stdlib - 0.0.1

Stdlib.Data.Result.Base

Definitions

type Result Error ValueSource#

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

Constructors

| error Error
| ok Value

handleResult {Error Value1 Value2} (onError : Error -> Value2) (onOk : Value1 -> Value2) (result : Result Error Value1) : Value2Source#

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

mapError {Value Error1 Error2} (f : Error1 -> Error2) (result : Result Error1 Value) : Result Error2 ValueSource#

Apply a function f to the error value of a Result.

mapOk {Error Value1 Value2} (f : Value1 -> Value2) (result : Result Error Value1) : Result Error Value2Source#

Apply a function f to the ok value of a Result.

isError {Error Value} (result : Result Error Value) : BoolSource#

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

isOk {Error Value} (result : Result Error Value) : BoolSource#

Return true if the value is ok, otherwise false.

fromError {Error Value} (defaultError : Error) (result : Result Error Value) : ErrorSource#

Return the contents of an error value, otherwise return defaultError.

fromOk {Error Value} (defaultValue : Value) (result : Result Error Value) : ValueSource#

Return the contents of an ok value, otherwise return defaultValue.

resultToMaybe {Error Value} (result : Result Error Value) : Maybe ValueSource#

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

maybeToResult {Error Value} (defaultError : Error) (maybeValue : Maybe Value) : Result Error ValueSource#

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