Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>I was hoping GHC would be able to pull the <code>Typeable</code> constraint from the context on the <code>Wrap</code> constructor</p> </blockquote> <p>If it had a <code>Wrap</code> constructor, it could pull the <code>Typeable</code> constraint from it.</p> <p>But it doesn't have a <code>Wrap</code> constructor.</p> <p>The difference is that the <code>Eq</code> instance uses the value, so it's either a <code>Wrap something</code>, where the <code>Wrap</code> constructor makes the <code>Eq</code> dictionary for the wrapped type available, and everything is fine, or it's <code>⊥</code>, and then everything is fine too, evaluating <code>x == y</code> bottoms out.</p> <p>Note that the derived</p> <pre><code>instance Eq (Wrapper a) </code></pre> <p>does <em>not</em> have an <code>Eq</code> constraint on the type variable <code>a</code>.</p> <pre><code>Prelude DerivT&gt; (undefined :: Wrapper (Int -&gt; Int)) == undefined *** Exception: Prelude.undefined Prelude DerivT&gt; (undefined :: (Int -&gt; Int)) == undefined &lt;interactive&gt;:3:29: No instance for (Eq (Int -&gt; Int)) arising from a use of `==' Possible fix: add an instance declaration for (Eq (Int -&gt; Int)) In the expression: (undefined :: Int -&gt; Int) == undefined In an equation for `it': it = (undefined :: Int -&gt; Int) == undefined </code></pre> <p>But the <code>Typeable</code> instance must not make use of the value, so there's no bottoming out if the supplied value isn't a <code>Wrap something</code>.</p> <p>Thus the derived <code>instance Typeable1 Wrapper</code> supplies</p> <pre><code>instance Typeable t =&gt; Typeable (Wrapper t) </code></pre> <p>but not an unconstrained</p> <pre><code>instance Typeable (Wrapper t) </code></pre> <p>and that unconstrained instance cannot be derived by GHC.</p> <p>Hence you have to either provide a constrained</p> <pre><code>instance Typeable t =&gt; BothEqAndTypeable (Wrapper t) </code></pre> <p>or an unconstrained</p> <pre><code>instance Typeable (Wrapper t) </code></pre> <p>yourself.</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. 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