stoatpower / elm-exts / Exts.Result

Extensions to the core Result library.

mapBoth : (e -> f) -> (a -> b) -> Result e a -> Result f b

Apply functions to both sides of a Result, transforming the error and ok types.

isOk : Result e a -> Basics.Bool

Boolean checks for success/failure.

isErr : Result e a -> Basics.Bool

fromOk : Result e a -> Maybe a

Convert a Result to a Maybe.

fromErr : Result e a -> Maybe e

mappend : Result e a -> Result e b -> Result e ( a, b )

Monoidal append - join two Results together as though they were one.

either : (e -> c) -> (a -> c) -> Result e a -> c

Collapse a Result down to a single value of a single type.

Example:

  case result of
    Err err -> errorView err
    Ok value -> okView value

...is equivalent to:

  either errorView okView result