How can I check whether the protocol is implemented? : <p>I wonder if there any way to ask Elixir whether <em>this object implements that protocol</em>, something like <code>obj |&gt; implements(Enumerable)</code>?</p>

<p>Basically, I have to distinguish structs and maps. The solution I currently have is kinda ugly:</p>

<pre><code>try
  obj |&gt; Enum.each ...
rescue 
  e in Protocol.UndefinedError -&gt; obj |&gt; Maps.keys ...
end
</code></pre>

<p>The above works, but I would prefer to use pattern matching like:</p>

<pre><code>cond do
  obj |&gt; is_implemented(Enumerable) -&gt; ...
  _ -&gt; ...
end
</code></pre>

<p>Am I missing something? <strong>Can one explicitly check whether the desired protocol is implemented by the object?</strong></p>
