为什么这段代码返回Nothing而不是抛出异常

2 monads haskell

你能解释一下为什么下面的代码返回Nothinginsteaf od异常"零"吗?

Just 0 >>= (\ x -> if (x == 0) then fail "zero" else Just (x + 1) )
Run Code Online (Sandbox Code Playgroud)

Wil*_*ell 10

因为您正在使用的Maybe实例Monad.此实例定义failNothing.