[Haskell-cafe] matching constructors
Koji Nakahara
yu- at div.club.ne.jp
Tue Mar 9 08:51:05 EST 2004
How about this approach ?
I think this is a conventional and clear way,
though Flag Verbose has a verbose String.
-----
import Data.List
import Data.Maybe
data Flag = Flag FlagType String
deriving Show
getFlagType (Flag ft _) = ft
data FlagType = Verbose | Input | Output | Filter
deriving (Show, Eq)
findFlag f@(Flag ft _) xs = fromMaybe f (find ((ft ==).getFlagType) xs)
-- instance Eq Flag where
-- Flag ft1 _ == Flag ft2 _ = ft1 == ft2
----
--
Koji Nakahara
More information about the Haskell-Cafe
mailing list