git.iko.soy/typeable/attoparsec
on master help sign in
Drop the second use of <|> from scientifically
commit9ae761bd9d7d3a47ac85a0e50d01ef35e918ebfd authorBryan O'Sullivan <bos@serpentine.com> dateSun 11 May 2014, 22:39 (12 years ago) parent2aa9077
1 file changed+5−3
Data/Attoparsec/ByteString/Char8.hs+5−3
Data/Attoparsec/ByteString/Char8.hs+5−3
@@ -539,9 +539,11 @@ scientifically h = do
539539 (negate $ B8.length fracDigits)
540540 step a w = a * 10 + fromIntegral (w - 48)
541541
542− s <- let dot = 46 in
543− (I.satisfy (==dot) *> (f <$> I.takeWhile isDigit_w8)) <|>
544− pure (Sci.scientific n 0)
542+ dotty <- I.peekWord8
543+ -- '.' -> ascii 46
544+ s <- case dotty of
545+ Just 46 -> I.anyWord8 *> (f <$> I.takeWhile isDigit_w8)
546+ _ -> pure (Sci.scientific n 0)
545547
546548 let !signedCoeff | positive = coefficient s
547549 | otherwise = negate $ coefficient s