Safe Haskell | Safe |
---|---|

Language | Haskell2010 |

Universal result type for calculations that may either: produce a value, signal the failure to obtain value, or signal that value is "not interesting".

- data Outcome a
- describe :: (a -> String) -> Outcome a -> String
- toEither :: Outcome a -> Either String a
- fromEither :: Either String a -> Outcome a
- fromMaybe :: String -> Maybe a -> Outcome a
- allOK :: [Outcome a] -> Outcome [a]
- exposeOrDie :: Outcome a -> a
- type OutcomeM a b = Deep a Outcome b
- type OutcomeIO a = OutcomeM IO a
- describeAndPrint :: (a -> String) -> OutcomeIO a -> IO ()

# Documentation

Universal result type for calculations that may either: produce a value, signal the failure to obtain value, or signal that value is "not interesting".

E.g. a text parser distinguishes situations when text file is
"structured enough" to have a syntax error (that's `Fail`

)
and when text file is not in a supported format at all
(that's `Skip`

).

toEither :: Outcome a -> Either String a Source #

Converts `Outcome`

into either wrapped value or error message.

fromEither :: Either String a -> Outcome a Source #

Converts `Either ErrorMessage Value` to `Outcome Value`

fromMaybe :: String -> Maybe a -> Outcome a Source #

Converts `Maybe Value` to `Outcome Value` using provided error
message to designate `Fail`

.

exposeOrDie :: Outcome a -> a Source #

Either returns a wrapped value or prints out an error message
and terminates the execution with `error`

.