以下代码无法编译:
这样做推导是否可行?
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) |]
这样做推导是否可行?
$(conT n)
看起来像什么。不过我不确定。 - ehirddata Alpha = $(conT n)
或者类似的东西吧?我认为你现在的代码存在类型错误,至少从 Dec 的定义上看是这样的。 - ehird