View Source Matcha.Source (Matcha v0.1.10)
Functions that work with the raw Erlang terms representing a match spec.
The "source" of a match specification is what Matcha calls data that fits the Erlang match specification grammar.
Matcha compiles Elixir code into such data, and wraps that data in structs. This module is the bridge between those structs and the Erlang functions that know how to operate on them.
Link to this section Summary
Functions
Compiles match spec source
into an opaque, more efficient internal representation.
Checks if provided value
is a compiled match spec source.
Ensures provided match spec source
is compiled.
Runs a match spec source
against a list of values.
Validates match spec source
of variant type
and tries to match it against match_target
.
Link to this section Types
@type all_matches() :: :"$$"
@type body() :: [expression()]
@type clause() :: {pattern(), conditions(), body()}
@type compiled() :: :ets.comp_match_spec()
@type condition() :: tuple()
@type conditions() :: [condition()]
@type expression() :: atom() | match_all() | all_matches() | tuple() | term()
@type match_all() :: :"$_"
@type match_result() :: {:ok, any(), trace_flags(), [{:error | :warning, charlist()}]} | {:error, [{:error | :warning, charlist()}]}
@type spec() :: [clause()]
@type trace_flags() :: list()
@type trace_match_result() :: {:ok, boolean() | trace_message(), trace_flags(), [{:error | :warning, charlist()}]} | {:error, [{:error | :warning, charlist()}]}
@type trace_message() :: charlist()
@type type() :: :table | :trace
@type uncompiled() :: spec()
Link to this section Functions
@spec compile(source :: uncompiled()) :: compiled()
Compiles match spec source
into an opaque, more efficient internal representation.
Checks if provided value
is a compiled match spec source.
@spec ensure_compiled(source :: uncompiled() | compiled()) :: compiled()
Ensures provided match spec source
is compiled.
@spec run(source :: uncompiled() | compiled(), list()) :: list()
Runs a match spec source
against a list of values.
@spec test(source :: uncompiled(), type(), match_target()) :: match_result()
Validates match spec source
of variant type
and tries to match it against match_target
.