Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can check the type in GHCi with <code>:t</code>, as mentioned in the other answers. If you want to try figuring it out yourself, you need to substitute the types as appropriate. In your first example, we have</p> <pre><code>zipWith :: (a -&gt; b -&gt; c) -&gt; [a] -&gt; [b] -&gt; [c] </code></pre> <p>and</p> <pre><code>map :: (a -&gt; b) -&gt; [a] -&gt; [b] </code></pre> <p>The first argument of <code>map</code> is a function of one argument, so we have to regard <code>zipWith</code> as such a function:</p> <pre><code>zipWith :: (a -&gt; b -&gt; c) -&gt; ([a] -&gt; [b] -&gt; [c]) </code></pre> <p>(The type above is equivalent to the original one. It means <code>zipWith</code> converts a function which takes arguments of types <code>a</code> and <code>b</code> to a function which takes lists of <code>a</code> and <code>b</code>.)</p> <p><code>map</code> can be seen as a function of one argument as well:</p> <pre><code>map :: (a -&gt; b) -&gt; ([a] -&gt; [b]) </code></pre> <p>Now, we fill in the types in <code>map</code>'s result type - <code>a</code> becomes <code>a -&gt; b -&gt; c</code> and <code>b</code> becomes <code>[a] -&gt; [b] -&gt; [c]</code>:</p> <pre><code>map zipWith :: [a -&gt; b -&gt; c] -&gt; [[a] -&gt; [b] -&gt; [c]] </code></pre> <p>P.S.: Do you really want functions which take lists of functions as arguments? If you just want to zip two lists adding the corresponding elements you want</p> <pre><code> zipWith (+) :: Num c =&gt; [c] -&gt; [c] -&gt; [c] </code></pre> <p>rather than <code>zipWith sum</code>.</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. 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