spectra_transform (spectra v0.13.0)

View Source

Summary

Functions

Parse transform that injects __spectra_type_info__/0 into the module being compiled. Opt in per module with -compile({parse_transform, spectra_transform})..

Types

forms()

-type forms() :: [erl_parse:abstract_form() | erl_parse:form_info()].

Functions

parse_transform(Forms, Opts)

-spec parse_transform(forms(), list()) -> forms().

Parse transform that injects __spectra_type_info__/0 into the module being compiled. Opt in per module with -compile({parse_transform, spectra_transform})..

The generated function returns the same spectra:type_info() value that spectra_abstract_code:types_in_module/1 would produce at runtime, but without requiring the BEAM to carry abstract_code debug info.

The export attribute, spec and function body are injected independently so that hand-written pieces of __spectra_type_info__/0 are always preserved: if the function body is already defined (plus an -export or -compile(export_all)), the forms are returned unchanged; otherwise only the missing pieces are added.