Template Haskell can't derive Read, Show, Eq instances
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]
Trac metadata
| Trac field | Value |
|---|---|
| Version | 7.0.4 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Template Haskell |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture |