Reputation:
Could you explain me why following code returns Nothing
insteaf od exception "zero" ?
Just 0 >>= (\ x -> if (x == 0) then fail "zero" else Just (x + 1) )
Upvotes: 2
Views: 97
Reputation: 2643
Because you are using the Maybe
instance of Monad
. This instance defines fail
as Nothing
.
Upvotes: 10