[Haskell-cafe] Numeric Class Problem

Brandon S. Allbery KF8NH allbery at ece.cmu.edu
Sun Jan 28 13:04:58 EST 2007

On Jan 28, 2007, at 13:01 , Dennis Buchmann wrote:

> It should look like this:
> 	floor(j * (n / p2n))
> where j is an Integer, n is the length of a list, therefore Integer  
> too,
> and p2n is 2^n.
> When i use the former line in my Haskell code (pasted at the end of  
> this mail),
> i get the following error message:
> qc.lhs:464:16:
>     No instance for (RealFrac Int)
>       arising from use of `floor' at qc.lhs:464:16-36

It's telling you you're trying to take the floor of an Int (not a  
type in class RealFrac, which would be Float or Double).  This makes  
sense because everything there is in fact an Int ((^) is defined as  
taking things of class Integral (Integer, Int) and returning  
something in class Num, which in this case will be Int because it's  
used in an Int expression).  In other words, floor is unnecessary.

brandon s. allbery    [linux,solaris,freebsd,perl]     allbery at kf8nh.com
system administrator [openafs,heimdal,too many hats] allbery at ece.cmu.edu
electrical and computer engineering, carnegie mellon university    KF8NH

More information about the Haskell-Cafe mailing list