[Haskell-beginners] Overloading resolution with numbers

Amy de Buitléir amy at nualeargais.ie
Thu Apr 5 15:18:39 CEST 2012


 <j.romildo <at> gmail.com> writes:
> Why does (read "2" + 1) works, but (read "2.3" + 1) fail at runtime?

Try this:

read "2.3" + 1 :: Float

Or this:

read "2.3" + 1.0

The reason that your version didn't work is because GHCi is guessing that you
want the read operation to parse an Integer, since you're adding it to 1.




More information about the Beginners mailing list