An outcome is a type which borrows concepts from both Elm Maybe and Result
If the outcome is Valid return the value. If the outcome is a None then
return a given default value. If the outcome is a Warning then propagate this warning.
Apply a function to an outcome. If the result is Valid, it will be converted.
If the outcome is a Warning or None, the same value will propagate through.
map sqrt (Valid 4.0) == Valid 2.0
Apply a function to two outcomes, if both outcome are Valid. If not,
a valid outcome and a None will propagate None, a Warning will always propagate.
Two warnings will be merged
Like the boolean '||' this will return the first value that is positive ('Valid').
or None (Valid "str") -- Valid "str"Convert a maybe to an outcome
fromMaybe (Just "str") -- Valid "str"
fromMaybe Nothing -- NoneConvert an outcome to a maybe
toMaybe (Valid "str") -- Just "str"
toMaybe None -- NothingCheck that a valid outcome verifies the criteria otherwise raise a warning
check String.isEmpty "should not be empty string" (Valid "some text") -- Valid "some text"
check String.isEmpty "should not be empty string" (Valid "") -- Warning "should not be empty string"Check that a valid outcome verifies the criteria otherwise return none
checkOrNone String.isEmpty (Valid "some text") -- Valid "some text"
checkOrNone String.isEmpty (Valid "") -- NoneAn outcome with a true value will produce a constant outcome
trueMapToConstant [ "alpha" ] (Valid True) -- Valid ["alpha"]
trueMapToConstant [ "alpha" ] (Valid False) -- None
Representation of an outcome which can be: