packages feed

tools-yj 0.1.0.36 → 0.1.0.37

raw patch · 2 files changed

+45/−1 lines, 2 files

Files

+ src/Data/Word/Adler32.hs view
@@ -0,0 +1,43 @@+{-# LANGUAGE ImportQualifiedPost #-}+{-# LANGUAGE BlockArguments, LambdaCase #-}+{-# LANGUAGE ExplicitForAll #-}+{-# LANGUAGE RequiredTypeArguments #-}+{-# LANGUAGE TypeOperators #-}+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE BangPatterns #-}+{-# OPTIONS_GHC -Wall -fno-warn-tabs #-}++module Data.Word.Adler32 (++	A, fromWord32, toWord32, step, initial++	) where++import Prelude hiding (uncurry)+import Data.Bits+import Data.Word++step :: (Int, A) -> Word8 -> (Int, A)+step (n, A a b) w = case n of+	0 -> (5551, A (( a + fromIntegral w) `mod` 65521) ((b + a + fromIntegral w) `mod` 65521))+	_ -> (n - 1, A (a + fromIntegral w) (b + a + fromIntegral w))++data A = A !Word32 !Word32 deriving (Show, Eq)++initial :: A+initial = A 1 0++fromWord32 :: Word32 -> A+fromWord32 w = A (w .&. 0xffff) (w `shiftR` 16)++toWord32 :: A -> Word32+toWord32 = uncurry (.|.) . first (`mod` 65521) . second ((`shiftL` 16) . (`mod` 65521))++first :: (Word32 -> Word32) -> A -> A+first f (A a b) = A (f a) b++second :: (Word32 -> Word32) -> A -> A+second f (A a b) = A a (f b)++uncurry :: (Word32 -> Word32 -> a) -> A -> a+uncurry f (A a b) = f a b
tools-yj.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack  name:           tools-yj-version:        0.1.0.36+version:        0.1.0.37 synopsis:       Tribial tools description:    Please see the README on GitHub at <https://github.com/YoshikuniJujo/tools-yj#readme> category:       Tools@@ -44,6 +44,7 @@       Data.Sequences.ToolsYj       Data.Text.ToolsYj       Data.Tuple.ToolsYj+      Data.Word.Adler32       Data.Word.Crc32       Text.Show.ToolsYj   other-modules: