<div dir="ltr"><div>Floating is the type class of types that are floating point.  The two most common instances are Float and Double.  Integral is the class of integer types.  Most commonly Int and Integer.</div><div><br></div><div><pre style="margin-top:0px;margin-bottom:1em;padding:5px;border:0px none;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;font-family:Consolas,Menlo,Monaco,"Lucida Console","Liberation Mono","DejaVu Sans Mono","Bitstream Vera Sans Mono","Courier New",monospace,sans-serif;vertical-align:baseline;box-sizing:inherit;width:auto;max-height:600px;overflow:auto;background-color:rgb(239,240,241);color:rgb(36,39,41)"><code style="margin:0px;padding:0px;border:0px none;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:Consolas,Menlo,Monaco,"Lucida Console","Liberation Mono","DejaVu Sans Mono","Bitstream Vera Sans Mono","Courier New",monospace,sans-serif;vertical-align:baseline;box-sizing:inherit;white-space:inherit">stdDev
  :: (Floating a1, Floating a, Integral a1) =></code></pre>When you see a type like that it means type a1 is both a Floating and also an Integral.  Intellectually that is impossible, but as far as ghc is concerned there could be a type that is an instance of both classes, so it allows it.  But when you try to call it, there's no type in scope that you can affix to a1 to please it, so it will always error.</div><div><br></div><div>The reason it has both Floating and Integral on the same type is that you are using several functions on various arguments of your function that imply that the types of those arguments must be instances of various classes.</div><div><br></div><div><div>fromIntegral :: (Integral a, Num b) => a -> b</div><div>sumOfMinusMeans :: (Eq t, Floating t) => Int -> t -> [[t]] -> t<br></div></div><div><div style="font-size:small;text-decoration-style:initial;text-decoration-color:initial"><div>sqrt :: Floating a => a -> a -- (this function may not be a factor)</div></div></div><div><br></div><div>I strongly recommend you write out a type for stdDev, but fix a1 to a concrete type and then ghc can tell you why that type won't work.</div><div><div>stdDev :: Int -> Int -> [Double] -> [[Double]] -> [Double]</div></div><div><br></div><div><div>    • No instance for (Integral Double)</div><div>        arising from a use of ‘fromIntegral’</div></div><div><br></div><div><div>stdDev :: Int -> Int -> [Integer] -> [[Integer]] -> [Double]</div></div><div><br></div><div><div>    • No instance for (Floating Integer)</div><div>        arising from a use of ‘sumOfMinusMeans’</div></div><div><br></div><div>And then think really hard about what types you want stdDev to accept.  Rework its the definition until the compiler is happy.  I suspect it is an extraneous fromIntegral.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Aug 23, 2018 at 6:26 AM, Jack Vice <span dir="ltr"><<a href="mailto:jack.vice@gmail.com" target="_blank">jack.vice@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><p style="margin:0px 0px 1em;padding:0px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;font-family:Arial,"Helvetica Neue",Helvetica,sans-serif;font-size:15px;vertical-align:baseline;box-sizing:inherit;clear:both;color:rgb(36,39,41)">I am trying to calculate the standard deviation for each index in a list of lists of floats. Using Ubuntu 18.04, ghc 8.0.2. I am getting the following runtime error which I have googled and still don't understand what "Integral Float" is exactly or even which parameter is causing the trouble.</p><pre style="margin-top:0px;margin-bottom:1em;padding:5px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;font-family:Consolas,Menlo,Monaco,"Lucida Console","Liberation Mono","DejaVu Sans Mono","Bitstream Vera Sans Mono","Courier New",monospace,sans-serif;font-size:13px;vertical-align:baseline;box-sizing:inherit;width:auto;max-height:600px;overflow:auto;background-color:rgb(239,240,241);word-wrap:normal;color:rgb(36,39,41)"><code style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:Consolas,Menlo,Monaco,"Lucida Console","Liberation Mono","DejaVu Sans Mono","Bitstream Vera Sans Mono","Courier New",monospace,sans-serif;vertical-align:baseline;box-sizing:inherit;white-space:inherit">*Main> let z = stdDev 0 2 y x
<interactive>:250:9: error:
• Could not deduce (Integral Float) arising from a use of ‘stdDev’
  from the context: Floating a
    bound by the inferred type of z :: Floating a => [a]
    at <interactive>:250:5-38
