Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You're problem doesn't have anything to do with <code>Floating</code>, though the typeclass does make your error harder to understand. Take the below code as an example:</p> <pre><code>test1 :: Int -&gt; Char -&gt; Int test1 = undefined test2 :: Int -&gt; Int test2 x = undefined testBoth = test2 . test1 </code></pre> <p>What is the type of testBoth? Well, we take the type of <code>(.) :: (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c</code> and turn the crank to get:</p> <ol> <li><code>b ~ Int</code> (the argument of <code>test2</code> unified with the first argument of <code>(.)</code>)</li> <li><code>c ~ Int</code> (the result of <code>test2</code> unified with the result of the first argument of <code>(.)</code>)</li> <li><code>a ~ Int</code> (<code>test1</code> argument 1 unified with argument 2 of <code>(.)</code>)</li> <li><code>b ~ Char -&gt; Int</code> (result of <code>test1</code> unified with argument 2 of <code>(.)</code>)</li> </ol> <p>but wait! that type variable, 'b' (#4, <code>Char -&gt; Int</code>), has to unify with the argument type of <code>test2</code> (#1, <code>Int</code>). Oh No!</p> <p>How should you do this? A correct solution is:</p> <pre><code>testBoth x = test2 . test1 x </code></pre> <p>There are other ways, but I consider this the most readable.</p> <p>Edit: So what was the error trying to tell you? It was saying that unifying <code>Floating a =&gt; a -&gt; a</code> with <code>Floating b =&gt; b</code> requires an <code>instance Floating (a -&gt; a)</code> ... while that's true, you really didn't want GHC to try and treat a function as a floating point number.</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.
 

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