https://github.com/ad-si/purescript-result
Computations that may succeed or fail.
https://github.com/ad-si/purescript-result
purescript result
Last synced: 4 months ago
JSON representation
Computations that may succeed or fail.
- Host: GitHub
- URL: https://github.com/ad-si/purescript-result
- Owner: ad-si
- License: mit
- Created: 2018-01-13T21:48:49.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-01-02T17:34:37.000Z (almost 2 years ago)
- Last Synced: 2025-03-10T16:05:15.865Z (7 months ago)
- Topics: purescript, result
- Language: PureScript
- Size: 119 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PureScript Result
[
](https://github.com/ad-si/purescript-result/releases)
[
](https://travis-ci.org/ad-si/purescript-result)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 | [package.elm-lang.org][elm]
Rust | `Result` | Ok | Err | [doc.rust-lang.org/book][rust]
OCaml | `('a, 'b) result` | Ok | Error | [ocaml.org/learn][ocaml]
F# | `Result<'T,'TError>` | Ok | Error | [docs.microsoft.com][fsharp][rust]: https://doc.rust-lang.org/book/ch09-02-recoverable-errors-with-result.html
[elm]: https://package.elm-lang.org/packages/elm/core/latest/Result
[ocaml]: https://ocaml.org/docs/error-handling#using-the-result-type-for-errors
[fsharp]: https://learn.microsoft.com/en-us/dotnet/fsharp/language-reference/resultsI'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:```purescript
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 `map`ed.
([details])[details]: https://github.com/purescript/purescript/issues/3202#issuecomment-357465332
## Installation
```
bower install --save purescript-result
```## Documentation
Module documentation is [published on Pursuit].
[published on Pursuit]: http://pursuit.purescript.org/packages/purescript-result
## Development
Deployment of new version:
```sh
npx pulp test
npx pulp version
npx pulp publish
```