Computations that may succeed or fail.

purescript, result
psc-package install result


PureScript Result

Latest release Build status

The Result type is used to represent computations that may succeed or fail.

This should be used instead of the more genereic Either.

Many other functional programming languages also support Result types:

Language Type Name Success Error Documentation
Elm Result error value Ok Err
Rust Result<T, E> Ok Err
OCaml ('a, 'b) result Ok Error
F# Result<'T,'TError> Ok Error

I'm not a fan of useless abbreviations (as if 3 instead of 5 characters would make a difference) but a fan of readability and pronounceability of code (e.g. dictating your coworker a snippet of code) and therefore this package uses:

data Result error value = Error error | Ok value

Because how typeclasses work in PureScript it must be Result error value and not Result value error, so that the value can be maped. (details)


bower install --save purescript-result


Module documentation is published on Pursuit.