One or the other.
One or the other.
When (not) to use this? → readme
value : Or value value -> value
Treat the values from the First
and Second
case equally
[ Or.First 0, Or.Second 1 ] |> List.map Or.value
--> [ 0, 1 ]
onFirstMap : (first -> firstMapped) -> Or first second -> Or firstMapped second
In case it's the First
, change it based on it's current value
Or.First "hello" |> Or.onFirstMap String.toUpper
--> Or.First "HELLO"
Or.Second "hello" |> Or.onFirstMap String.toUpper
--> Or.Second "hello"
Prefer a case..of
if you handle both cases
onSecondMap : (second -> secondMapped) -> Or first second -> Or first secondMapped
In case it's the Second
, change it based on it's current value
Or.First "hello" |> Or.onSecondMap String.toUpper
--> Or.First "hello"
Or.Second "hello" |> Or.onSecondMap String.toUpper
--> Or.Second "HELLO"
Prefer a case..of
if you handle both cases
justOnFirst : Or first second_ -> Maybe first
Just
if the first value is present, Nothing
if the second is present
Or.First 0 |> Or.justOnFirst --> Just 0
Or.Second 1 |> Or.justOnFirst --> Nothing
Prefer a case..of
if you handle both cases
justOnSecond : Or first_ second -> Maybe second
Just
if the second value is present, Nothing
if the first is present
Or.First 0 |> Or.justOnSecond --> Nothing
Or.Second 1 |> Or.justOnSecond --> Just 1
Prefer a case..of
if you handle both cases