Hi Stefan,

myFunction x@(Constructor1 _*) = ...
myFunction x@(Constructor2 _*) = ...

myFunction x@(Constructor1 {}) =
myFunction x@(Constructor2 {}) =


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
constructor).

In this context a is not a type, but a value, and the non-ambiguous
constraint can get pretty confusing in a case like this. The answer is
to use records:

data Data = Constructor1 {field1 :: Bool, field2 :: Int, field3 :: Int}

myFunction (Constructor1 {field2=a}) = ...

Thanks

Neil
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to