Skip to content

refactor: adopt alias __MODULE__ for struct references#67

Merged
nyo16 merged 1 commit into
masterfrom
refactor/alias-module-structs
Jul 4, 2026
Merged

refactor: adopt alias __MODULE__ for struct references#67
nyo16 merged 1 commit into
masterfrom
refactor/alias-module-structs

Conversation

@nyo16

@nyo16 nyo16 commented Jul 4, 2026

Copy link
Copy Markdown
Owner

Stacked on # — merge that first; this diff is the
single commit a97e8c8.

What

Adopts the alias __MODULE__ idiom for struct references across the library:
%__MODULE__{...} builds, pattern matches, update syntax, and @type t definitions
become the module's short name (%Message{}, %Context{}, …). 37 files, ~253 refs,
matching the existing exemplar in memory/store/hybrid.ex.

Several moduledocs already wrote examples with the short name (Registry.new(),
Agent.new(...)) — the alias makes those docs literally accurate.

Scope

  • Converted: struct references only
  • Untouched: process-identity uses (GenServer.start_link(__MODULE__, ...),
    :ets.new(__MODULE__, ...), @behaviour, callback-module arguments)
  • Excluded: errors/base.ex (refs inside quote do — macro hygiene),
    errors.ex (9 submodules × 1 ref — alias noise), four 1-ref files

Notes for review

  • Multi-module files got one alias per struct module: eval/result.ex
    (Result + SuiteResult) and eval/metrics.ex (Metrics + Metrics.Summary)
  • Stdlib-shadowing candidates (Registry, Agent, Node) were audited per file —
    no stdlib calls to those names exist in the converted files
  • skill.ex's two refs verified to sit outside its __using__ quote block

Verification

Zero behavior change — alias is compile-time lexical.

  • mix test: 1992 passed (7 doctests), 102 excluded — exact baseline match
  • mix compile --warnings-as-errors, mix format --check-formatted,
    mix credo --strict (0 issues), mix docs warning-free
  • Residual grep -rn "%__MODULE__{" lib shows only the 15 documented exclusion refs

@nyo16 nyo16 force-pushed the refactor/alias-module-structs branch from 00cd905 to 562dbda Compare July 4, 2026 18:37
Convert %__MODULE__{} builds, matches, updates, and @type t definitions
to the module's short name with alias __MODULE__ in scope, matching the
existing exemplar in memory/store/hybrid.ex. 37 files, ~253 refs.

Process-identity uses (GenServer.start_link(__MODULE__, ...), :ets,
@behaviour) are untouched, as are errors/base.ex and errors.ex (macro
hygiene / single-use noise) and four 1-ref files.

Multi-module files got one alias per struct module: eval/result.ex
(Result + SuiteResult) and eval/metrics.ex (Metrics + Metrics.Summary).

Zero behavior change: alias is compile-time. Full suite 1992 passed /
102 excluded (baseline match), credo --strict clean, docs warning-free.
@nyo16 nyo16 force-pushed the refactor/alias-module-structs branch from 562dbda to 66d0dfc Compare July 4, 2026 18:40
@nyo16 nyo16 merged commit 95cea7a into master Jul 4, 2026
6 checks passed
@nyo16 nyo16 deleted the refactor/alias-module-structs branch July 4, 2026 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant