On 6/1/06, Christophe Poucet <[EMAIL PROTECTED]> wrote:
That's why
today I have created an automated derivation for data constructor
filtering. As I started coding someone mentioned that something similar
can be done with list comprehensions, so I'm not certain about the scope
of usefulness, however personally I have found the need for this at
times.

data T = A Int | B String deriving Show
test1 = [A 3, B "hello", A 5]
test2 = [x | x@(A _) <- test1]

The key here is that pattern match failure in a monad calls fail:
http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v%3Afail
and fail in the List monad is [].
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to