Open tomjaguarpaw opened 2 years ago
How do you even begin to prove this?
fail s
cannot contain any values of an arbitrary type a
.f
can never be invoked by >>=
.f
cannot be invoked, >>=
must behave the same way for any f
.f
be pure
— by a law of monad >>= pure
≡ id
. Therefore, by №3 >>= f
≡ id
for any f
.id (fail s)
≡ fail s
. ∎— Maybe like this.
But this all on the assumption that everything is defined. Is this an admissible assumption? Otherwise, we can consider situations where >>=
invokes f
with undefined
— then f
can either crash (≢ fail s
) or return an arbitrary value (≢ fail s
).
Apparently you can prove it by parametricity. See https://www.reddit.com/r/haskell/comments/u5k4gv/is_it_possible_for_fail_s_not_to_be_a_left_zero/.
The
MonadFail
docs say thatfail s
must be a "left zero", i.e.But given that
fail s :: forall a. m a
is there any way that it couldn't be a left zero?