标签: haskell
查看fail MaybeT实例中Monad的源代码:
fail
MaybeT
Monad
instance (Monad m) => Monad (MaybeT m) where fail _ = MaybeT (return Nothing)
很明显,没有使用fail的论点。那么为什么没有像quit :: MaybeT m ()这样的更清晰的功能可以避免我们每次都输入fail ""?或者我错过了什么?
quit :: MaybeT m ()
fail ""
答案 0 :(得分:8)
这是MaybeT mzero is个实例MonadPlus的内容(除了类型比您给出的更通用:MaybeT个实例,我们有mzero :: Monad m => MaybeT m a)。
mzero
MonadPlus
mzero :: Monad m => MaybeT m a