Add instance Alternative (Either e)

Herbert Valerio Riedel hvriedel at gmail.com
Thu Aug 8 05:37:35 UTC 2019


On Tue, Aug 6, 2019 at 9:40 PM Dannyu NDos <ndospark320 at gmail.com> wrote:
> instance Monoid e => Alternative (Either e) where
>     empty = left mempty
>     Left x <|> Left y = Left (x <> y)
>     Left _ <|> y = y
>     x <|> _ = x
>
> Leftmost Right is returned for sake of consistence with Semigroup instance.

Related: https://ghc.haskell.org/trac/ghc/ticket/9588


More information about the Libraries mailing list