Skip to content

Pointfree

Compare
Choose a tag to compare
@expede expede released this 12 Sep 07:00

Pointfree unary functions!

Allows defining functions as straight function composition (ie: no need to state the argument). Provides a clean, composable named functions. Also doubles as an aliasing device.

defmodule Foo do
  use Quark
  defx foo, do: Enum.sum |> succ
  defx bar, do: ((&Enum.sum/1) <~> succ).()
end

[1,2,3] |> Foo.foo
#=> 7

[1,2,3] |> Foo.bar
#=> 7

Pointfree n-ary functions (based on the first function in the body) is still coming 😄