digit 0.7 → 0.8
raw patch · 3 files changed
+44/−10 lines, 3 filesdep ~basedep ~hedgehogdep ~tastyPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: base, hedgehog, tasty, tasty-hedgehog
API changes (from Hackage documentation)
+ Data.Digit.Integral: addDecDigit :: DecDigit -> DecDigit -> (Bool, DecDigit)
+ Data.Digit.Integral: addDecDigit' :: DecDigit -> DecDigit -> (DecDigit, DecDigit)
+ Data.Digit.Integral: mod10 :: Integral a => a -> DecDigit
Files
- changelog.md +4/−0
- digit.cabal +7/−7
- src/Data/Digit/Integral.hs +33/−3
changelog.md view
@@ -1,3 +1,7 @@+0.8++* Add decimal arithmetic+ 0.6 * Removed the `Digit` datatype
digit.cabal view
@@ -1,5 +1,5 @@ name: digit-version: 0.7+version: 0.8 license: BSD3 license-file: LICENCE author: Queensland Functional Programming Lab <oᴉ˙ldɟb@llǝʞsɐɥ>@@ -13,7 +13,7 @@ cabal-version: >= 1.10 build-type: Simple extra-source-files: CONTRIBUTORS, changelog.md-tested-with: GHC == 8.4.1, GHC == 8.2.2, GHC == 8.0.2, GHC == 7.10.3+tested-with: GHC == 8.6.1, GHC == 8.4.3, GHC == 8.2.2, GHC == 8.0.2, GHC == 7.10.3 description: <<http://i.imgur.com/uZnp9ke.png>> .@@ -28,7 +28,7 @@ Haskell2010 build-depends:- base >= 4.7 && < 5+ base >= 4.8 && < 4.13 , lens >= 4.0 && < 5 , parsers >= 0.12.3 && < 0.13 , semigroups >= 0.12 && < 1.0@@ -87,17 +87,17 @@ Haskell2010 build-depends:- base >=4.8 && <4.12+ base >=4.8 && <4.13 , lens >=4.0 && <5 , ansi-wl-pprint >=0.6 && <0.7- , hedgehog >=0.5 && <0.7- , tasty >=0.11 && <1.2+ , hedgehog >=0.5 && <1.1+ , tasty >=0.11 && <1.3 , tasty-hspec >=1.1 && <1.2 , parsec >=3.1 && <3.2 , parsers >=0.12.3 && <0.13 , pretty >=1.1 && <1.2 , text >=1.2 && <1.3- , tasty-hedgehog >=0.1 && <0.3+ , tasty-hedgehog >=0.1 && <1.1 , tasty-hunit >=0.9 && <0.11 , semigroups >= 0.12 && < 1.0 , digit
src/Data/Digit/Integral.hs view
@@ -30,24 +30,30 @@ , integralHeXaDeCiMaLNoZero , integralHeXaDeCiMaL , _HeXDigitsIntegral+, mod10+, addDecDigit+, addDecDigit' ) where import Prelude (Eq, Integral, error, fst, lookup,- quotRem, (*), (+), (-), (==), (>=))+ quotRem, (*), (+), (-), (==), (>=), mod, divMod) import Control.Applicative (Applicative) import Control.Category (id, (.)) import Control.Lens (APrism, Choice, Prism', Review,- clonePrism, outside, prism', unto,- ( # ), (.~), (^?!))+ clonePrism, outside, prism', unto, over, _1,+ ( # ), (.~), (^?!), (^?)) import Control.Lens.Extras (is) +import Data.Bool (Bool, bool) import Data.Either (Either (..), either) import Data.Foldable (find, foldl') import Data.Function (($),const) import Data.Functor ((<$>))+import Data.Int (Int) import Data.List.NonEmpty (NonEmpty) import Data.Maybe (fromMaybe)+import Data.Ord ((>)) import Data.Digit.Binary import Data.Digit.Decimal@@ -505,6 +511,30 @@ _HeXDigitsIntegral = either (\n -> -(go n) - 1) go where go = foldl' (\b a -> (integralHeXaDeCiMaL # a) + 16 * b) 0++mod10 ::+ Integral a =>+ a+ -> DecDigit+mod10 n =+ let r = n `mod` 10+ in fromMaybe (mod10 r) (r ^? integralDecimal)++addDecDigit ::+ DecDigit+ -> DecDigit+ -> (Bool, DecDigit)+addDecDigit a b =+ let (x, r) =+ (integralDecimal # a + integralDecimal # b) `divMod` 10+ in (x > 0, mod10 (r :: Int))++addDecDigit' ::+ DecDigit+ -> DecDigit+ -> (DecDigit, DecDigit)+addDecDigit' a b =+ over _1 (bool x0 x1) (addDecDigit a b) ---- not exported associatePrism ::