Module

Data.These

Package
purescript-these
Repository
purescript-contrib/purescript-these

#These Source

data These a b

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

Constructors

Instances

#these Source

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 Source

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

#thatOrBoth Source

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

#maybeThese Source

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 Source

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 Source

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

Returns an a value if possible.

#theseRight Source

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

Returns a b value if possible.

#this Source

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

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

#that Source

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

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

#both Source

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 Source

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

Returns true when the These value is This

#isThat Source

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

Returns true when the These value is That

#isBoth Source

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

Returns true when the These value is Both

#swap Source

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

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

#assoc Source

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

Re-associate These from left to right.