git.iko.soy/typeable/attoparsec
on master help sign in
Document the lack of NaN/Infinity support in the floating point parsers.
commitee7ffc3bd4b0958668e62e902b0af13842b3709a authorBryan O'Sullivan <bos@serpentine.com> dateWed 13 Apr 2011, 10:54 (16 years ago) parent4b7c559
1 file changed+9
Data/Attoparsec/Char8.hs+9
Data/Attoparsec/Char8.hs+9
@@ -417,6 +417,9 @@ signed p = (negate <$> (char8 '-' *> p))
417417--
418418-- >rational "3.foo" == Done 3.0 ".foo"
419419-- >rational "3e" == Done 3.0 "e"
420+--
421+-- This function does not accept string representations of \"NaN\" or
422+-- \"Infinity\".
420423rational :: Fractional a => Parser a
421424{-# SPECIALIZE rational :: Parser Double #-}
422425{-# SPECIALIZE rational :: Parser Float #-}
@@ -436,6 +439,9 @@ rational = floaty $ \real frac fracDenom -> fromRational $
436439-- results, but for the remaining 5.8%, this function loses precision
437440-- around the 15th decimal place. For 0.001% of numbers, this
438441-- function will lose precision at the 13th or 14th decimal place.
442+--
443+-- This function does not accept string representations of \"NaN\" or
444+-- \"Infinity\".
439445double :: Parser Double
440446double = floaty asDouble
441447
@@ -452,6 +458,9 @@ asDouble real frac fracDenom =
452458-- On integral inputs, it gives perfectly accurate answers, and on
453459-- floating point inputs, it is slightly less accurate than
454460-- 'rational'.
461+--
462+-- This function does not accept string representations of \"NaN\" or
463+-- \"Infinity\".
455464number :: Parser Number
456465number = floaty $ \real frac fracDenom ->
457466 if frac == 0 && fracDenom == 0