packages feed

digit 0.7 → 0.15

raw patch · 5 files changed

Files

LICENCE view
@@ -1,6 +1,7 @@ Copyright (C) 2010-2016 NICTA Limited-Copyright (c) 2017, Commonwealth Scientific and Industrial Research Organisation+Copyright (c) 2017-2018, Commonwealth Scientific and Industrial Research Organisation (CSIRO) ABN 41 687 119 230.+Copyright (c) 2019-2020, System F (System F Aerial Operations) ABN 19 363 313 255  All rights reserved. @@ -15,7 +16,7 @@       disclaimer in the documentation and/or other materials provided       with the distribution. -    * Neither the name of QFPL nor the names of other+    * Neither the name of System F nor the names of other       contributors may be used to endorse or promote products derived       from this software without specific prior written permission. 
changelog.md view
@@ -1,3 +1,31 @@+0.15++* Widen version bounds.++0.14++* Fix export for `DecDigitNoZero`.++0.13++* Make `DecDigitNoZero` data type.++0.12++* Fix bug in functions that produce Integral values.++0.11++* Update `lens` to support `< 5.2`++0.9++* Update base version.++0.8++* Add decimal arithmetic+ 0.6  * Removed the `Digit` datatype
digit.cabal view
@@ -1,40 +1,41 @@ name:               digit-version:            0.7+version:            0.15 license:            BSD3 license-file:       LICENCE-author:             Queensland Functional Programming Lab <oᴉ˙ldɟb@llǝʞsɐɥ>-maintainer:         Queensland Functional Programming Lab <oᴉ˙ldɟb@llǝʞsɐɥ>-copyright:          Copyright (C) 2010-2016 NICTA Limited-                    Copyright (c) 2017, Commonwealth Scientific and Industrial Research Organisation (CSIRO) ABN 41 687 119 230.+author:             System F <nɐ˙ɯoɔ˙ɟɯǝʇsʎs@ǝpoɔ>+maintainer:         System F <nɐ˙ɯoɔ˙ɟɯǝʇsʎs@ǝpoɔ>+copyright:          Copyright (c) 2010-2016 NICTA Limited+                    Copyright (c) 2017-2018, Commonwealth Scientific and Industrial Research Organisation (CSIRO) ABN 41 687 119 230.+                    Copyright (c) System F (System F Aerial Operations) 2019-2020 synopsis:           A data-type representing digits 0-9 and other combinations category:           Data-homepage:           https://github.com/qfpl/digit-bug-reports:        https://github.com/qfpl/digit/issues+homepage:           https://github.com/system-f/digit+bug-reports:        https://github.com/system-f/digit/issues 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 == 9.8.1, GHC == 9.6.3, GHC == 9.4.7, GHC == 9.0.2, 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>>+  <<https://system-f.gitlab.io/logo/systemf-450x450.jpg>>   .   @Digit@ is a data-type that represents the digits 0-9 and other combinations.  source-repository   head   type:             git-  location:         git@github.com:qfpl/digit.git+  location:         git@github.com:system-f/digit.git  library   default-language:                     Haskell2010    build-depends:-                    base               >= 4.7 && < 5-                    , lens             >= 4.0 && < 5-                    , parsers          >= 0.12.3 && < 0.13+                    base               >= 4.8 && < 6+                    , lens             >= 4.0 && < 6+                    , parsers          >= 0.12.3 && < 1                     , semigroups       >= 0.12 && < 1.0                     , template-haskell >= 2.8 && < 3-                    , semigroupoids    >= 5 && < 6-                    , scientific       >= 0.3 && < 0.4+                    , semigroupoids    >= 5 && < 7+                    , scientific       >= 0.3 && < 1    ghc-options:                     -Wall@@ -87,17 +88,17 @@                     Haskell2010    build-depends:-                    base             >=4.8    && <4.12-                    , lens           >=4.0    && <5+                    base             >=4.8    && <4.13+                    , lens           >=4.0    && <5.2                     , 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/Decimal.hs view
@@ -4,6 +4,7 @@  module Data.Digit.Decimal(   DecDigit(..)+, DecDigitNoZero(..) , DecimalNoZero , Decimal , parseDecimalNoZero@@ -73,6 +74,30 @@ instance D7 DecDigit where; d7 = _DecDigit7 instance D8 DecDigit where; d8 = _DecDigit8 instance D9 DecDigit where; d9 = _DecDigit9++data DecDigitNoZero =+  DecDigitNoZero1+  | DecDigitNoZero2+  | DecDigitNoZero3+  | DecDigitNoZero4+  | DecDigitNoZero5+  | DecDigitNoZero6+  | DecDigitNoZero7+  | DecDigitNoZero8+  | DecDigitNoZero9+  deriving (Show, Eq, Ord, Enum, Bounded)++makePrisms ''DecDigitNoZero++instance D1 DecDigitNoZero where; d1 = _DecDigitNoZero1+instance D2 DecDigitNoZero where; d2 = _DecDigitNoZero2+instance D3 DecDigitNoZero where; d3 = _DecDigitNoZero3+instance D4 DecDigitNoZero where; d4 = _DecDigitNoZero4+instance D5 DecDigitNoZero where; d5 = _DecDigitNoZero5+instance D6 DecDigitNoZero where; d6 = _DecDigitNoZero6+instance D7 DecDigitNoZero where; d7 = _DecDigitNoZero7+instance D8 DecDigitNoZero where; d8 = _DecDigitNoZero8+instance D9 DecDigitNoZero where; d9 = _DecDigitNoZero9  type DecimalNoZero d =   (D1 d, D2 d, D3 d, D4 d, D5 d, D6 d, D7 d, D8 d, D9 d)
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@@ -122,12 +128,12 @@ -- 0 -- -- >>> binDigitsIntegral (Left (BinDigit0 :| [])) :: Int--- -1+-- 0 -- -- >>> binDigitsIntegral (Left (BinDigit1 :| [BinDigit1])) :: Int--- -4+-- -3 binDigitsIntegral :: Integral a => Either (NonEmpty BinDigit) (NonEmpty BinDigit) -> a-binDigitsIntegral = either (\n -> -(go n) - 1) go+binDigitsIntegral = either (\n -> -(go n)) go   where     go = foldl' (\b a -> (integralBinary # a) + 2 * b) 0 @@ -193,12 +199,12 @@ -- 0 -- -- >>> octDigitsIntegral (Left (OctDigit0 :| [])) :: Int--- -1+-- 0 -- -- >>> octDigitsIntegral (Left (OctDigit7 :| [OctDigit7])) :: Int--- -64+-- -63 octDigitsIntegral :: Integral a => Either (NonEmpty OctDigit) (NonEmpty OctDigit) -> a-octDigitsIntegral = either (\n -> -(go n) - 1) go+octDigitsIntegral = either (\n -> -(go n)) go   where     go = foldl' (\b a -> (integralOctal # a) + 8 * b) 0 @@ -262,12 +268,12 @@ -- 0 -- -- >>> decDigitsIntegral (Left (DecDigit0 :| [])) :: Int--- -1+-- 0 -- -- >>> decDigitsIntegral (Left (DecDigit9 :| [DecDigit9])) :: Int--- -100+-- -9 decDigitsIntegral :: Integral a => Either (NonEmpty DecDigit) (NonEmpty DecDigit) -> a-decDigitsIntegral = either (\n -> -(go n) - 1) go+decDigitsIntegral = either (\n -> -(go n)) go   where     go = foldl' (\b a -> (integralDecimal # a) + 10 * b) 0 @@ -333,12 +339,12 @@ -- 0 -- -- >>> hexDigitsIntegral (Left (HexDigit0 :| [])) :: Int--- -1+-- 0 -- -- >>> hexDigitsIntegral (Left (HexDigitf :| [HexDigitf])) :: Int--- -256+-- -255 hexDigitsIntegral :: Integral a => Either (NonEmpty HexDigit) (NonEmpty HexDigit) -> a-hexDigitsIntegral = either (\n -> -(go n) - 1) go+hexDigitsIntegral = either (\n -> -(go n)) go   where     go = foldl' (\b a -> (integralHexadecimal # a) + 16 * b) 0 @@ -398,19 +404,19 @@         (if q == 0 then id else go q) . ((r ^?! integralHEXADECIMAL) :)  -- |--- >>> HEXDigitsIntegral (Right (HEXDigit1 :| [HEXDigit0, HEXDigit0])) :: Int+-- >>> _HEXDigitsIntegral (Right (HEXDigit1 :| [HEXDigit0, HEXDigit0])) :: Int -- 256 ----- >>> HEXDigitsIntegral (Right (HEXDigit0 :| [])) :: Int+-- >>> _HEXDigitsIntegral (Right (HEXDigit0 :| [])) :: Int -- 0 ----- >>> HEXDigitsIntegral (Left (HEXDigit0 :| [])) :: Int--- -1+-- >>> _HEXDigitsIntegral (Left (HEXDigit0 :| [])) :: Int+-- 0 ----- >>> HEXDigitsIntegral (Left (HEXDigitF :| [HEXDigitF])) :: Int--- -256+-- >>> _HEXDigitsIntegral (Left (HEXDigitF :| [HEXDigitF])) :: Int+-- -255 _HEXDigitsIntegral :: Integral a => Either (NonEmpty HEXDigit) (NonEmpty HEXDigit) -> a-_HEXDigitsIntegral = either (\n -> -(go n) - 1) go+_HEXDigitsIntegral = either (\n -> -(go n)) go   where     go = foldl' (\b a -> (integralHEXADECIMAL # a) + 16 * b) 0 @@ -490,21 +496,45 @@      error "incomplete pattern")  -- |--- >>> HeXDigitsIntegral (Right (HeXDigit1 :| [HeXDigit0, HeXDigit0])) :: Int+-- >>> _HeXDigitsIntegral (Right (HeXDigit1 :| [HeXDigit0, HeXDigit0])) :: Int -- 256 ----- >>> HeXDigitsIntegral (Right (HeXDigit0 :| [])) :: Int+-- >>> _HeXDigitsIntegral (Right (HeXDigit0 :| [])) :: Int -- 0 ----- >>> HeXDigitsIntegral (Left (HeXDigit0 :| [])) :: Int--- -1+-- >>> _HeXDigitsIntegral (Left (HeXDigit0 :| [])) :: Int+-- 0 ----- >>> HeXDigitsIntegral (Left (HeXDigitF :| [HeXDigitF])) :: Int--- -256+-- >>> _HeXDigitsIntegral (Left (HeXDigitF :| [HeXDigitF])) :: Int+-- -255 _HeXDigitsIntegral :: Integral a => Either (NonEmpty HeXDigit) (NonEmpty HeXDigit) -> a-_HeXDigitsIntegral = either (\n -> -(go n) - 1) go+_HeXDigitsIntegral = either (\n -> -(go n)) 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 ::