The pipe operator (|>) composes function calls by passing one expression’s result to the next call as its first argument. It replaces temporary variables and deeply nested calls with a left-to-right sequence that reads like a data transformation. section 1.2.2 section 2.3.2
Use the operator to make function flow visible:
- Write `prev(arg1, arg2) |> next(arg3, arg4)` instead of `next(prev(arg1, arg2), arg3, arg4)`. section 2.3.2
- Lay multiline pipelines out from top to bottom; in IEx, each complete pipeline line evaluates and displays its intermediate result. section 2.3.2
- Understand the abstraction as compile-time transformation: the pipeline becomes the equivalent nested, or staircased, calls. section 1.2.2
Transform and print a value
The pipeline `-5 |> abs() |> Integer.to_string() |> IO.puts()` computes the absolute value, converts it to a string, and prints it. Its nested equivalent is `IO.puts(Integer.to_string(abs(-5)))`. section 2.3.2
def process_xml(model, xml) do model |> update(xml) |> process_changes() |> persist() end
A small Elixir pipeline shows the idiom in a production-shaped transformation: update a model, process its changes, then persist it. section 1.2.2





