What is the best way to define a @callback when injecting dependencies?

I’m using the behaviour pattern to define how something should be implemented.

The function I am defining accepts a module as a parameter, which allows me to inject different modules (for testing, easily switching up implementations used, etc).

I couldn’t find something appropriate in the Kernel.Typespec docs so what I have done at the moment is something like this;

@callback my_func(some_var :: String.t, this_is_my_dependency :: Module) :: success | error

This is how the implementation is defined;

def my_func(some_var, this_is_my_dependency \\ MyDependency), do: ...

I’d appreciate some guidance on the best way to write this. Thanks for reading :slight_smile:

Under build-in types in the docs there’s module() => implemented as atom() if you don’t look at the 1.0.5 docs, like you did: https://hexdocs.pm/elixir/typespecs.html