[Haskell-beginners] Overloading resolution with numbers

j.romildo at gmail.com j.romildo at gmail.com
Thu Apr 5 15:16:34 CEST 2012


Hello.

Consider the following ghci session:

   Prelude> :t read "2" + 1
   read "2" + 1 :: (Num a, Read a) => a

   Prelude> :t read "2.3" + 1
   read "2.3" + 1 :: (Num a, Read a) => a

   Prelude> read "2" + 1
   3

   Prelude> read "2.3" + 1
   *** Exception: Prelude.read: no parse

Why does (read "2" + 1) works, but (read "2.3" + 1) fail at runtime?

Romildo



More information about the Beginners mailing list