scientific-notation 0.1.1.0 → 0.1.2.0
raw patch · 3 files changed
+33/−4 lines, 3 filesdep +bytebuilddep +natural-arithmeticdep ~QuickCheckdep ~tastydep ~tasty-hunitPVP ok
version bump matches the API change (PVP)
Dependencies added: bytebuild, natural-arithmetic
Dependency ranges changed: QuickCheck, tasty, tasty-hunit
API changes (from Hackage documentation)
+ Data.Number.Scientific: builderUtf8 :: Scientific -> Builder
Files
- CHANGELOG.md +4/−0
- scientific-notation.cabal +7/−4
- src/Data/Number/Scientific.hs +22/−0
CHANGELOG.md view
@@ -1,5 +1,9 @@ # Revision history for scientific-notation +## 0.1.2.0 -- 2020-05-01++* Add `builderUtf8`.+ ## 0.1.1.0 -- 2019-11-06 * Add `withExposed`.
scientific-notation.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.2 name: scientific-notation-version: 0.1.1.0+version: 0.1.2.0 synopsis: Scientific notation intended for tokenization description: This library provides a type used to represent a number in@@ -49,7 +49,9 @@ exposed-modules: Data.Number.Scientific build-depends: , base >=4.12 && <5+ , bytebuild >=0.3.5 && <0.4 , bytesmith >=0.3 && <0.4+ , natural-arithmetic >=0.1.1 && <0.2 hs-source-dirs: src ghc-options: -O2 -Wall default-language: Haskell2010@@ -61,13 +63,14 @@ main-is: Main.hs ghc-options: -Wall -O2 build-depends:- , QuickCheck >=2.13.1 && <2.14+ , QuickCheck >=2.13.1 , base >=4.12.0.0 && <5+ , bytebuild , byteslice , bytestring , scientific-notation- , tasty >=1.2.3 && <1.3- , tasty-hunit >=0.10.0.2 && <0.11+ , tasty >=1.2.3+ , tasty-hunit >=0.10.0.2 , tasty-quickcheck , primitive , bytesmith
src/Data/Number/Scientific.hs view
@@ -33,6 +33,8 @@ , parserUnsignedUtf8Bytes# , parserNegatedUtf8Bytes# , parserNegatedTrailingUtf8Bytes#+ -- * Encode+ , builderUtf8 ) where import Prelude hiding (negate)@@ -40,10 +42,14 @@ import GHC.Exts (Int#,Word#,Int(I#),(+#)) import GHC.Word (Word(W#),Word8(W8#),Word16(W16#),Word32(W32#),Word64(W64#)) import GHC.Int (Int64(I64#),Int32(I32#))+import Data.Bytes.Builder (Builder) import Data.Bytes.Parser.Unsafe (Parser(..)) import Data.Fixed (Fixed(MkFixed),HasResolution) +import qualified Arithmetic.Nat as Nat import qualified Data.Fixed as Fixed+import qualified Data.Bytes.Builder as Builder+import qualified Data.Bytes.Builder.Bounded as BB import qualified Data.Bytes.Parser as Parser import qualified Data.Bytes.Parser.Latin as Latin import qualified Data.Bytes.Parser.Unsafe as Unsafe@@ -848,3 +854,19 @@ (# | (# y, b, c #) #) -> runParser (g y) (# arr, b, c #) s1 )++builderUtf8 :: Scientific -> Builder+builderUtf8 (Scientific coeff e big)+ | e == 0 = Builder.intDec coeff+ | e == minBound = let LargeScientific coeff' e' = big in+ Builder.integerDec coeff'+ <>+ Builder.ascii 'e'+ <>+ Builder.integerDec e'+ | otherwise = Builder.fromBounded Nat.constant $+ BB.intDec coeff+ `BB.append`+ BB.ascii 'e'+ `BB.append`+ BB.intDec e