
5 Apr
2012
5 Apr
'12
9:18 a.m.
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.