plymio_fontais v0.2.0 Plymio.Fontais View Source

Plymio.Fontais is a foundation / support package for the Plymio and Harnais package families.

Documentation Terms

In the documentation these terms, usually in italics, are used to mean the same thing (e.g. opts).

opts and opzioni

opts is a Keyword list. An opzioni is a list of opts.

form and forms

A form is an quoted form (ast). A forms is a list of zero, one or more forms.

result and results

A result is either {:ok, any} or {:error, error} where error is an Exception.

A results is an enumerable of result e.g. a List or Stream.

Standard Processing and Result Patterns

Many functions return either {:ok, value} or {:error, error} where error will be an Exception.

Peer bang functions return either the value or raises the error.

There are three common function patterns:

pattern 0

A pattern 0 function always returns either {:ok, any} or {:error, error}.

If the function’s processing (e.g. after calling other functions) does not produce either {:ok, value} or {:error, error}, a new {:error, error} will be created and returned.

A pattern 0 function is pessimistic i.e it assumes the value is invalid, and an error has occured.

pattern 1

A pattern 1 function always returns either {:ok, any} or {:error, error}.

If the function’s processing (e.g. after calling other functions) produces a value that is neither {:ok, any} nor {:error, error}, the value is converted into {:ok, value} and returned.

A pattern 1 function is optimistic i.e it assumes the value is valid.

pattern 2

A pattern 2 function always returns either {:ok, any}, {:error, error}, nil or the unset value.

See below for an explanation of the unset value.

A pattern 2 function works like pattern 1 other than if the value is nil or the unset value (see below), it is returned unchanged.

The Unset Value

In many situations it is useful to know whether a var has been set explicity but its value can be validly nil.

For example the default default value for a struct field is nil. But there is no way to determine whether the field has been set to nil or has never been set at all.

The Unset Value is an arbitrary, randomish atom that can be used where nil can not e.g. as the default value for a field in a struct.

See Plymio.Fontais.Guard.the_unset_value/0.

Link to this section Summary

Link to this section Types

Link to this type alias_key() View Source
alias_key() :: key()
Link to this type alias_keys() View Source
alias_keys() :: keys()
Link to this type alias_value() View Source
alias_value() :: nil | alias_keys()
Link to this type aliases_dict() View Source
aliases_dict() :: %{optional(alias_key()) => alias_key()}
Link to this type aliases_kvs() View Source
aliases_kvs() :: [{alias_key(), alias_value()}]
Link to this type aliases_tuples() View Source
aliases_tuples() :: [{alias_key(), alias_key()}]
Link to this type dict() View Source
dict() :: %{optional(alias_key()) => any()}
Link to this type fun1_map() View Source
fun1_map() :: (any() -> any())
Link to this type keys() View Source
keys() :: key() | [key()]
Link to this type opzioni() View Source
opzioni() :: [opts()]
Link to this type product() View Source
product() :: [kv()]
Link to this type result() View Source
result() :: {:ok, any()} | {:error, error()}
Link to this type results() View Source
results() :: [result()]

Link to this section Functions

Link to this function is_value_set(value) View Source
is_value_set(any()) :: boolean()

Delegated to Plymio.Fontais.Guard.is_value_set/1

Link to this function is_value_unset(value) View Source
is_value_unset(any()) :: boolean()

Delegated to Plymio.Fontais.Guard.is_value_unset/1

Link to this function is_value_unset_or_nil(value) View Source
is_value_unset_or_nil(any()) :: boolean()

Delegated to Plymio.Fontais.Guard.is_value_unset_or_nil/1

Link to this function the_unset_value() View Source
the_unset_value() :: atom()

Delegated to Plymio.Fontais.Guard.the_unset_value/0