Hi, all,
Mb it’s silly question , but: is there any possibility to define a behaviour in a function’s spec?
for example we have:
defmodule SomeBehaviour do
@callback do_it() :: any()
end
defmodule Adopter1 do
@behaviour SomeBehaviour
def do_it(), do: :done
end
defmodule Adopter2 do
@behaviour SomeBehaviour
def do_it(), do: :not_done
end
defmodule SomeModule do
# So, what's the right @spec for this function, if I'd like to specify SomeBehaviour adopters usage?
# The first thought is to use just SomeBehaviour.t with @type t :: __MODULE__ in SomeBehaviour definition,
# but as for me it seems too strict and any adopter will not pass the check
def do_it_with(adopter), do: adopter.do_it()
end
Thanks.