我只是哈斯克爾單子玩弄和我不斷收到,我似乎無法修復的錯誤。我的代碼段使用狀態Monad將字符串中的前兩個字符添加到一起,並將它們作爲狀態的一部分返回。我的「放」行不斷給我的錯誤: * Non type-variable argument in the constraint: MonadState [a] m
(Use FlexibleContexts to permit this)
*
當我這樣定義函數中ghci的: > :m Control.Monad
> let f n = n+1
> let g = liftM f
他們工作得很好: > g $ Just 2
> Just 3
> g $ [1,2]
> [2,3]
但是,當我定義文件相同的功能(probl.hs): import Control.Monad
f :: Integer -> Intege