deriving...
Andre Pang
ozone at algorithm.com.au
Wed Oct 13 10:50:06 EDT 2004
On 13/10/2004, at 10:02 AM, MR K P SCHUPKE wrote:
> Okay, I see the Generic type class stuff does not support multi
> parameter type classes. I guess I am stuck - any suggestions as to
> how best do this?
>
> I wish to be able to derive type level labels for datatypes, like
> the following:
>
> data Fred a = Fred a deriving TTypeable
>
> generates the instance:
>
> instance TTypeable a al => TTypeable (Fred a) (NCons (N3 (N4 (N5
> Nil))) (TCons al Nil))
If you are happy to live on the edge a bit (which you seem to be happy
with, considering that you're playing with GHC CVS ;), Template Haskell
might be one way to do it. See "Template Haskell: A Report from the
Field", a paper where Ian Lynagh does exactly what you're trying to do:
http://www.haskell.org/th/papers.html
--
% Andre Pang : trust.in.love.to.save
More information about the Glasgow-haskell-users
mailing list