ExAequoFn.NamedFn (ExAequoFn v0.1.3)
View SourceA function wrapper
Summary
Types
@type either_t(error_t, ok_t) :: {:ok, ok_t} | {:error, error_t}
@type function_t() :: (... -> any())
@type maybe(t) :: nil | t
@type result_t(t) :: {:ok, t} | :error
@type t() :: %ExAequoFn.NamedFn{ arity: non_neg_integer(), fun: function_t(), name: binary() }
@type transformers_t() :: [transformer_t()]
Functions
Same as call(..., [])
, basically extracting fun
This can also curry into a function
iex(1)> join3 = new(&Enum.join([&1, &2, &3], "-"), "joiner")
...(1)> join2 = call(join3, ~W[a])
...(1)> assert join2.(~W[b c]) == "a-b-c"
But be careful with arg sizes
iex(2)> adder = new(&(&1 + &2))
...(2)> assert_raise(ArgumentError, fn -> call(adder, [1, 2, 3]) end)
@spec new(function_t(), binary?()) :: t()