CallumJHays / elm-unwrap

Dangerously unwrap value wrapper types in Elm

Home Page:http://package.elm-lang.org/packages/CallumJHays/elm-unwrap/latest

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

elm package install CallumJHays/elm-unwrap

Functions

Unwrap.maybe : Maybe val -> val

Forcibly unwraps a maybe. Crash the program when it is Nothing.

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.

Unwrap.result (Ok 42) == 42
Unwrap.result (Err "Should never happen") -- CRASHES

About

Dangerously unwrap value wrapper types in Elm

http://package.elm-lang.org/packages/CallumJHays/elm-unwrap/latest

License:MIT License


Languages

Language:Elm 100.0%