错误:
maybet.hs:8:14:
Couldn't match expected type `MaybeT m0 t0'
with actual type `Maybe a0'
In the return type of a call of `M.lookup'
In a stmt of a 'do' expression: m <- M.lookup "a" a
In the second argument of `($)', namely
`do { m <- M.lookup "a" a;
lift $ putStrLn m }'
和代码:
import qualified Data.Map as M
import Control.Monad.Trans.Maybe
import Control.Monad.Trans.Class
main = do
let a = M.fromList [("a", "b"), ("c", "d")]
runMaybeT $ do
m <- M.lookup "a" a
lift $ putStrLn m
putStrLn "done"
如果有人可以帮助我使用 MaybeT 变压器,我将不胜感激。我不知道如何让这个工作。