Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>What you implemented (rather, what you think you implemented) is a function that works only on lists of <code>Integer</code>s, what the assignment wants you to do is create one that works on lists of all types provided they are equality-comparable (so that your function will also work on lists of booleans or strings). You probably don't have to change a lot: Try removing the explicit type signatures from your code and ask <code>ghci</code> about the type that it would infer from your code (<code>:l yourfile.hs</code> and then <code>:t deleteAll_list_comp</code>). Unless you use arithmetic operations or similar things, you will most likely find that your functions already work for all <code>Eq a</code>.</p> <p>As a simpler example that may explain the concept: Let's say we want to write a function <code>isequal</code> that checks for equality (slightly useless, but hey):</p> <pre><code>isequal :: Integer -&gt; Integer -&gt; Bool isequal a b = (a == b) </code></pre> <p>This is a perfectly fine definition of <code>isequal</code>, but the type constraints that I have manually put on it are way stronger than they have to. In fact, in the absence of the manual type signature, ghci infers:</p> <pre><code>Prelude&gt; :t isequal isequal :: Eq a =&gt; a -&gt; a -&gt; Bool </code></pre> <p>which tells us that the function will work for all input types, as long as they are <code>deriving Eq</code>, which means nothing more than having a proper <code>==</code> relation defined on them.</p> <hr> <p>There is still a problem with your <code>_rec</code> function though, since it should do the same thing as your <code>_comp</code> function, the type signatures should match.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload