
Tom Pledger wrote:
Andrew Wagner
writes: I'm sure there's a way to do this, but it's escaping me at present. I want to do something like this:
data Foo = Bar a => Foo a Bool ...
That is, I want to create a new type, Foo, whose constructor takes both a Boolean and a value of a type of class Bar.
Sometimes it's enough to declare
data Foo a = Foo a Bool
and to put the 'Bar a =>' context onto the functions and instances that involve Foo.
Although, if you really want to omit the `a` from the type, you can use the ExistentialQuantification extension or GADTs to do something like: -- with ExistentialQuantification data Foo = forall a . Bar a => Foo a Bool -- with GADTs data Foo where forall a . Bar a => Foo a Bool I haven't used either extension in a few months though, so I may have gotten the syntax wrong. You can look them up to be sure. - Jake