partisan_otp_modules (partisan v6.3.0)

View Source

The OTP-to-Partisan module correspondence: the single source of truth for which OTP modules Partisan substitutes, and how.

Every consumer derives its view from substitutions/0 rather than restating the table:

  • partisan_otp_rewrite renames atoms, behaviour attributes and remote calls (atom_renames/0, call_renames/0).
  • partisan_gen_transform generates one beam per OTP module (otp_modules/0, partisan_module/1).
  • partisan_app and partisan_otp_test_gen load the generated set (partisan_modules/0).
  • priv/generate_otp_sources.escript writes the generated set into the modules key of partisan.app.src.

Origins

A row's origin says how its Partisan module comes to exist, and that is exactly what decides which syntactic positions the rewrite renames:

  • generated — partisan_gen_transform derives the module mechanically from the OTP module's abstract code. Every such name is also a behaviour name, so it occurs as a bare atom in data (child specs, {via, Mod, Name} tuples, logger report labels) as well as in calls and -behaviour attributes. All positions are renamed.
  • handwritten — Partisan ships its own module with a compatible API. Only remote calls are redirected. The atom keeps its OTP meaning in data positions, where renaming it would corrupt ordinary terms.

The two rename maps are therefore no longer independent tables that must be kept consistent by hand: call_renames/0 is by construction a superset of atom_renames/0.

Summary

Types

How a Partisan module comes to exist; see the module documentation.

One OTP-to-Partisan substitution.

Functions

Returns the renames applied to atoms in data positions, to -behaviour' attributes and to the-module' attribute.

Returns the renames applied to remote calls and remote fun references.

Returns the OTP modules `partisan_gen_transform' generates from, in generation order.

Returns the Partisan module that substitutes for OtpModule'. Errors with{badkey, OtpModule}' when the module has no substitution.

Returns the generated Partisan modules, in generation order.

Returns the substitution table, in generation order.

Types

origin()

-type origin() :: generated | handwritten.

How a Partisan module comes to exist; see the module documentation.

substitution()

-type substitution() :: {OtpModule :: module(), Partisan :: module(), origin()}.

One OTP-to-Partisan substitution.

Functions

atom_renames()

-spec atom_renames() -> #{module() => module()}.

Returns the renames applied to atoms in data positions, to -behaviour' attributes and to the-module' attribute.

Restricted to `generated' rows, whose names double as behaviour names.

call_renames()

-spec call_renames() -> #{module() => module()}.

Returns the renames applied to remote calls and remote fun references.

Covers every row: a handwritten substitute is reached by call even though its name must not be renamed as data.

otp_modules()

-spec otp_modules() -> [module()].

Returns the OTP modules `partisan_gen_transform' generates from, in generation order.

partisan_module(OtpModule)

-spec partisan_module(module()) -> module().

Returns the Partisan module that substitutes for OtpModule'. Errors with{badkey, OtpModule}' when the module has no substitution.

partisan_modules()

-spec partisan_modules() -> [module()].

Returns the generated Partisan modules, in generation order.

This is the set `partisan_app' requires to be loadable at application start.

substitutions()

-spec substitutions() -> [substitution()].

Returns the substitution table, in generation order.

Order is significant: partisan_gen_transform generates the generated rows top to bottom, and gen and proc_lib must exist before gen_server is generated.