git.iko.soy/typeable/attoparsec
on master help sign in
Fix up docs around Number
commita8eeed82712cc9737ddc0f8bf4bba8827481e668 authorBryan O'Sullivan <bos@serpentine.com> dateWed 28 May 2014, 22:40 (12 years ago) parent676354a
3 files changed+20−32
Data/Attoparsec/ByteString/Char8.hs+4−17 Data/Attoparsec/Number.hs+14−1 Data/Attoparsec/Text.hs+2−14
Data/Attoparsec/ByteString/Char8.hs+4−17
@@ -1,6 +1,6 @@
11{-# LANGUAGE BangPatterns, FlexibleInstances, TypeFamilies,
22 TypeSynonymInstances, GADTs #-}
3−{-# OPTIONS_GHC -fno-warn-orphans #-}
3+{-# OPTIONS_GHC -fno-warn-orphans -fno-warn-warnings-deprecations #-}
44
55-- |
66-- Module : Data.Attoparsec.ByteString.Char8
@@ -513,15 +513,6 @@ rational = scientifically realToFrac
513513--
514514-- The syntax accepted by this parser is the same as for 'rational'.
515515--
516−-- /Note/: This function is almost ten times faster than 'rational',
517−-- but is slightly less accurate.
518−--
519−-- The 'Double' type supports about 16 decimal places of accuracy.
520−-- For 94.2% of numbers, this function and 'rational' give identical
521−-- results, but for the remaining 5.8%, this function loses precision
522−-- around the 15th decimal place. For 0.001% of numbers, this
523−-- function will lose precision at the 13th or 14th decimal place.
524−--
525516-- This function does not accept string representations of \"NaN\" or
526517-- \"Infinity\".
527518double :: Parser Double
@@ -531,13 +522,8 @@ double = scientifically Sci.toRealFloat
531522--
532523-- The syntax accepted by this parser is the same as for 'rational'.
533524--
534−-- /Note/: This function is almost ten times faster than 'rational'.
535−-- On integral inputs, it gives perfectly accurate answers, and on
536−-- floating point inputs, it is slightly less accurate than
537−-- 'rational'.
538−--
539−-- This function does not accept string representations of \"NaN\" or
540−-- \"
525+ -- This function does not accept string representations of \"NaN\" or
526+ -- \"Infinity\".
541527number :: Parser Number
542528number = scientifically $ \s ->
543529 let e = Sci.base10Exponent s
@@ -545,6 +531,7 @@ number = scientifically $ \s ->
545531 in if e >= 0
546532 then I (c * 10 ^ e)
547533 else D (Sci.toRealFloat s)
534+{-# DEPRECATED number "Use 'scientific' instead." #-}
548535
549536-- | Parse a scientific number.
550537--
Data/Attoparsec/Number.hs+14−1
@@ -8,9 +8,18 @@
88-- Stability : experimental
99-- Portability : unknown
1010--
11+-- This module is deprecated, and both the module and 'Number' type
12+-- will be removed in the next major release. Use the
13+-- <http://hackage.haskell.org/package/scientific scientific> package
14+-- and the 'Data.Scientific.Scientific' type instead.
15+--
1116-- A simple number type, useful for parsing both exact and inexact
1217-- quantities without losing much precision.
13−module Data.Attoparsec.Number ( Number(..) ) where
18+module Data.Attoparsec.Number
19+ {-# DEPRECATED "This module will be removed in the next major release." #-}
20+ (
21+ Number(..)
22+ ) where
1423
1524import Control.DeepSeq (NFData(rnf))
1625import Data.Data (Data)
@@ -19,9 +28,13 @@ import Data.Typeable (Typeable)
1928
2029-- | A numeric type that can represent integers accurately, and
2130-- floating point numbers to the precision of a 'Double'.
31+--
32+-- /Note/: this type is deprecated, and will be removed in the next
33+-- major release. Use the 'Data.Scientific.Scientific' type instead.
2234data Number = I !Integer
2335 | D {-# UNPACK #-} !Double
2436 deriving (Typeable, Data)
37+{-# DEPRECATED Number "Use Scientific instead." #-}
2538
2639instance Show Number where
2740 show (I a) = show a
Data/Attoparsec/Text.hs+2−14
@@ -1,4 +1,5 @@
11{-# LANGUAGE BangPatterns, FlexibleInstances, TypeSynonymInstances #-}
2+{-# OPTIONS_GHC -fno-warn-warnings-deprecations #-}
23
34-- |
45-- Module : Data.Attoparsec.Text
@@ -361,15 +362,6 @@ rational = scientifically realToFrac
361362--
362363-- The syntax accepted by this parser is the same as for 'rational'.
363364--
364−-- /Note/: This function is almost ten times faster than 'rational',
365−-- but is slightly less accurate.
366−--
367−-- The 'Double' type supports about 16 decimal places of accuracy.
368−-- For 94.2% of numbers, this function and 'rational' give identical
369−-- results, but for the remaining 5.8%, this function loses precision
370−-- around the 15th decimal place. For 0.001% of numbers, this
371−-- function will lose precision at the 13th or 14th decimal place.
372−--
373365-- This function does not accept string representations of \"NaN\" or
374366-- \"Infinity\".
375367double :: Parser Double
@@ -379,11 +371,6 @@ double = scientifically Sci.toRealFloat
379371--
380372-- The syntax accepted by this parser is the same as for 'rational'.
381373--
382−-- /Note/: This function is almost ten times faster than 'rational'.
383−-- On integral inputs, it gives perfectly accurate answers, and on
384−-- floating point inputs, it is slightly less accurate than
385−-- 'rational'.
386−--
387374-- This function does not accept string representations of \"NaN\" or
388375-- \"Infinity\".
389376number :: Parser Number
@@ -393,6 +380,7 @@ number = scientifically $ \s ->
393380 in if e >= 0
394381 then I (c * 10 ^ e)
395382 else D (Sci.toRealFloat s)
383+{-# DEPRECATED number "Use 'scientific' instead." #-}
396384
397385-- | Parse a scientific number.
398386--