One, the other or both.
In case we have Both, change them based on their current values
import Or
AndOr.Only (Or.First "hello")
|> AndOr.onBothAlter (Tuple.mapFirst String.toUpper)
--> AndOr.Only (Or.First "hello")
AndOr.Both ( "hello", "there" )
|> AndOr.onBothAlter (Tuple.mapFirst String.toUpper)
--> AndOr.Both ( "HELLO", "there" )Prefer a case..of if you handle both cases
In case we have Only one of them, change it based on its current value
import Or
AndOr.Only (Or.First "hello")
|> AndOr.onOnlyAlter (Or.onFirstMap String.toUpper)
--> AndOr.Only (Or.First "HELLO")
AndOr.Both ( "hello", "there" )
|> AndOr.onOnlyAlter (Or.onFirstMap String.toUpper)
--> AndOr.Both ( "hello", "there" )Prefer a case..of if you handle both cases
Just if both values are present, Nothing if only one is present
import Or
AndOr.Both ( 0, 1 ) |> AndOr.justOnBoth --> Just ( 0, 1 )
AndOr.Only (Or.First 0) |> AndOr.justOnBoth --> Nothing
AndOr.Only (Or.Second 1) |> AndOr.justOnBoth --> NothingPrefer a case..of if you handle both cases
Just if only one value is present, Nothing if both are present
import Or
AndOr.Both ( 0, 1 ) |> AndOr.justOnOnly --> Nothing
AndOr.Only (Or.First 0) |> AndOr.justOnOnly --> Just (Or.First 0)
AndOr.Only (Or.Second 1) |> AndOr.justOnOnly --> Just (Or.Second 1)
AndOr.Only (Or.Second 1)
|> AndOr.justOnOnly
|> Maybe.andThen Or.justOnSecond
--> Just 1Prefer a case..of if you handle both cases
Either both or only the first or second.
When (not) to use this? → readme