錯誤: 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.loo
名單,我有以下功能: -- xs: list to be changed
-- ws: list of indices where the values will change to 0
replaceAtIndices xs ws = [if (fromJust (elemIndex x xs)) `elem` ws then 0 else x | x <- xs]
功能發生在2名列表。
我有一個函數定義 maybeToList :: (a -> Maybe a) -> a -> [a]
maybeToList f x = x : maybe [] (maybeToList f) (f x)
這個功能似乎很明顯,我不能相信這不是標準。 是否在某個模塊中定義(我已經檢查過Data.Maybe)?