tools-yj 0.1.0.42 → 0.1.0.43
raw patch · 2 files changed
+61/−1 lines, 2 filesPVP: minor bump suggested
API additions: PVP suggests at least a minor version bump
API changes (from Hackage documentation)
+ Data.Word.ToolsYj: data Word4
+ Data.Word.ToolsYj: instance GHC.Bits.Bits Data.Word.ToolsYj.Word4
+ Data.Word.ToolsYj: instance GHC.Bits.FiniteBits Data.Word.ToolsYj.Word4
+ Data.Word.ToolsYj: instance GHC.Classes.Eq Data.Word.ToolsYj.Word4
+ Data.Word.ToolsYj: instance GHC.Classes.Ord Data.Word.ToolsYj.Word4
+ Data.Word.ToolsYj: instance GHC.Enum.Bounded Data.Word.ToolsYj.Word4
+ Data.Word.ToolsYj: instance GHC.Enum.Enum Data.Word.ToolsYj.Word4
+ Data.Word.ToolsYj: instance GHC.Num.Num Data.Word.ToolsYj.Word4
+ Data.Word.ToolsYj: instance GHC.Real.Integral Data.Word.ToolsYj.Word4
+ Data.Word.ToolsYj: instance GHC.Real.Real Data.Word.ToolsYj.Word4
Files
- src/Data/Word/ToolsYj.hs +59/−0
- tools-yj.cabal +2/−1
+ src/Data/Word/ToolsYj.hs view
@@ -0,0 +1,59 @@+{-# OPTIONS_GHC -Wall -fno-warn-tabs #-}++module Data.Word.ToolsYj (++ Word4++ ) where++import Control.Arrow+import Data.Bits+import Data.Word++newtype Word4 = Word4_ { unWord4 :: Word8 }++instance Bits Word4 where+ Word4_ w1 .&. Word4_ w2 = Word4_ $ w1 .&. w2+ Word4_ w1 .|. Word4_ w2 = Word4_ $ w1 .|. w2+ Word4_ w1 `xor` Word4_ w2 = Word4_ $ w1 `xor` w2+ complement = Word4_ . (.&. 0xf) . complement . unWord4+ shift (Word4_ w) i = Word4_ . (.&. 0xf) $ shift w i+ rotate (Word4_ w) i = Word4_ $ shiftR w' 4 .|. (w' .&. 0xf)+ where+ w' = (`rotate` i) $ (.&. 0xf) w+ bitSize _ = 4; bitSizeMaybe _ = Just 4; isSigned _ = False+ Word4_ w `testBit` i = w `testBit` i+ bit i = Word4_ . (.&. 0xf) $ bit i+ popCount (Word4_ w) = popCount $ (.&. 0xf) w++instance FiniteBits Word4 where+ finiteBitSize _ = 4++instance Bounded Word4 where minBound = 0; maxBound = 0xf++instance Enum Word4 where+ toEnum i+ | 0 <= i && i <= 0xf = fromIntegral i+ | otherwise = error $+ "Enum.toEnum{Word4}: tag " +++ show i ++ " is outside of bounds (0,15)"+ fromEnum = fromIntegral++instance Num Word4 where+ Word4_ w1 + Word4_ w2 = Word4_ . (.&. 0xf) $ w1 + w2+ Word4_ w1 * Word4_ w2 = Word4_ . (.&. 0xf) $ w1 * w2+ abs = id+ signum _ = 1+ negate = Word4_ . (.&. 0xf) . negate . unWord4+ fromInteger = Word4_ . (.&. 0xf) . fromInteger++instance Real Word4 where+ toRational = toRational . (.&. 0xf) . unWord4++instance Integral Word4 where+ toInteger = toInteger . (.&. 0xf) . unWord4+ Word4_ w1 `quotRem` Word4_ w2 =+ (Word4_ . (.&. 0xf) *** Word4_ . (.&. 0xf)) $ w1 `quotRem` w2++instance Eq Word4 where Word4_ w1 == Word4_ w2 = (w1 .&. 0xf) == (w2 .&. 0xf)+instance Ord Word4 where Word4_ w1 <= Word4_ w2 = (.&. 0xf) w1 <= (.&. 0xf) w2
tools-yj.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack name: tools-yj-version: 0.1.0.42+version: 0.1.0.43 synopsis: Tribial tools description: Please see the README on GitHub at <https://github.com/YoshikuniJujo/tools-yj#readme> category: Tools@@ -46,6 +46,7 @@ Data.Tuple.ToolsYj Data.Word.Adler32 Data.Word.Crc32+ Data.Word.ToolsYj Foreign.C.ByteArray Text.Show.ToolsYj other-modules: