Module

Data.These

#These

data These a b

Data type isomorphic to α ∨ β ∨ (α ∧ β) or Either a (Either b (Tuple a b)).

Constructors

Instances

#these

these :: forall a b c. (a -> c) -> (b -> c) -> (a -> b -> c) -> These a b -> c

Given functions to handle each constructor, collapse a These value into single value.

#thisOrBoth

thisOrBoth :: forall a b. a -> Maybe b -> These a b

#thatOrBoth

thatOrBoth :: forall a b. b -> Maybe a -> These a b

#maybeThese

maybeThese :: forall a b. Maybe a -> Maybe b -> Maybe (These a b)

Takes a pair of Maybes and attempts to create a These from them.

#fromThese

fromThese :: forall a b. a -> b -> These a b -> Tuple a b

Takes two default values and a These value. If the These value is This or That, the value wrapped in the These value and its corresponding default value are wrapped into a Tuple. Otherwise, the values stored in the Both are rewrapped into a Tuple.

#theseLeft

theseLeft :: forall a b. These a b -> Maybe a

Returns an a value if possible.

#theseRight

theseRight :: forall a b. These a b -> Maybe b

Returns a b value if possible.

#this

this :: forall a b. These a b -> Maybe a

Returns the a value if and only if the value is constructed with This.

#that

that :: forall a b. These a b -> Maybe b

Returns the b value if and only if the value is constructed with That.

#both

both :: forall a b. These a b -> Maybe (Tuple a b)

Returns the a and b values if and only if they are constructed with Both.

#isThis

isThis :: forall a b. These a b -> Boolean

Returns true when the These value is This

#isThat

isThat :: forall a b. These a b -> Boolean

Returns true when the These value is That

#isBoth

isBoth :: forall a b. These a b -> Boolean

Returns true when the These value is Both

#swap

swap :: forall a b. These a b -> These b a

Swap between This and That, and flips the order for Both.

#assoc

assoc :: forall a b c. These (These a b) c -> These a (These b c)

Re-associate These from left to right.

Modules