[Haskell-cafe] Pattern matching
Stefan Aeschbacher
haskell at aeschbacher.ch
Mon Jan 15 04:21:22 EST 2007
2007/1/15, Stefan O'Rear <stefanor at cox.net>:
> On Mon, Jan 15, 2007 at 10:09:10AM +0100, Stefan Aeschbacher wrote:
> > Hi
> >
> > I sometimes have a function definition similar to this:
> >
> > myFunction x@(Constructor1 _ _ _ _ _ _) = ...
> > myFunction x@(Constructor2 _ _ _ _ _ _ _ _) = ...
>
> myFunction x at Constructor1{} = ...
> myFunction x at Constructor2{} = ...
>
> this works even for non-record types
I didnt know about the possibilty to use {}. This solves my problem
quite nicely.
thanks
More information about the Haskell-Cafe
mailing list