It is.
-- https://hackage.haskell.org/package/base-4.12.0.0/docs/src/Control.Monad.Fail.html#line-80
instance MonadFail IO where
fail = failIO
-- https://hackage.haskell.org/package/base-4.12.0.0/docs/src/GHC.IO.html#failIO
failIO :: String -> IO a
failIO s = IO (raiseIO# (toException (userError s)))
Compare to
-- https://hackage.haskell.org/package/base-4.12.0.0/docs/src/GHC.IO.Exception.html#ioException
ioException :: IOException -> IO a
ioException err = throwIO err
-- https://hackage.haskell.org/package/base-4.12.0.0/docs/src/GHC.IO.Exception.html#ioError
ioError :: IOError -> IO a
ioError = ioException
-- https://hackage.haskell.org/package/base-4.12.0.0/docs/src/GHC.IO.html#throwIO
throwIO :: Exception e => e -> IO a
throwIO e = IO (raiseIO# (toException e))
- Oleg
On Mon, 25 Nov 2019, Bertram Felgenhauer via Libraries wrote:
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...)
Isn't fail in IO a synonym for (ioError . userError) ?
_______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries