I am working with behaviours and callbacks, so I am trying to define a spec for a function that should accept an argument which is also a function, but specifically a function that accepts 1 argument. I just discovered that there is a is_function that can be used in a guard clause: Kernel — Elixir v1.20.2
I have something like this:
@callback something(fun :: function()) :: list()
and implementations look like this:
@impl true
def something(fun) do
fun.("abc")
end
It is important that the provided fun has an arity of 1. I could make a guard clause:
@impl true
def something(fun) when is_function(fun, 1) do
fun.("abc")
end
but I am wondering if it is possible to define this in the @callback spec?


















