Proposal and discussion: Add MonadFail instance to Either

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)

IsString str => MonadFail (Either str) does make sense to me. +1
2016-08-12 8:02 GMT+09:00 Tobias Markus
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) _______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

+1 from me. it is perfectly "right sized" in terms of what it requires.
-Edward
On Thu, Aug 11, 2016 at 7:02 PM, Tobias Markus
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) _______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
participants (3)
-
Edward Kmett
-
Fumiaki Kinoshita
-
Tobias Markus