Search documentation of Metastatic

# Metastatic.Adapters.Elixir.FromMeta (Metastatic v0.2.0)

View Source

Transform MetaAST (M2) back to Elixir AST (M1).

This module implements the reification function ρ_Elixir that instantiates meta-level representations back into Elixir-specific AST structures.

## Transformation Strategy

The transformation reverses the abstraction performed by `ToMeta`, using metadata to restore M1-specific information when needed.

## Round-Trip Fidelity

The transformation aims for high fidelity:

- Metadata preserves line numbers, contexts, and formatting hints
- Variable contexts are restored from metadata
- Special forms are reconstructed from metadata markers

## Default Values

When metadata is absent or incomplete:

- Line number defaults to 0
- Variable context defaults to `Elixir`
- Empty metadata keyword list `[]` is used

# Summary

## Functions

transform(unknown, metadata)

Transform MetaAST back to Elixir AST.

# Functions

# transform(unknown, metadata)

    @spec transform(term(), map()) :: {:ok, term()} | {:error, String.t()}

Transform MetaAST back to Elixir AST.

Returns `{:ok, elixir_ast}` on success or `{:error, reason}` on failure.

## Examples

    iex> transform({:literal, :integer, 42}, %{})
    {:ok, 42}

    iex> transform({:variable, "x"}, %{context: Elixir})
    {:ok, {:x, [], Elixir}}

    iex> transform({:binary_op, :arithmetic, :+, {:variable, "x"}, {:literal, :integer, 5}}, %{})
    {:ok, {:+, [], [{:x, [], Elixir}, 5]}}