This is an alternative site for discovering Elm packages. You may be looking for the official Elm package site instead.

Mom.Either

type alias Either a b = Mom (Result a b) b

A computation that may fail with additional information about the failure.

left : a -> Either a b

A failed computation.

right : b -> Either a b

A successful computation.

run : Either a b -> Result a b

Run the computation extracting the value to Result a b.

module Mom.Either exposing (..)

{-|
@docs Either
@docs left, right, run
-}

import Mom exposing (..)

{-|
A computation that may fail with additional information about the failure.
-}
type alias Either a b =
  Mom (Result a b) b

{-|
Run the computation extracting the value to `Result a b`.
-}
run : Either a b -> Result a b
run =
  with Ok

{-|
A failed computation.
-}
left : a -> Either a b
left a =
  Mom (\_ -> Err a)

{-|
A successful computation.
-}
right : b -> Either a b
right =
  pure