Search code examples
haskellghcghci

GHC's readBin function from Numeric Library is not being recognised by GHCI


I am trying to use the readBin function from the Numeric Library but ghci is telling me that it is not in scope. Other functions like readOct and readHex are working. What could be the problem here?

Here is the error message:

Prelude> import Numeric
Prelude Numeric> :t readBin

<interactive>:1:1: error:
    • Variable not in scope: readBin
    • Perhaps you meant ‘readLn’ (imported from Prelude)
Prelude Numeric> :t readHex
readHex :: (Eq a, Num a) => ReadS a
Prelude Numeric> readHex "deadbeef"
[(3735928559,"")]

Solution

  • You're probably using GHC 9.0.2 or older. Those versions didn't have readBin yet.

    (Or more accurately, base-4.15.1.0 and older didn't have that function yet.)