Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

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
```