
27 Dec
2008
27 Dec
'08
3:21 p.m.
Andrew Wagner
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. For example, in Chris Okasaki's book Purely Functional Data Structures, the h in data BootstrapHeap h a = ... is always meant to satisfy 'Heap h =>', but this is ensured by putting the context at all the points where a BootstrapHeap is created, and not exporting BootstrapHeap's data constructors. Regards, Tom