我有这个功能:
data Memory = Memory
{visited::[Point]
,dfsstack::[Point]
,currentPoz::Point
}deriving(Eq)
perceiveAndAct :: SVal -> [Cardinal] -> a -> (Action, a)
perceiveAndAct s cs m
| elem W cs == True && elem N cs == True && elem E cs == True && elem S cs == False = (Just S, Memory (visited m) (dfsstack m) (currentPoz m))
把 m 而不是 Memory (visited m) (dfsstack m) (currentPoz m)
工作正常,否则它给了我:
Couldn't match expected type `(a, b)'
against inferred type `Memory -> Point'
In the first argument of `fst', namely `currentPoz'
In the first argument of `($)', namely `fst currentPoz'
In the expression: fst currentPoz $ currentPoz m
可能是什么问题呢?