title: How to Interpret (Eq a)
body: <p>I need to create a function of two parameters, an <code>Int</code> and a <code>[Int]</code>, that returns a new <code>[Int]</code> with all occurrences of the first parameter removed.</p>
  
  <p>I can create the function easily enough, both with list comprehension and list recursion. However, I do it with these parameters:</p>
  
  <pre><code>deleteAll_list_comp :: Integer -&gt; [Integer] -&gt; [Integer]
  deleteAll_list_rec :: (Integer -&gt; Bool) -&gt; [Integer] -&gt; [Integer]
  </code></pre>
  
  <p>For my assignment, however, my required parameters are </p>
  
  <pre><code>deleteAll_list_comp :: (Eq a) =&gt; a -&gt; [a] -&gt; [a]
  deleteAll_list_rec :: (Eq a) =&gt; a -&gt; [a] -&gt; [a]
  </code></pre>
  
  <p>I don't know how to read this syntax. As Google has told me, <code>(Eq a)</code> merely explains to Haskell that <code>a</code> is a type that is comparable. However, I don't understand the point of this as all <code>Int</code>s are naturally comparable. How do I go about interpreting and implementing the methods using these parameters? What I mean is, what exactly are the parameters to begin with?</p>
  
  <hr>
  
  <p>@groovy @pelotom</p>
  
  <p>Thanks, this makes it very clear. I understand now that really it is only asking for two parameters as opposed to three. However, I still am running into a problem with this code.</p>
  
  <pre><code>deleteAll_list_rec :: (Eq a) =&gt; a -&gt; [a] -&gt; [a]
  delete_list_rec toDelete [] = []
  delete_list_rec toDelete (a:as) =
          if(toDelete == a) then delete_list_rec toDelete as
          else a:(delete_list_rec toDelete as)
  </code></pre>
  
  <p>This gives me a "The type signature for <code>deleteAll_list_rec</code>
    lacks an accompanying binding" which makes no sense to me seeing as how I did bind the requirements properly, didn't I? From my small experience, <code>(a:as)</code> counts as a list while extracting the first element from it. Why does this generate an error but</p>
  
  <pre><code>deleteAll_list_comp :: (Eq a) =&gt; a -&gt; [a] -&gt; [a]
  deleteAll_list_comp toDelete ls = [x | x &lt;- ls, toDelete==x]
  </code></pre>
  
  <p>does not?</p>
  
  <hr>
  
  <p>2/7/13 Update: For all those who might stumble upon this post in the future with the same question, I've found some good information about Haskell in general, and my question specifically, at this link : <a href="http://learnyouahaskell.com/types-and-typeclasses" rel="nofollow">http://learnyouahaskell.com/types-and-typeclasses</a></p>
  
  <blockquote>
    <p>"Interesting. We see a new thing here, the => symbol. Everything before the => symbol is >called a class constraint. We can read the previous type declaration like this: the >equality function takes any two values that are of the same type and returns a Bool. The >type of those two values must be a member of the Eq class (this was the class constraint).</p>
    
    <p>The Eq typeclass provides an interface for testing for equality. Any type where it makes >sense to test for equality between two values of that type should be a member of the Eq >class. All standard Haskell types except for IO (the type for dealing with input and >output) and functions are a part of the Eq typeclass."</p>
  </blockquote>