Module forms

Data Types

form()

form() = erl_parse:abstract_form()

forms()

forms() = [form()]

mapf()

mapf() = fun((form()) -> any())

mrf()

mrf() = fun((form(), any()) -> {any(), any()})

opt()

opt() = forms_only

opts()

opts() = [opt()]

predicate()

predicate() = fun((form()) -> boolean())

redf()

redf() = fun((form(), any()) -> any())

Function Index

all/2 Check if all forms meet the provided predicate.
any/2 Check if there is any form meeting the provided predicate.
cons_to_list/1 Convert a cons (abstract representation of a list) into a list.
eval/1 Evaluate the provided String expression or abstract form.
filter/2 Filter out all forms not meeting the provided predicate.
from_abstract/1 Turn the provided abstract form into an Erlang representation.
list_to_cons/1 Convert a list into a cons (abstract representation of a list).
map/2 Calls the provided fun/1 on all given forms, including nested forms.
map/3
mr/3 Combines the operations of map/2 and reduce/3 into one pass.
quote/1 Quote a form so that it can, for instance, be bound to a variable when manipulating Erlang's abstract code.
read/1 Read the Erlang abstract forms from the specified source file or binary compiled using the -debug_info compile option.
reduce/3 Calls the provided fun/2 on all given forms, including nested forms.
reduce/4
to_abstract/1 Turn the provided Erlang attribute or expression into its abstract format representation.
unquote/1 Inverse of the quote/1 function.

Function Details

all/2

all(Pred::predicate(), Fs::forms()) -> boolean()

Check if all forms meet the provided predicate.

any/2

any(Pred::predicate(), Fs::forms()) -> boolean()

Check if there is any form meeting the provided predicate.

cons_to_list/1

cons_to_list(Cons::form()) -> list()

Convert a cons (abstract representation of a list) into a list

eval/1

eval(Expr::string() | form()) -> term()

Evaluate the provided String expression or abstract form.

filter/2

filter(Fun::predicate(), Forms::forms()) -> forms()

Filter out all forms not meeting the provided predicate.

from_abstract/1

from_abstract(Forms::form()) -> string()

Turn the provided abstract form into an Erlang representation.

list_to_cons/1

list_to_cons(Tail::list()) -> form()

Convert a list into a cons (abstract representation of a list)

map/2

map(Fun::mapf(), Forms::forms()) -> forms()

Calls the provided fun/1 on all given forms, including nested forms. The original forms are replaced by the resulting Erlang term after applying the provided fun/1 on them.

map/3

map(Fun::mapf(), Forms::forms(), Opts::opts()) -> forms()

mr/3

mr(Fun::mrf(), Acc::any(), Fs::forms()) -> {any(), any()}

Combines the operations of map/2 and reduce/3 into one pass.

quote/1

quote(Term) -> any()

Quote a form so that it can, for instance, be bound to a variable when manipulating Erlang's abstract code.

The following abstract code is not valid code
  {match, 1, {var, 1, 'A'},
             {function, 1, foo, 0,
              [
               {clause, 0, [], [], [{atom, 1, foo}]}
              ]}}

because, in Erlang code, it would be equivalent to

  A = foo() -> foo.

which is, obviously, no valid Erlang code. However, one could quote the right-hand side of the above match operation so that it becomes a valid Erlang expression.

One could consider that an expression similar to the one below

  {match, 1, {var, 1, 'A'},
             forms:quote(
                 {function, 1, foo, 0,
                  [
                   {clause, 0, [], [], [{atom, 1, foo}]}
                  ]})}

becomes something like

  A = <<...>>.

read/1

read(Module::atom() | iolist()) -> forms()

Read the Erlang abstract forms from the specified source file or binary compiled using the -debug_info compile option.

reduce/3

reduce(Fun::redf(), Acc::any(), Forms::forms()) -> any()

Calls the provided fun/2 on all given forms, including nested forms. fun/2 must return a new accumulator which is passed to the next call.

reduce/4

reduce(Fun::redf(), Acc::any(), Forms::forms(), Opts::opts()) -> any()

to_abstract/1

to_abstract(String::string()) -> form()

Turn the provided Erlang attribute or expression into its abstract format representation.

unquote/1

unquote(Binary) -> any()

Inverse of the quote/1 function. Takes a quoted form and returns its original form.


Generated by EDoc