Adam Smyczek <[EMAIL PROTECTED]> wrote:

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

_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to