Pattern guards vs. case (was, unfortunately :Re: interesting example of laziness/ghc optimisation)

Johannes Waldmann joe@isun.informatik.uni-leipzig.de
Thu, 1 Mar 2001 11:52:33 +0100 (MET)


> But if you want to be really weird you can write something
> like (I haven't typed this in):
> 
> f x | (Foo _) == x = 
> f x | (Bar _) == x =

no, you can't, e. g. hugs (Feb 2000) says

Prelude> let f x | Just 4 == x = 0 in f (Just 4)
0
Prelude> let f x | Just _ == x = 0 in f (Just 4)
ERROR: Illegal `_' in expression

-- 
-- Johannes Waldmann ---- http://www.informatik.uni-leipzig.de/~joe/ --
-- joe@informatik.uni-leipzig.de -- phone/fax (+49) 341 9732 204/252 --