scientific 0.3.4.15 → 0.3.5.0
raw patch · 3 files changed
+33/−3 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Data.Scientific: scientificP :: ReadP Scientific
Files
- changelog +4/−0
- scientific.cabal +2/−2
- src/Data/Scientific.hs +27/−1
changelog view
@@ -1,3 +1,7 @@+0.3.5.0+ * Export scientificP :: ReadP Scientific+ (Courtesy of Shlok Datye @shlok)+ 0.3.4.15 * Fix build for base < 4.8.
scientific.cabal view
@@ -1,5 +1,5 @@ name: scientific-version: 0.3.4.15+version: 0.3.5.0 synopsis: Numbers represented using scientific notation description: @Data.Scientific@ provides the number type 'Scientific'. Scientific numbers are@@ -106,7 +106,7 @@ , tasty-smallcheck >= 0.2 && < 0.9 , tasty-quickcheck >= 0.8 && < 0.9 , smallcheck >= 1.0 && < 1.2- , QuickCheck >= 2.5 && < 2.10+ , QuickCheck >= 2.5 && < 2.11 , text >= 0.8 && < 1.3 if flag(bytestring-builder)
src/Data/Scientific.hs view
@@ -74,6 +74,9 @@ , toBoundedInteger , fromFloatDigits + -- * Parsing+ , scientificP+ -- * Pretty printing , formatScientific , FPFormat(..)@@ -104,7 +107,7 @@ import Data.Typeable (Typeable) import qualified Data.Vector as V import qualified Data.Vector.Mutable as VM-import Data.Word (Word, Word8, Word16, Word32, Word64)+import Data.Word (Word8, Word16, Word32, Word64) import Math.NumberTheory.Logarithms (integerLog10') import qualified Numeric (floatToDigits) import qualified Text.Read as Read@@ -116,6 +119,7 @@ #if !MIN_VERSION_base(4,8,0) import Data.Functor ((<$>))+import Data.Word (Word) import Control.Applicative ((<*>)) #endif @@ -786,12 +790,34 @@ -- Parsing ---------------------------------------------------------------------- +-- | Supports the skipping of parentheses and whitespaces. Example:+--+-- > > read " ( (( -1.0e+3 ) ))" :: Scientific+-- > -1000.0+--+-- (Note: This @Read@ instance makes internal use of+-- 'scientificP' to parse the floating-point number.) instance Read Scientific where readPrec = Read.parens $ ReadPrec.lift (ReadP.skipSpaces >> scientificP) -- A strict pair data SP = SP !Integer {-# UNPACK #-}!Int +-- | A parser for parsing a floating-point+-- number into a 'Scientific' value. Example:+--+-- > > import Text.ParserCombinators.ReadP (readP_to_S)+-- > > readP_to_S scientificP "3"+-- > [(3.0,"")]+-- > > readP_to_S scientificP "3.0e2"+-- > [(3.0,"e2"),(300.0,"")]+-- > > readP_to_S scientificP "+3.0e+2"+-- > [(3.0,"e+2"),(300.0,"")]+-- > > readP_to_S scientificP "-3.0e-2"+-- > [(-3.0,"e-2"),(-3.0e-2,"")]+--+-- Note: This parser only parses the number itself; it does+-- not parse any surrounding parentheses or whitespaces. scientificP :: ReadP Scientific scientificP = do let positive = (('+' ==) <$> ReadP.satisfy isSign) `mplus` return True