title: Check if a value is a Keyword List
body: <p>Elixir provides a few <code>is_</code> functions that let you check if an item is a specific type:</p>
  
  <ul>
  <li><code>is_atom</code></li>
  <li><code>is_binary</code></li>
  <li><code>is_map</code></li>
  <li>etc.</li>
  </ul>
  
  <p><strong>But how do I check if a value is a Keyword List in Elixir?</strong> I understand that underneath, Keyword Lists are a list of 2-element tuples with the first element as an atom, so my current workaround is this:</p>
  
  
  
  <pre class="lang-ex prettyprint-override"><code>defmodule KList do
    def is_keyword?(list) when is_list(list) do
      Enum.all? list, fn item -&gt;
        case item do
          {k, _} -&gt; is_atom(k)
          _      -&gt; false
        end
      end
    end
  
    def is_keyword?(_), do: false
  end
  </code></pre>
  
  <p><strong>Is there a better (or an in-built) way of doing this? And more importantly, how can I do this in a <code>when</code> clause?</strong></p>