Объявления данных шаблона Haskell, которые производят Show

Следующее не компилируется:

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

Я вообще не могу понять, что означает ошибка:

Can't derive instances where the instance context mentions
type variables that are not data type parameters
  Offending constraint: Show t_d
When deriving the instance for (Show Alpha)
In the Template Haskell quotation
  [d| data Alpha = Alpha $(conT n) deriving (Show, Read) |]
In the expression:
  [d| data Alpha = Alpha $(conT n) deriving (Show, Read) |]

Можно ли делать подобные деривации?

8
задан Ana 31 December 2011 в 18:01
поделиться