title: Haskell "No instance for (Eq a) arising from a use of `/='"
body: <p>I'm just starting to get into the world of functional programming in a class. As a part of an assignment, we have to write a function that determines if a list is a singleton or not (if the list has exactly 1 element inside of it)</p>
  
  <p>I've written the function and it works perfectly fine:</p>
  
  <pre><code>singleton x = x /= [] &amp;&amp; x == take 1 (x) 
  </code></pre>
  
  <p>If I call singleton [1] it returns true as expected.
  If I call singleton [] or singleton [1,2,3]  it returns false as expected.</p>
  
  <p>However, my professor wants us to properly document the code with (I'm not exactly sure what this is called, but it tell haskell what to expect as input and output from the function):</p>
  
  <pre><code>singleton :: [a] -&gt; Bool
  </code></pre>
  
  <p>As far as I can tell, this should work, but as soon as I have this, the compiler says "No instance for (Eq a) arising from a use of '/='"</p>
  
  <p>Could anyone point me in the right direction to get the code compiled with that (I really have no clue what it's called) bit of function declaration?</p>
  
  <p>Thanks!</p>