Re: [Haskell-cafe] template haskell for typeclass synonyms

2010-11-02 Thread Paolino
It's first time I use TH. It would be nice to point out the motivations for using it. If everything TH does is doable without it, the point of using it is write less code, eliminating some necessary and automatically computable code. But I guess there is some more . paolino 2010/11/2 Antoine

Re: [Haskell-cafe] template haskell for typeclass synonyms

2010-11-02 Thread Gábor Lehel
Well, Template Haskell is what you go to when what you want -can't- be reasonably expressed with standard GHC Haskell. It's something of a last resort (at least in my case). Typeclass synonyms can be faked reasonably well with UndecidableInstances, but if you want to, for example, automatically

[Haskell-cafe] template haskell for typeclass synonyms

2010-11-01 Thread Paolino
Hello. 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

Re: [Haskell-cafe] template haskell for typeclass synonyms

2010-11-01 Thread Christopher Done
On 1 November 2010 17:53, Paolino paolo.verone...@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

Re: [Haskell-cafe] template haskell for typeclass synonyms

2010-11-01 Thread Gábor Lehel
On Mon, Nov 1, 2010 at 6:09 PM, Christopher Done chrisd...@googlemail.com wrote: On 1 November 2010 17:53, Paolino paolo.verone...@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

Re: [Haskell-cafe] template haskell for typeclass synonyms

2010-11-01 Thread Paolino
Thanks. I annotated the function http://hpaste.org/paste/41035/test_simpleclasssynonym It seems to produce the right code. How should I use the Parents synonym in my functions? This is a noob question I suppose. paolino 2010/11/1 Gábor Lehel illiss...@gmail.com On Mon, Nov 1, 2010 at 6:09

Re: [Haskell-cafe] template haskell for typeclass synonyms

2010-11-01 Thread Paolino
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

Re: [Haskell-cafe] template haskell for typeclass synonyms

2010-11-01 Thread Antoine Latter
2010/11/1 Paolino paolo.verone...@gmail.com: 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