docs - 0.0.0

Stdlib.Data.Result.Base

Definitions

type Result E ASource#

The Result type represents either a success with a value of `ok` or an error with value `error`.

Constructors

| error E
| ok A

handleResult {E A B} (onError : E -> B) (onOk : A -> B) : Result E A -> BSource#

Apply the onError function if the value is error or apply the onOk function if the value is ok.

mapError {A E1 E2} (f : E1 -> E2) : Result E1 A -> Result E2 ASource#

Apply a function to the error value of a Result.

mapOk {E A C} (f : A -> C) : Result E A -> Result E CSource#

Apply a function to the ok value of a Result.

isError {E A} : Result E A -> BoolSource#

Return true if the value is an error, otherwise false.

isOk {E A} : Result E A -> BoolSource#

Return true if the value is ok, otherwise false.

fromError {E A} (default : E) : Result E A -> ESource#

Return the contents of an error value, otherwise return a default.

fromOk {E A} (default : A) : Result E A -> ASource#

Return the contents of an ok value, otherwise return a default.

resultToMaybe {E A} : Result E A -> Maybe ASource#

Convert a Result to a Maybe. An error value becomes `nothing`.

maybeToResult {E A} (defaultError : E) : Maybe A -> Result E ASource#

Convert a Maybe to a Result. A nothing value becomes `error defaultError`.