GHC Haskell seems to require a number before the decimal point to read Double. Here is the code:
main :: IO ()
main = do
let d1 = read "0.3" :: Double
d2 = read ".3" :: Double
print d1
print d2
Running this process:
0.3
*** Exception: Prelude.read: no parse
Is this a GHC bug or just a major limitation?
(I tried reading ".3" using C, Javascript and MS Excel, and all of this could successfully parse ".3" and understand it as a number. I think I see the consequences of this problem in other areas of my program, including reading arguments command line with parseargs package and reading paired in html forms with Yesod MForms.)
Is there a fix or workaround for this issue?
source
share