• In the expression: stdDev 0 (length (head (x))) y x
  In an equation for ‘z’: z = stdDev 0 (length (head (x))) y x
</code></pre><p style="margin:0px 0px 1em;padding:0px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;font-family:Arial,"Helvetica Neue",Helvetica,sans-serif;font-size:15px;vertical-align:baseline;box-sizing:inherit;clear:both;color:rgb(36,39,41)">Code:</p><pre style="margin-top:0px;margin-bottom:1em;padding:5px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;font-family:Consolas,Menlo,Monaco,"Lucida Console","Liberation Mono","DejaVu Sans Mono","Bitstream Vera Sans Mono","Courier New",monospace,sans-serif;font-size:13px;vertical-align:baseline;box-sizing:inherit;width:auto;max-height:600px;overflow:auto;background-color:rgb(239,240,241);word-wrap:normal;color:rgb(36,39,41)"><code style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:Consolas,Menlo,Monaco,"Lucida Console","Liberation Mono","DejaVu Sans Mono","Bitstream Vera Sans Mono","Courier New",monospace,sans-serif;vertical-align:baseline;box-sizing:inherit;white-space:inherit">-- i is start index, l is length of each list, ms is list of means, 
--    xs is Matrix
stdDev i l ms xs
     | i < l     = sqrt(fromIntegral(<wbr>sumOfMinusMeans i (ms!!i) xs) / 
                             fromIntegral(l)):(stdDev (i+1) l ms xs)
     | otherwise = []

--i is index, m is mean for the index
sumOfMinusMeans i m (x:xs)
     | xs == []     = (x!!i - m)**2
     | i < length x = (x!!i - m)**2 + (sumOfMinusMeans i m xs)
     | otherwise    = 0
</code></pre><p style="margin:0px 0px 1em;padding:0px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;font-family:Arial,"Helvetica Neue",Helvetica,sans-serif;font-size:15px;vertical-align:baseline;box-sizing:inherit;clear:both;color:rgb(36,39,41)">Types:</p><pre style="margin-top:0px;margin-bottom:1em;padding:5px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;font-family:Consolas,Menlo,Monaco,"Lucida Console","Liberation Mono","DejaVu Sans Mono","Bitstream Vera Sans Mono","Courier New",monospace,sans-serif;font-size:13px;vertical-align:baseline;box-sizing:inherit;width:auto;max-height:600px;overflow:auto;background-color:rgb(239,240,241);word-wrap:normal;color:rgb(36,39,41)"><code style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:Consolas,Menlo,Monaco,"Lucida Console","Liberation Mono","DejaVu Sans Mono","Bitstream Vera Sans Mono","Courier New",monospace,sans-serif;vertical-align:baseline;box-sizing:inherit;white-space:inherit">*Main> :t stdDev
stdDev
  :: (Floating a1, Floating a, Integral a1) =>
     Int -> Int -> [a1] -> [[a1]] -> [a]

*Main> :t sumOfMinusMeans
sumOfMinusMeans :: (Eq t, Floating t) => Int -> t -> [[t]] -> t
</code></pre><p style="margin:0px 0px 1em;padding:0px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;font-family:Arial,"Helvetica Neue",Helvetica,sans-serif;font-size:15px;vertical-align:baseline;box-sizing:inherit;clear:both;color:rgb(36,39,41)">Variables:</p><pre style="margin-top:0px;margin-bottom:1em;padding:5px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;font-family:Consolas,Menlo,Monaco,"Lucida Console","Liberation Mono","DejaVu Sans Mono","Bitstream Vera Sans Mono","Courier New",monospace,sans-serif;font-size:13px;vertical-align:baseline;box-sizing:inherit;width:auto;max-height:600px;overflow:auto;background-color:rgb(239,240,241);word-wrap:normal;color:rgb(36,39,41)"><code style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:Consolas,Menlo,Monaco,"Lucida Console","Liberation Mono","DejaVu Sans Mono","Bitstream Vera Sans Mono","Courier New",monospace,sans-serif;vertical-align:baseline;box-sizing:inherit;white-space:inherit">*Main> y
[380.0,1.0]
*Main> x
[[600.0,1.0],[400.0,1.0],[170.<wbr>0,1.0],[430.0,1.0],[300.0,1.0]<wbr>]</code></pre></div>
<br>______________________________<wbr>_________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org">Beginners@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-<wbr>bin/mailman/listinfo/beginners</a><br>
<br></blockquote></div><br></div>