Package

purescript-result

Repository
adius/purescript-result
License
MIT
Uploaded by
adius
Published on
2018-01-13T22:27:04Z

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 doc.rust-lang.org/book
Rust Result<T, E> Ok Err package.elm-lang.org
OCaml ('a, 'b) result Ok Error ocaml.org/learn
F# Result<'T,'TError> Ok Error docs.microsoft.com

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)

Installation

bower install --save purescript-result

Documentation

Module documentation is published on Pursuit.