Sometimes things take a little longer to write as you have to be slightly more verbose, but it's so much quicker to understand when coming back to it.
The pipe operator |> that you mention is great example because it does something in OO that is typically done using a 'fluent interface'[0] often used in 'Builder' classes (i.e., the class methods return the object so that it can be chained together). The great thing about the pipe operator is that it's much more simple and flexible, it simply passes the result of the prior function as the first argument to the second. This means, unlike with a fluent API, you can pipe together functions from completely different modules:
:crypto.hash(:md5, some_binary)
|> :base64.encode_to_string()
Elixir also has protocols[1], which allow a function to be used across a variety of types (similar to obj-c/Swift). Which again is more flexible, as the functionality can extend a 'class' that you don't control.Elixir also has behaviors[2], which just guarantee that a module contains a number of functions, something akin to interfaces Java.
Dialyzer can take advantage of behaviors and protocols to enforce typing constraints.
[0] https://en.wikipedia.org/wiki/Fluent_interface [1] https://hexdocs.pm/elixir/1.12/Protocol.html [2] https://hexdocs.pm/elixir/1.12/Behaviour.html
x, err := computeAThing(1, 1)
y, err := and_then.Int(err, makeComputeAThingFn(x, 1))
z, err := and_then.Int(err, makeComputeAthingFn(x, y))
another, err := and_then.AnotherType(err, makeComputeAnotherTypeFn(z))
where makeComputeAThingFn(...) returns a function with the body `return computeAThing(...)`. `err` will end up with the first non-nil error and the following and_then.X's will be no-ops.I learned F# in a ~year, and then found a Clojure job. I _never_ want to go back to OO.
Yes, I do enjoy FP on the long run, not only to write it but more importantly to maintain it (much easier in my opinion, including refactoring & tech debt reduction).
I still use OO too (e.g. with Ruby), but my Ruby style has gotten more FP-oriented as a result (e.g. ETL components which looks a lot like Elixir modules).