View Source Babel.Step behaviour (Babel v1.2.0)
This module is meant to be used to create your own Babel
custom steps,
and is used internally to create all of Babel
's built-in steps.
It's required that any module which use
s Babel.Step
defines a struct.
What happens when I use Babel.Step
?
Your struct will:
- implement the
Babel.Step
behaviour (apply/2
) - implement the
Babel.Applicable
protocol, whose invocations delegate toapply/2
Inspect
If you'd like to customize the inspect/2
rendition of your custom Babel.Step
,
you can use Babel.Step, inspect: true
; this will implement the Inspect
protocol
and delegate all invocations to inspect/2
.
Summary
Types
@type result(output) :: output | {:ok, output} | :error | {:error, reason :: any()}
@type result_or_trace(output) :: result(output) | Babel.Trace.t(output)
An implementation of this behaviour.
An implementation of this behaviour whose apply/2
function produces the specified output.
@type t(_input, _output) :: any()
An implementation of this behaviour whose apply/2
function accepts the given input and produces the specified output.
Callbacks
@callback apply(t(output), Babel.Context.t()) :: result_or_trace(output) when output: any()
@callback inspect(t(), Inspect.Opts.t()) :: Inspect.Algebra.t()