Proposal and discussion: Add MonadFail instance to Either

Tobias Markus tobias at miglix.eu
Thu Aug 11 23:02:25 UTC 2016


As suggested in the GHC Trac [1], it would be nice to have a MonadFail
instance for Either. The original suggestion by lexi.lambda was

  instance MonadFail (Either String) where
    fail = Left

However, it was rightfully pointed out that this instance is overly
specific. The discussion arrived at the following alternative proposed
by Iceland_jack:

  instance IsString str => MonadFail (Either str) where
    fail = Left . fromString

For previous discussion on this proposal, please take a look at the Trac
thread.

I am looking forward to your input!

Tobias

[1] GHC Trac Ticket #12160, https://ghc.haskell.org/trac/ghc/ticket/12160

--
Tobias Markus

"They who would give up essential Liberty, to purchase a little
temporary Safety, deserve neither Liberty nor Safety."
        -- Benjamin Franklin (1706-1790)


More information about the Libraries mailing list