[Haskell-cafe] Re: [Haskell] How to define tail function for Even/Odd GADT lists?

David Roundy daveroundy at gmail.com
Wed Apr 23 19:46:49 EDT 2008

2008/4/23 Martijn Schrage <martijn at cs.uu.nl>:
>  It depends a bit on what you want to use these lists for, but the following
> encoding works for your examples and doesn't need the type class.
> data E
>  data O
>  type Even = (E,O)
>  type Odd  = (O,E)

That's a nice little trick!  I like how you achieve type signatures
relating two distinct types just by sticking them in a tuple.  :)


More information about the Haskell-Cafe mailing list