monex v0.1.5 MonEx

A collection of simple monadic types: Option, Result.

Summary

Functions

Applies function returning to content of monadic type

Calls supplied function with content of monadic type as an argument, returns argument intact

Applies function to content of monadic type

Types

monadic()

Functions

flat_map(arg, f)
flat_map(monadic, (term -> monadic)) :: monadic

Applies function returning to content of monadic type:

Example: inverse = fn (x) -> if x == 0, do: none(), else: some(1/x) end some(5) |> flat_map(f) == some(1/5) some(0) |> flat_map(f) == none()

foreach(res, f)
foreach(monadic, (term -> no_return)) :: monadic

Calls supplied function with content of monadic type as an argument, returns argument intact

map(arg, f)
map(monadic, (term -> term)) :: monadic

Applies function to content of monadic type:

Example: f = fn (x) -> x * 2 end some(5) |> map(f) == some(10) none() |> map(f) == none()