nats 1.1 → 1.1.1
raw patch · 3 files changed
+12/−7 lines, 3 filesdep ~binarynew-uploader
Dependency ranges changed: binary
Files
- CHANGELOG.markdown +5/−0
- nats.cabal +2/−2
- src/Numeric/Natural.hs +5/−5
CHANGELOG.markdown view
@@ -1,3 +1,8 @@+1.1.1+-----+* Backported a more efficient `Binary` instance for `Nat`+* Allow `binary-0.8`+ 1.1 --- * Backported `Lift` instances.
nats.cabal view
@@ -1,6 +1,6 @@ name: nats category: Numeric, Algebra-version: 1.1+version: 1.1.1 license: BSD3 cabal-version: >= 1.10 license-file: LICENSE@@ -71,7 +71,7 @@ build-depends: base >= 2 && < 5 if flag(binary)- build-depends: binary >= 0.2 && < 0.8+ build-depends: binary >= 0.2 && < 0.9 if flag(template-haskell) build-depends: template-haskell >= 2.2 && < 2.12
src/Numeric/Natural.hs view
@@ -39,7 +39,7 @@ #ifdef MIN_VERSION_binary import Control.Monad (liftM) import Data.Binary (Binary(..), Get, Word8, Word64, putWord8)-import Data.List (unfoldr)+import Data.List (foldl', unfoldr) #endif import Data.Bits@@ -234,16 +234,16 @@ -- -- Fold and unfold an Integer to and from a list of its bytes ---unroll :: (Integral a, Num a, Bits a) => a -> [Word8]+unroll :: (Integral a, Bits a) => a -> [Word8] unroll = unfoldr step where step 0 = Nothing step i = Just (fromIntegral i, i `shiftR` 8) -roll :: (Integral a, Num a, Bits a) => [Word8] -> a-roll = foldr unstep 0+roll :: (Integral a, Bits a) => [Word8] -> a+roll = foldl' unstep 0 . reverse where- unstep b a = a `shiftL` 8 .|. fromIntegral b+ unstep a b = a `shiftL` 8 .|. fromIntegral b -- Fixed-size type for a subset of Natural type NaturalWord = Word64