Proposal: pattern synonyms

Malcolm Wallace Malcolm.Wallace at cs.york.ac.uk
Thu Feb 16 05:37:29 EST 2006


Conor McBride <ctm at cs.nott.ac.uk> writes:

>   P x y z = C x (y, [z])

Isn't this idea very similar to views, and pattern-guards?
For instance, you could rewrite your example thus:

data EffectView x = Bang
                  | Bing x
                  | Dull x

view :: MyEffect x -> EffectView x
view (Comp Nothing)                         = Bang
view (Comp (Just (Prod (Any True), Id x)))  = Bing x
view (Comp (Just (Prod (Any False), Id x))) = Dull x

my_function e
    | Bang   <- view effect  = ...
    | Bing x <- view effect  = ... x ...
    | Dull x <- view effect  = ... x ...

Regards,
    Malcolm


More information about the Haskell-prime mailing list