【发布时间】:2011-10-28 20:23:55
【问题描述】:
您好,我正在尝试在 Haskell 中编写一个非常简单的函数。但是我不能让“ghci”接受我的代码。
data Field = A1 Int deriving (Show)
data FieldList = FL [Field] | Name String deriving (Show)
t :: Field
t = A1 1
u :: Int -> FieldList
u 0 = FL []
u n = FL [t]:(u (n-1))
我得到的错误是这样的:
test.hs:9:7:
Couldn't match expected type `FieldList' with actual type `[a0]'
In the expression: (FL [t]) : (u (n - 1))
In an equation for `u': u n = (FL [t]) : (u (n - 1))
有人能指出我正确的方向吗?
谢谢!
【问题讨论】:
标签: haskell