Remove MonadFail (ST s) instance
Bertram Felgenhauer
bertram.felgenhauer at googlemail.com
Mon Nov 25 10:28:09 UTC 2019
Oleg Grenrus wrote:
> I cannot see any justification for that instance
>
> -- | @since 4.11.0.0
> instance Fail.MonadFail (ST s) where
> fail s = errorWithoutStackTrace s
It's certainly not in the spirit of the MonadFail proposal. Arguably,
*all* implementations of `fail` in terms of `error*` are wrong, even
the one for IO. (I suspect dropping the instance for IO would cause a
lot of pain though...)
I'm neutral on the proposal itself.
> If someone wants to fail pattern matches in `ST s`, please do that
> explicitly.
However, I don't like this framing. In practice, there's at least one
other use of MonadFail for historical reasons: generic code that may
fail. Before MFP, one could write (and people have written) code like
fooM :: Monad m => a -> m b
fooM ... = fail "unsupported case"
It is easy enough to change the signature of such a `fooM` to require
MonadFail, but then the function becomes impossible to use for monads
that don't have a MonadFail instance. So after the MFP, one should
provide two functions instead, one using `error` and another one
using `fail`...
> Note: compatibility package
> https://hackage.haskell.org/package/fail-4.9.0.0/docs/Control-Monad-Fail.html
> doesn't have that instance, so I suspect not-that many use(d) that instance.
Or perhaps nobody cares about ghc-7.10 anymore.
Cheers,
Bertram
More information about the Libraries
mailing list