MutagenEx.Mutators.Pipeline (mutagen_ex v0.2.0)

Copy Markdown View Source

Reorders two adjacent |> segments.

Per mutagen.mutators catalog entry 7.

AST shape

a |> b() |> c() parses left-associative:

{:|>, _, [{:|>, _, [a, b_call]}, c_call]}

We rewrite the outer pipe so that a |> b() |> c() becomes a |> c() |> b() — i.e. swap the two pipe stages while keeping the initial value a.

Validation

  • :structurally_invalid — match?/1 already rules out single-stage pipelines and non-pipe nodes; if validate/1 somehow sees one it skips.
  • :no_op_shadowed — when the two function call segments are textually identical (a |> f() |> f()) the reorder is a no-op. Detected by structural equality of the normalised AST of the two call segments.

Reorder symmetry: applying mutate/1 twice on a two-stage pipe restores the original. The property test exercises this for two-stage pipes.