I am new to Haskell, but I have background in various programming languages (including Lisp)
I have very basic question, if there is a way to match algebraic types constructors besides
use of pattern matching. I wrote today code like this:
data Flag = Verbose |
Input String |
Output String |
Filter String
deriving Showinstance Eq Flag where
Verbose == Verbose = True
Input _ == Input _ = True
Output _ == Output _ = True
Filter _ == Filter _ = True
_ == _ = FalsefindFlag :: Flag -> [Flag] -> Flag findFlag f [] = f findFlag y (x:xs) = if x == y then x else findFlag y xs
If there is a cleaner way to implement findFlag and Eq Flag?
Vadim
-- "La perfection est atteinte non quand il ne reste rien a ajouter, mais quand il ne reste rien a enlever." (Antoine de Saint-Exupery)
_______________________________________________ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
