Open j-maas opened 4 years ago
As a workaround, one can define their own float parser:
{-| The built-in float parser has a bug with leading 'e'.
See <https://github.com/elm/parser/issues/44>
-}
parseFloat : Parser Float
parseFloat =
{- By making it backtrackable, even if the input start with an 'e',
we will be able to try out other alternatives instead of getting
stuck on it as an invalid number.
-}
Parser.backtrackable <| Parser.float ExpectingFloat InvalidNumber
int
parser has the same problem of committing the leading 'e'
I ran in to this same problem:
term : Parser Expr
term =
P.oneOf
[ P.succeed Number
|= number
, P.succeed EParam
|= param
]
Given,
Parser.run term "E"
it returns
Err [{ col = 2, problem = ExpectingInt, row = 1 }]
instead of
Ok (EParam "E")
Similar to #28, the float parser comitts when it encounters an 'e', making it impossible to have a parser that reads either a float or some text:
(Try it on Ellie: https://ellie-app.com/8yp6MxtzSsna1)