Tuple Calls

We both agree on it making more sense for piping to work on the last argument because of currying (and this would make quite a few functional patterns, such as applying applicative functors, a lot easier to express in Elixir!). However, this is a choice that cannot be altered anymore as it is deeply ingrained into the language.

The difference between tuple calls and piping, and why I call this ‘OOP-style’ is that you are dispatching functions based on the data type you happen to have at hand:

my_data_type
|> MyOneModule.bar(extra_argument)
|> MyOtherModule.baz()

Here, it is clear what code is called.

my_data_type
.bar(extra_argument)
.baz()

Here, which bar/2 is called depends on what my_data_type actually is bound to. Furthermore, which baz/1 is called depends on what this bar/2 returns. This is the kind of implicitness inherent in OOP programs because in objects, code and data lives together, and exactly what we try to avoid in functional programming.

6 Likes