查找之后Control.Monad https://hackage.haskell.org/package/base-4.9.1.0/docs/Control-Monad.html文档,我很困惑
这段话:
上述法律意味着:
fmap f xs = xs >>= return . f
他们是如何暗示这一点的?
Control.Applicative https://hackage.haskell.org/package/base-4.9.1.0/docs/Control-Applicative.html says
由于这些法律,Functor
f 的实例将满足
fmap f x = pure f <*> x
之间的关系Applicative
and Monad
says
pure = return
(<*>) = ap
ap https://hackage.haskell.org/package/base-4.9.1.0/docs/Control-Monad.html#v:ap says
return f `ap` x1 `ap` ... `ap` xn
相当于
liftMn f x1 x2 ... xn
所以
fmap f x = pure f <*> x
= return f `ap` x
= liftM f x
= do { v <- x; return (f v) }
= x >>= return . f
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)