monex v0.1.3 MonEx.Option

Option module provides Option type with utility functions.

Summary

Types

t()

Option type. some(x) or none() unwraps into {:some, x} or {:none}

Functions

Returns content of option if argument is some(), raises otherwise

Returns content of option if argument is some(), second argument otherwise

Returns true if argument is none() false if some()

Returns true if argument is some() false if none()

Converts arbitrary term into option, some(term) if not nil, none() otherwise

Types

t()
t() :: {:some, term} | {:none}

Option type. some(x) or none() unwraps into {:some, x} or {:none}

Functions

get(arg)
get(t) :: term

Returns content of option if argument is some(), raises otherwise

get_or_else(arg, z)
get_or_else(t, term) :: term

Returns content of option if argument is some(), second argument otherwise

is_none(x)
is_none(t) :: boolean

Returns true if argument is none() false if some()

is_some(arg)
is_some(t) :: boolean

Returns true if argument is some() false if none()

to_option(x)
to_option(term) :: t

Converts arbitrary term into option, some(term) if not nil, none() otherwise

Macros

none()
some(val)