let base = 10
let bitsPerDigit = logBase 2.0 (fromIntegral base)
let activeBits = fromIntegral $
ceiling (bitsPerDigit * (Prelude.length "123"))
There's a missing fromIntegral
above, which causes GHC to underline logBase
and complain that it has no instance for (Floating Int)
. This is, on the face of things, completely mystifying. Both parameters are “obviously” floating! A second error points to ceiling
, saying no instance for (RealFrac Int)
.
The second error is the more suggestive one, since the problem is that the type of *
causes GHC to equate the type of bitsPerDigit
with that of (Prelude.length clean)
, i.e. Int
. But it’s more than a little strange to force the programmer to reason about their code in the same order that the type checker does!