Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I'm afraid that <code>not oddOf</code> isn't a reasonable partially-applied function. It's an application of <code>not</code> to <code>oddOf</code>.</p> <p><code>not</code> has type <code>Bool -&gt; Bool</code>; it takes a single <code>Bool</code> argument and returns a <code>Bool</code>. <code>oddOf</code> isn't a <code>Bool</code>, so <code>not</code> can't be applied to it. But what you want is not to apply <code>not</code> to <code>oddOf</code> itself, but to apply <code>not</code> to the <em>result</em> of applying <code>oddOf</code> to two arguments.</p> <p>The most direct way to do what you want is to write something like this:</p> <pre><code>evenOf value list = not $ oddOf value list </code></pre> <p>This is theoretically a little less direct and abstract than it could be, because rather than just defining <code>evenOf</code> by its relationship to <code>oddOf</code> directly you're "manually" wiring up the inputs to <code>evenOf</code> to the inputs of <code>oddOf</code> and then post-processing its result. A point-free version, such as Ziyao Wei's suggested:</p> <pre><code>evenOf = ((not .) .) oddOf </code></pre> <p>more directly states that relationship, freeing the reader from having to verify that the 2 arguments to <code>evenOf</code> are simply passed to <code>oddOf</code> in the same order and not used for any other purpose. But generally it takes quite a deep familiarity with Haskell to find that version clearer (otherwise you have to instead verify what exactly the nested composition sections do to see the "directly stated" relationship). So if you're more comfortable with explicitly naming and "wiring" the arguments, that's probably the elegant way you're looking for.</p>
    singulars
    1. This table or related slice is empty.
    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.
    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