[Haskell-cafe] Automatic derivation (TemplateHaskell?)

Twan van Laarhoven twanvl at gmail.com
Thu Apr 5 07:07:14 EDT 2007


Joel Reymont wrote:
 > This is in Language.Haskell.TH.Syntax which is imported at the top of
 > Data/Derive/TH.hs so I don't understand the cause of the error
 >
 > instance Functor Q where
 >   fmap f (Q x) = Q (fmap f x)
 >
 > ...
 >
 > Any suggestions?

Since Q is a Monad, you can make the instance

 > instance Functor Q where
 >     fmap = liftM


 >
 > But Q is exported by Languave.Haskell.TH.Syntax !!!
 >

Only the type constructor is exported, not the data constructor.

Twan


More information about the Haskell-Cafe mailing list