【发布时间】:2019-12-25 09:20:55
【问题描述】:
我正在处理一个函数
createTypeBoard :: (Int, Int) -> CellType -> Board
使用这些类型
newtype Board = Board [(Cell, CellType)] deriving(Eq)
data CellType = Mine
| Flag
| Void
| Enumerated Int
| Undiscovered
deriving Eq
type Cell = (Int, Int)
createTypeBoard (2,2) 我的应该是:Board [((1,1), X), ((1,2), X), ((2,1), X), ((2,2 ), X)]
(X 是我的节目实例)
我的想法是使用 zip:
createTypeBoars (a, b) c = zip (createCells (a, b)) [c]
但我不断收到错误
• Couldn't match expected type ‘Board’
with actual type ‘[(Cell, CellType)]’
• In the expression: zip (createCells (a, b)) [Flag]
In an equation for ‘createTypeBoard’:
createTypeBoard (a, b) Flag = zip (createCells (a, b)) [Flag]
Board 基本上是 [(Cell, CellType)] 所以我真的不明白问题是什么:(
【问题讨论】: