sanctuary-either
The Either type represents values with two possibilities: a value of type
Either a b
is either a Left whose value is of type a
or a Right whose
value is of type b
.
Either a b
satisfies the following Fantasy Land specifications:
> const Useless = > const isTypeClass = type x === 'sanctuary-type-classes/TypeClass@1' > S S 'Setoid ✅ * ' // if ‘a’ and ‘b’ satisfy Setoid 'Ord ✅ * ' // if ‘a’ and ‘b’ satisfy Ord 'Semigroupoid ❌ ' 'Category ❌ ' 'Semigroup ✅ * ' // if ‘a’ and ‘b’ satisfy Semigroup 'Monoid ❌ ' 'Group ❌ ' 'Filterable ❌ ' 'Functor ✅ ' 'Bifunctor ✅ ' 'Profunctor ❌ ' 'Apply ✅ ' 'Applicative ✅ ' 'Chain ✅ ' 'ChainRec ✅ ' 'Monad ✅ ' 'Alt ✅ ' 'Plus ❌ ' 'Alternative ❌ ' 'Foldable ✅ ' 'Traversable ✅ ' 'Extend ✅ ' 'Comonad ❌ ' 'Contravariant ❌ '
Either :: TypeRep Either
Either type representative.
Either.Left :: a -> Either a b
Constructs a value of type Either a b
from a value of type a
.
>
Either.Right :: b -> Either a b
Constructs a value of type Either a b
from a value of type b
.
>
Either.fantasy-land/of :: b -> Either a b
of (Either) (x)
is equivalent toRight (x)
> S 42
Either.fantasy-land/chainRec :: ((a -> c, b -> c, a) -> Either d c, a) -> Either d b
> Z > Z
Either#@@show :: (Showable a, Showable b) => Either a b ~> () -> String
show (Left (x))
is equivalent to'Left (' + show (x) + ')'
show (Right (x))
is equivalent to'Right (' + show (x) + ')'
> 'Left ("sqrt undefined for -1")' > 'Right ([1, 2, 3])'
Either#fantasy-land/equals :: (Setoid a, Setoid b) => Either a b ~> Either a b -> Boolean
Left (x)
is equal toLeft (y)
iffx
is equal toy
according toZ.equals
Right (x)
is equal toRight (y)
iffx
is equal toy
according toZ.equals
Left (x)
is never equal toRight (y)
> S true > S true > S false
Either#fantasy-land/lte :: (Ord a, Ord b) => Either a b ~> Either a b -> Boolean
Left (x)
is less than or equal toLeft (y)
iffx
is less than or equal toy
according toZ.lte
Right (x)
is less than or equal toRight (y)
iffx
is less than or equal toy
according toZ.lte
Left (x)
is always less thanRight (y)
> S > S > S > S
Either#fantasy-land/concat :: (Semigroup a, Semigroup b) => Either a b ~> Either a b -> Either a b
concat (Left (x)) (Left (y))
is equivalent toLeft (concat (x) (y))
concat (Right (x)) (Right (y))
is equivalent toRight (concat (x) (y))
concat (Left (x)) (Right (y))
is equivalent toRight (y)
concat (Right (x)) (Left (y))
is equivalent toRight (x)
> S > S > S > S
Either#fantasy-land/map :: Either a b ~> (b -> c) -> Either a c
map (f) (Left (x))
is equivalent toLeft (x)
map (f) (Right (x))
is equivalent toRight (f (x))
> S > S
Either#fantasy-land/bimap :: Either a c ~> (a -> b, c -> d) -> Either b d
bimap (f) (g) (Left (x))
is equivalent toLeft (f (x))
bimap (f) (g) (Right (x))
is equivalent toRight (g (x))
> S S > S S
Either#fantasy-land/ap :: Either a b ~> Either a (b -> c) -> Either a c
ap (Left (x)) (Left (y))
is equivalent toLeft (x)
ap (Left (x)) (Right (y))
is equivalent toLeft (x)
ap (Right (f)) (Left (x))
is equivalent toLeft (x)
ap (Right (f)) (Right (x))
is equivalent toRight (f (x))
> S > S > S > S
Either#fantasy-land/chain :: Either a b ~> (b -> Either a c) -> Either a c
chain (f) (Left (x))
is equivalent toLeft (x)
chain (f) (Right (x))
is equivalent tof (x)
> const sqrt = n < 0 ? : > S > S > S
Either#fantasy-land/alt :: Either a b ~> Either a b -> Either a b
alt (Left (y)) (Left (x))
is equivalent toLeft (y)
alt (Right (y)) (Left (x))
is equivalent toRight (y)
alt (Left (y)) (Right (x))
is equivalent toRight (x)
alt (Right (y)) (Right (x))
is equivalent toRight (x)
> Salt > Salt > Salt > Salt
Either#fantasy-land/reduce :: Either a b ~> ((c, b) -> c, c) -> c
reduce (f) (x) (Left (y))
is equivalent tox
reduce (f) (x) (Right (y))
is equivalent tof (x) (y)
> S 1 1 > S 1 1 2
Either#fantasy-land/traverse :: Applicative f => Either a b ~> (TypeRep f, b -> f c) -> f (Either a c)
traverse (A) (f) (Left (x))
is equivalent toof (A) (Left (x))
traverse (A) (f) (Right (x))
is equivalent tomap (Right) (f (x))
> S Swords > S Swords
Either#fantasy-land/extend :: Either a b ~> (Either a b -> c) -> Either a c
extend (f) (Left (x))
is equivalent toLeft (x)
extend (f) (Right (x))
is equivalent toRight (f (Right (x)))
> S > S