Quark.Partial (Quark v2.3.2) View Source

Provide curried functions, that can also be partially bound without dot notation. Partially applying a function will always return a fully-curried function.

Please note that these will use all of the arities up to the defined function.

For instance:

defpartial foo(a, b, c), do: a + b + c
#=> foo/0, foo/1, foo/2, and foo/3

If you need to use an arity in the range below the original function, fall back to defcurry/2 and partially apply manually.

Link to this section Summary

Functions

A convenience on defcurry/2. Generates a series of partially-bound applications of a fully-curried function, for all arities at and below the user-specified arity.

defpartial/2, but generates private functions.

Link to this section Functions

Link to this macro

defpartial(arg, list)

View Source (macro)

A convenience on defcurry/2. Generates a series of partially-bound applications of a fully-curried function, for all arities at and below the user-specified arity.

For instance:

defpartial add(a,b), do: a + b
#=> add/0, add/1, add/2.

Examples

defmodule A do
  defpartial minus(a, b, c), do: a - b - c
end

A.minus(3, 2, 1)
#=> 0

A.minus.(3).(2).(1)
#=> 0

below_ten = A.minus(10)
below_ten.(2).(1)
#=> 7

below_five = A.minus(20, 15)
below_five.(2)
#=> 3
Link to this macro

defpartialp(arg, list)

View Source (macro)

defpartial/2, but generates private functions.