[Haskell-cafe] Pattern matching
haskell at aeschbacher.ch
Mon Jan 15 04:09:10 EST 2007
I sometimes have a function definition similar to this:
myFunction x@(Constructor1 _ _ _ _ _ _) = ...
myFunction x@(Constructor2 _ _ _ _ _ _ _ _) = ...
which in my eyes is not very elegant and easy to type. Is there an easier way to
switch on the different constructors of a type (Data.Generics
certainly could be used..)?
If not, has thought been put in a pattern matching possibility of the
form _*. This
myFunction x@(Constructor1 _*) = ...
myFunction x@(Constructor2 _*) = ...
Also pattern matches of the form:
myFunction2 (Constructor1 _* a _*) = ...
could be possible as long as the pattern is non-ambiguous (in this
case, only one variable with the type of a is present in this
More information about the Haskell-Cafe