tomjaguarpaw / tilapia

Improving all Haskell's programmer interfaces

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Improve MonadFail docs - isn't 'fail s' always a left zero?

tomjaguarpaw opened this issue · comments

The MonadFail docs say that fail s must be a "left zero", i.e.

fail s >>= f  =  fail s

But given that fail s :: forall a. m a is there any way that it couldn't be a left zero?

How do you even begin to prove this?

  1. fail s cannot contain any values of an arbitrary type a.
  2. Therefore, f can never be invoked by >>=.
  3. Since f cannot be invoked, >>= must behave the same way for any f.
  4. Take f be pure — by a law of monad >>= pureid. Therefore, by №3 >>= fid for any f.
  5. 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).