mix credence.ast (credence v0.8.0)

Copy Markdown

Print the Sourceror.parse_string!/1 AST of a code snippet — the exact tree a Pattern rule's check/2 pattern-matches against — in two views:

mix credence.ast path/to/snippet.exs      # from a file
echo 'Enum.map(x, & &1)' | mix credence.ast  # from stdin
  1. Rawinspect(ast, pretty: true, limit: :infinity), INCLUDING the {:__block__, _, [literal]} wrappers around literals, which a rule's check/2 must match. This is the ground truth.
  2. Layout-stripped — the same tree with :line/:column/:closing/:last/:end meta dropped, for readability.

This is an exploration-killer for rule authors (and Tunex's implementer seed): it hands you the tuple shape instead of making you guess it in iex.

NOTE: it deliberately does not print the normalize_sourceror_ast/unwrapped form — that unwraps the __block__ literal wrappers (it exists for test-time AST-equivalence) and would teach the wrong shape to match.