#5737: Template Haskell can't derive Read, Show, Eq instances
---------------------------------------+------------------------------------
 Reporter:  guest                      |          Owner:                  
     Type:  bug                        |         Status:  new             
 Priority:  normal                     |      Component:  Template Haskell
  Version:  7.0.4                      |       Keywords:                  
       Os:  Unknown/Multiple           |   Architecture:  Unknown/Multiple
  Failure:  GHC rejects valid program  |       Testcase:                  
Blockedby:                             |       Blocking:                  
  Related:                             |  
---------------------------------------+------------------------------------
 Given the following code:

 {{{
 import Language.Haskell.TH
 makeAlpha' n = [d| data Alpha = Alpha $(conT n) deriving (Show, Read) |]
 }}}

 The compiler complains with the following error:

 {{{
 Can't derive instances where the instance context mentions
 type variables that are not data type parameters
   Offending constraint: Show t_d
 }}}

 But manually constructing the AST works without issues:

 {{{
 makeAlpha n = do
   let alpha = mkName "Alpha"
   dec <- dataD (return []) alpha []
     [normalC alpha [fmap ((,) NotStrict) $ conT n]]
     [''Show, ''Read]
   return [dec]
 }}}

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/5737>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler

_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to