我愿履行一项职能,即它的作用。
iterateM :: Monad m => (a -> m a) -> a -> [m a]
然而,我第一次撰写这一职务:
iterateM f x = f x >>= (x -> return x : iterateM f x )
我会发现错误:
Could not deduce (m ~ [])
from the context (Monad m)
bound by the type signature for
iterateM :: Monad m => (a -> m a) -> a -> [m a]
at main.hs:3:1-57
`m is a rigid type variable bound by
the type signature for
iterateM :: Monad m => (a -> m a) -> a -> [m a]
at main.hs:3:1
Expected type: [a]
Actual type: m a
In the return type of a call of `f
In the first argument of `(>>=) , namely `f x
In the expression: f x >>= ( x -> return x : iterateM f x )
如果我删除我的类型,格西兹告诉我,我的职能类型是:
iterateM :: Monad m => (a -> [a]) -> a -> [m a]
我在这里失踪了吗?