Point Free?

I suspect it isn’t possible, but it seems that it’s almost possible with partial application & pipes etc.

Perhaps just a simple macro away. Any thoughts?


For who does not know what @mmport80 is talking about: Point-Free, Point-Less or Tacit programming means that you combine (partially apply) functions without explicitly stating the arguments they are going to take.

In Elixir, this is going to be hard because Elixir does not perform partial application of its functions. There are some libraries (such as Currying, which I wrote) that allow you to do partial application, but the end result isn’t very pretty. First and foremost, Elixir’s convention for functions is to put the most ‘important’ (most often changed) argument as its first argument, which is also what the pipe operator |> works with. This makes it less useful to perform currying, as we might instead want to curry ‘backwards’ (fill in the less often changing arguments). It will also probably be slower because closures are added for the intermediate application steps which are not optimized away when compiled to bytecode (which is what a language like e.g. Haskell would do).

I also think that Tacit programming in general goes somewhat against the Explicitness that is the convention most Elixir programmers, guides, and the current standard library advocate.


Adding to Qqwy’s reply, here’s a couple of projects that might be an alternative for tacit programming in Elixir:
expede’s Quark and Rex (my still work in progress concatenative elixir)


The question is why is this even important to you?

Whenever stuff like this crops up I feel compelled to point people to Beyond Functional Programming with Elixir and Erlang which I summarize as: “In Elixir and Erlang functional programming is a means to an end - not an end in itself”.

To me point free style is simply a manifestation of “function composition” becoming a commonly employed tool in your development toolbox. Elixir is perfectly capable of supporting programming by “function composition” as partial application and higher order functions are well supported but whether the point free style is supported or not, the ultimate responsibility for designing your functions so that they can be easily composed still lies with you as the developer.


Yup I agree - but I suspect I mostly agree because I suspect I haven’t explored point free fully yet ; )

But yup, a nice long pipe seems to give you much of what point free gives you, with not that much extra syntactical noise…

1 Like

Functions conducive to pipelining are idiomatic in Elixir but there are quick and dirty ways of supporting function composition through support functions as well.

defmodule Test do
  # function typically pipelined over p1
  def fp(p1,p2,p3,p4) do
    p1 + p2 + p3 + p4

  # return function to be composed over p1
  def fc(p2,p3,p4) do
    fn (p1) -> fp(p1,p2,p3,p4) end

g = Test.fc(2,3,4)

IO.inspect g.(1)
1 Like