[Haskell-cafe] Numerals in input vs numerals in source

Doug McIlroy doug at cs.dartmouth.edu
Wed Sep 24 03:19:30 UTC 2014


Consider

e1 = read "1" :: Integer
e2 = read "1" :: Rational
e3 = read "1" :: Double

e1 and e3 evaluate to 1 and 1.0 respectively
e2 produces an error: "Prelude.read: no parse"

Yet (1::Integer, 1::Rational, 1::Double) evaluates to (1, 1%1, 1.0)

Is the inconsistent parsing defensible, or just an (irrational!) fact?
I believe a reconciliation would break nothing.

Doug McIlroy


More information about the Haskell-Cafe mailing list