[Haskell-cafe] template haskell for typeclass synonyms

Paolino paolo.veronelli at gmail.com
Mon Nov 1 17:24:24 EDT 2010


I think I've got something nice in the end.

http://hpaste.org/41042/classsynonymhs

example:

class  (    ParteDi (Servizio a) s
        ,    Read a
        ,    Eq a
        ,     Show a
        ,     Integer `ParteDi` s
        ) => SClass s a

$(classSynonym ''SClass)

ghci ":i SClass" command is printing some strange type variables but it
compiles

paolino

2010/11/1 Gábor Lehel <illissius at gmail.com>

> On Mon, Nov 1, 2010 at 6:09 PM, Christopher Done
> <chrisdone at googlemail.com> wrote:
> > On 1 November 2010 17:53, Paolino <paolo.veronelli at gmail.com> wrote:
> >> I'd like to have a template haskell function that take some constraints
> and
> >> a class name and write an empty class from those and relative empty
> instance
> >> to simulate typeclass synonyms.
> >>
> >> As I've never written TH and couldn't find a easily adaptable code
> around, I
> >> ask here for the code, or some hints on how to arrive there.
> >
> > I took Justin Bailey's haskelldb-th library as a TH example to work
> > from and rewrote one TH function to try my hand at it, it's quite easy
> > to follow with a simple example:
> >
> > http://hpaste.org/paste/41035/demo
> >
> > Maybe this is enough example to get you going. The rest you can find
> > syntax parts from the TH Haddock documentation.
>
> A useful FYI: the API docs are (almost) completely devoid of comments,
> but if you click to see the source, it does have some additional
> information in comments there, just not Haddock-formatted.
>
>
> > _______________________________________________
> > Haskell-Cafe mailing list
> > Haskell-Cafe at haskell.org
> > http://www.haskell.org/mailman/listinfo/haskell-cafe
> >
>
>
>
> --
> Work is punishment for failing to procrastinate effectively.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20101101/8f260eb7/attachment.html


More information about the Haskell-Cafe mailing list