title: Pattern matching in purescript
body: <p>How can I implement <code>head</code> or <code>singleton</code> function in purescript by pattern matching? The problem is that the compiler requires the explicit definition of the broadest pattern, but I can't generate a default value for a type that I don't know. </p>
  
  <pre><code>fromSingleton :: forall a. a -&gt; Array a -&gt; a 
  fromSingleton _   [x] = x
  fromSingleton def []    = def
  </code></pre>
  
  <p>returns:</p>
  
  <pre><code>A case expression could not be determined to cover all inputs.
    The following additional cases are required to cover all inputs:
  
      _ _
  
    Alternatively, add a Partial constraint to the type of the enclosing value.
  </code></pre>
  
  <p>But this proposal looks dummy, I can't  add:</p>
  
  <pre><code>fromSingleton _ _     = ??? (a -- is any type, how can I implement default for it?)
  </code></pre>