title: Check that module implements behaviour
body: <p>I have a behaviour and a function that takes a list of modules that should implement that behaviour. I would like to check that each module passed in does in fact implement that behaviour. I can do that with <code>MyBehaviour.implemented_by?/1</code> below, but I'm wondering if there's a more direct way about it.</p>
  
  <pre><code>defmodule MyBehaviour do
    @callback do_something(String.t(), String.t()) :: no_return()
  
    def implemented_by?(module) do
      :attributes
      |&gt; module.module_info()
      |&gt; Enum.member?({:behaviour, [__MODULE__]})
    end
  end
  </code></pre>
  
  <p><strong>Is that the best way to check that?</strong> I'm not finding anything in the docs or Elixir forum or anywhere.</p>
  
  <p><strong>Should I even be checking that?</strong> Or should I just let the responsibility rest entirely upon the caller? Are behaviours more about "I want to make sure I implement everything needed" than "I want everyone else to know I implement everything needed"?</p>
  
  <p><strong>Is there a way to use behaviours as a type in typespecs?</strong> Can my function spec say that args should implement my behaviour, or should I just use <code>module()/atom()</code>?</p>