Commit 5685b476 authored by Steffen Michels's avatar Steffen Michels

restore gEq instance for Either

parent 4b5ce424
Pipeline #14950 passed with stage
in 1 minute and 15 seconds
......@@ -12,6 +12,7 @@ from Data.Monoid import class Monoid, class Semigroup
from Data.Foldable import class Foldable
from Data.Traversable import class Traversable
from Data.Bifunctor import class Bifunctor
from Data.GenEq import generic gEq
:: Either a b = Left a | Right b
......@@ -33,6 +34,8 @@ instance Bifunctor Either
instance Alternative (Either m) | Monoid m
derive gEq Either
either :: .(.a -> .c) .(.b -> .c) !(Either .a .b) -> .c
lefts :: .[Either .a .b] -> .[.a]
rights :: .[Either .a .b] -> .[.b]
......
......@@ -12,6 +12,7 @@ from Data.Foldable import class Foldable(foldMap,foldl,foldr)
from Data.Traversable import class Traversable(traverse)
import qualified Data.Traversable as T
import Data.Bifunctor
import Data.GenEq
instance Functor (Either a) where
fmap f (Left l) = Left l
......@@ -80,6 +81,8 @@ where
empty = Left mempty
(<|>) fa fb = either (\e->either (Left o mappend e) Right fb) Right fa
derive gEq Either
either :: .(.a -> .c) .(.b -> .c) !(Either .a .b) -> .c
either f _ (Left x) = f x
either _ g (Right y) = g y
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment