
3 Jun
2008
3 Jun
'08
8:51 p.m.
Adam Smyczek
data SampleType = A | B Int | C String | D -- .... etc. deriving (Eq)
sampleTypes = [A, B 5, C "test"] :: [SampleType]
If you derive from Eq, you can do isA = (==) A filter isA sampleTypes or ad-hoc: filter ((==) A) sampleTypes things like filter (\x -> case x of { A -> True ; B b | b > 2 -> True ; C c | c == "foo" -> True ; _ -> False}) sampleTypes work, too. Admittedly, I'm lambda-spoilt. -- (c) this sig last receiving data processing entity. Inspect headers for past copyright information. All rights reserved. Unauthorised copying, hiring, renting, public performance and/or broadcasting of this signature prohibited.