Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/callumjhays/elm-unwrap
Dangerously unwrap value wrapper types in Elm
https://github.com/callumjhays/elm-unwrap
elm elm-lang helpers monads unwrap
Last synced: 26 days ago
JSON representation
Dangerously unwrap value wrapper types in Elm
- Host: GitHub
- URL: https://github.com/callumjhays/elm-unwrap
- Owner: CallumJHays
- License: mit
- Created: 2017-04-27T16:03:17.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-04-27T19:13:02.000Z (over 7 years ago)
- Last Synced: 2024-11-24T19:46:18.975Z (about 1 month ago)
- Topics: elm, elm-lang, helpers, monads, unwrap
- Language: Elm
- Homepage: http://package.elm-lang.org/packages/CallumJHays/elm-unwrap/latest
- Size: 4.88 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# `elm-unwrap`
This library provides quick functions for uunwrapping value wrapper
types such as Maybe and Result types. I have found myself rewriting this time
and time again, so I thought to separate it out into a package.Only use these if the program SHOULD crash in the case of the value not being
present.# Installation
```bash
elm package install CallumJHays/elm-unwrap
```# Functions
## `Unwrap.maybe : Maybe val -> val`
Forcibly unwraps a maybe. Crash the program when it is Nothing.
```elm
Unwrap.maybe (Just 42) == 42
Unwrap.maybe Nothing -- CRASHES
```## `Unwrap.result : Result err val -> val`
Forcibly unwraps a result. Crash the program when it is Err.
```elm
Unwrap.result (Ok 42) == 42
Unwrap.result (Err "Should never happen") -- CRASHES
```