[Haskell-cafe] Re: Scraping boilerplate deriving?

Kevin Jardine kevinjardine at gmail.com
Wed Sep 15 09:11:46 EDT 2010


Hi Malcolm,

In this case, I am counting on GHC's

{-# LANGUAGE GeneralizedNewtypeDeriving #-}

feature to derive the instances for the classes I am including in the
deriving clause.

So perhaps portability is not a big issue here in any case.

I do think that

defObj(MyType)

looks a bit cleaner than

$(defObj "MyType")

so I am starting to lean back towards the CPP solution after all.

CPP is not always the best option, but perhaps it is in this case.

Kevin

On Sep 15, 10:31 am, Malcolm Wallace <malcolm.wall... at me.com> wrote:
> > That's what I had originally. However, some people have made critical
> > comments about CPP macros on this list and I thought that TH was
> > considered the better option.
>
> I was one of those people advising against the use of CPP macros.  
> However, Template Haskell is ghc-only, and is unlikely ever to be  
> implemented by any other Haskell compiler.  Thus CPP, for all its  
> faults, may be the better solution here, simply because it is portable.
>
> (I also note in passing that ghc's core libraries themselves use  
> exactly this kind of CPP macro to generate lots of tedious boilerplate.)
>
> Regards,
>      Malcolm
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-C... at haskell.orghttp://www.haskell.org/mailman/listinfo/haskell-cafe


More information about the Haskell-Cafe mailing list