Module coers

coers provide small function for value coercion.

Copyright © 2016 X. Van de Woestyne

Version: 0.1.0

Authors: X. Van de Woestyne (xaviervdw@gmail.com).

Description

coers provide small function for value coercion.

Data Types

result()

result() = #result{succeeded = boolean(), value = term()}

Function Index

fail/1determine if a coercion is a failure.
fmap/2Apply and wrap a function to a result.
is_ascii_char/1determine if an integer is a potential Ascii Char.
map/2Apply a function to a result.
maybe_string/1check if a list is maybe a string.
new/2Create a new result.
of_string/1an ugly and magic coercion from string to term().
of_string/2try coercion or define a default value the suceeded flag is preserved.
succeed/1determine if a coercion is a success.
to_atom/1try to coerce a term to an atom.
to_atom/2try coercion or define a default value the suceeded flag is preserved.
to_bool/1try to coerce a term to a boolean.
to_bool/2try coercion or define a default value the suceeded flag is preserved.
to_float/1try to coerce a term to a float.
to_float/2try coercion or define a default value the suceeded flag is preserved.
to_int/1try to coerce a term to an integer.
to_int/2try coercion or define a default value the suceeded flag is preserved.
to_string/1try to coerce term into string.
to_string/2Replace value if coercion failed the suceeded flag is preserved.
traverse/1Unabstract result as a tuple.
unless/2Replace value if coercion failed the suceeded flag is preserved.
value/1extract the value of a wrapped result.

Function Details

fail/1

fail(Coercion::result()) -> boolean()

determine if a coercion is a failure

fmap/2

fmap(F::function(), Result::result()) -> result()

Apply and wrap a function to a result

is_ascii_char/1

is_ascii_char(X::integer()) -> boolean()

determine if an integer is a potential Ascii Char

map/2

map(F::function(), Result::result()) -> term()

Apply a function to a result

maybe_string/1

maybe_string(List::list()) -> boolean()

check if a list is maybe a string

new/2

new(Flag::boolean(), Value::term()) -> result()

Create a new result

of_string/1

of_string(String::string()) -> result()

an ugly and magic coercion from string to term()

of_string/2

of_string(Str::string(), Default::term()) -> result()

try coercion or define a default value the suceeded flag is preserved

succeed/1

succeed(Coercion::result()) -> boolean()

determine if a coercion is a success

to_atom/1

to_atom(Obj::term()) -> result()

try to coerce a term to an atom

to_atom/2

to_atom(Term::term(), Default::term()) -> result()

try coercion or define a default value the suceeded flag is preserved

to_bool/1

to_bool(Obj::term()) -> boolean()

try to coerce a term to a boolean

to_bool/2

to_bool(Term::term(), Default::term()) -> result()

try coercion or define a default value the suceeded flag is preserved

to_float/1

to_float(Obj::term()) -> result()

try to coerce a term to a float

to_float/2

to_float(Term::term(), Default::term()) -> result()

try coercion or define a default value the suceeded flag is preserved

to_int/1

to_int(Obj::term()) -> result()

try to coerce a term to an integer

to_int/2

to_int(Term::term(), Default::term()) -> result()

try coercion or define a default value the suceeded flag is preserved

to_string/1

to_string(Term::any()) -> string()

try to coerce term into string

to_string/2

to_string(Term::term(), Default::term()) -> result()

Replace value if coercion failed the suceeded flag is preserved

traverse/1

traverse(Result::result()) -> {boolean(), term()}

Unabstract result as a tuple

unless/2

unless(Result::result(), Default::term()) -> result()

Replace value if coercion failed the suceeded flag is preserved

value/1

value(Coercion::result()) -> term()

extract the value of a wrapped result


Generated by EDoc, Jan 21 2017, 17:00:08.