Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I can't explain why, but here's the proof of the cycle:</p> <p>Assume <code>k &gt;= 2</code> and <code>fmap^(4k) :: (a -&gt; b) -&gt; F1 F2 F3 a -&gt; F1 F2 F3 b</code>, where <code>Fx</code> stands for an unknown/arbitrary <code>Functor</code>. <code>fmap^n</code> stands for <code>fmap</code> applied to <code>n-1</code> <code>fmap</code>s, not <code>n</code>-fold iteration. The induction's start can be verified by hand or querying ghci.</p> <pre><code>fmap^(4k+1) = fmap^(4k) fmap fmap :: (x -&gt; y) -&gt; F4 x -&gt; F4 y </code></pre> <p>unification with a -> b yields <code>a = x -&gt; y</code>, <code>b = F4 x -&gt; F4 y</code>, so</p> <pre><code>fmap^(4k+1) :: F1 F2 F3 (x -&gt; y) -&gt; F1 F2 F3 (F4 x -&gt; F4 y) </code></pre> <p>Now, for <code>fmap^(4k+2)</code> we must unify <code>F1 F2 F3 (x -&gt; y)</code> with <code>(a -&gt; b) -&gt; F5 a -&gt; F5 b</code>.<br> Thus <code>F1 = (-&gt;) (a -&gt; b)</code> and <code>F2 F3 (x -&gt; y)</code> must be unified with <code>F5 a -&gt; F5 b</code>.<br> Hence <code>F2 = (-&gt;) (F5 a)</code> and <code>F3 (x -&gt; y) = F5 b</code>, i.e. <code>F5 = F3</code> and <code>b = x -&gt; y</code>. The result is</p> <pre><code>fmap^(4k+2) :: F1 F2 F3 (F4 x -&gt; F4 y) = (a -&gt; (x -&gt; y)) -&gt; F3 a -&gt; F3 (F4 x -&gt; F4 y) </code></pre> <p>For <code>fmap^(4k+3)</code>, we must unify <code>a -&gt; (x -&gt; y)</code> with <code>(m -&gt; n) -&gt; F6 m -&gt; F6 n)</code>, giving <code>a = m -&gt; n</code>,<br> <code>x = F6 m</code> and <code>y = F6 n</code>, so</p> <pre><code>fmap^(4k+3) :: F3 a -&gt; F3 (F4 x -&gt; F4 y) = F3 (m -&gt; n) -&gt; F3 (F4 F6 m -&gt; F4 F6 n) </code></pre> <p>Finally, we must unify <code>F3 (m -&gt; n)</code> with <code>(a -&gt; b) -&gt; F7 a -&gt; F7 b</code>, so <code>F3 = (-&gt;) (a -&gt; b)</code>, <code>m = F7 a</code> and <code>n = F7 b</code>, therefore</p> <pre><code>fmap^(4k+4) :: F3 (F4 F6 m -&gt; F4 F6 n) = (a -&gt; b) -&gt; (F4 F6 F7 a -&gt; F4 F6 F7 b) </code></pre> <p>and the cycle is complete. Of course the result follows from querying ghci, but maybe the derivation sheds some light on how it works.</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.
 

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