[Haskell-cafe] Existentially-quantified constructors, Eq and Show

Joel Reymont joelr1 at gmail.com
Wed Dec 7 17:12:07 EST 2005


Is there a less verbose way of doing this:

data State a
     = Start
     | Stop
     | (Show a, Eq a) => State a

instance Eq a => Eq (State a) where
     (State a) == (State b) = a == b
     Start == Start = True
     Stop == Stop = True

instance Show a => Show (State a) where
     show (State a) = show a
     show Start = "Start"
     show Stop = "Stop"

	Thanks, Joel


More information about the Haskell-Cafe mailing list