Transforming Data

Applications need to actually do things to be useful. The essence of creating that behavior in functional programming is transforming data. This whole next section will be about just that—defining functions that transform the data structures we’ve defined.

Elixir gives us the pipeline operator |>, which allows us to elegantly take the output of a function and give it to another function as its first argument. It’s tailor-made for the kind of work we’ll be doing, and it’s very idiomatic in Elixir.

We can think of pipelines as chaining functions together vertically. We can also chain them horizontally—functions calling functions either in the same module or across modules.

We’ll use both approaches to take complex work, break ...

Get Functional Web Development with Elixir, OTP, and Phoenix now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.