This module implements 'Either' like in Haskell.
Actuall type declaration
left : Either a b -> Maybe a
Decodes the left side of an Either statement. Will return Nothing if the variable is on the right.
Similar to right
.
right : Either a b -> Maybe b
Decodes the right side of an Either statement. Will return Nothing if the variable is on the left.
Similar to left
.
leftI : a -> Either a b -> a
Like left
, but insured. If the variable is on the right side, a given value will be returned instead.
rightI : b -> Either a b -> b
Like right
, but insured. If the variable is on the left side, a given value will be returned instead.
This is like an enum declaration for which side is active in an Either variable.
They can not be Left
and Right
, because those constructors are already taken by
the above Either
declaration.
side : Either a b -> Side
Returns which side of the variable is active.
isOnSide : Side -> Either a b -> Basics.Bool
Checks if the Either variable is on a given side.
sameSide : Either a b -> Either c d -> Basics.Bool
Checks if two Either variables are active on the same side.
allSameSide : List (Either a b) -> Basics.Bool
Checks if ALL the Either variables are on the same side.
lefts : List (Either a b) -> List a
Gets all the left values of a list of Either variables.
rights : List (Either a b) -> List b
Gets all the right values of a list of Either variables.
flip : Either a b -> Either b a
Flips the sides around, so that a becomes b and b becomes a.