hw-int 0.0.1.0 → 0.0.2.0
raw patch · 5 files changed
+275/−7 lines, 5 filesdep ~doctestdep ~hedgehogdep ~hw-hspec-hedgehogPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: doctest, hedgehog, hw-hspec-hedgehog
API changes (from Hackage documentation)
+ HaskellWorks.Data.Int.Narrow: class Narrow a b
+ HaskellWorks.Data.Int.Narrow: instance HaskellWorks.Data.Int.Narrow.Narrow GHC.Int.Int16 GHC.Int.Int16
+ HaskellWorks.Data.Int.Narrow: instance HaskellWorks.Data.Int.Narrow.Narrow GHC.Int.Int16 GHC.Int.Int8
+ HaskellWorks.Data.Int.Narrow: instance HaskellWorks.Data.Int.Narrow.Narrow GHC.Int.Int32 GHC.Int.Int16
+ HaskellWorks.Data.Int.Narrow: instance HaskellWorks.Data.Int.Narrow.Narrow GHC.Int.Int32 GHC.Int.Int32
+ HaskellWorks.Data.Int.Narrow: instance HaskellWorks.Data.Int.Narrow.Narrow GHC.Int.Int32 GHC.Int.Int8
+ HaskellWorks.Data.Int.Narrow: instance HaskellWorks.Data.Int.Narrow.Narrow GHC.Int.Int64 GHC.Int.Int16
+ HaskellWorks.Data.Int.Narrow: instance HaskellWorks.Data.Int.Narrow.Narrow GHC.Int.Int64 GHC.Int.Int32
+ HaskellWorks.Data.Int.Narrow: instance HaskellWorks.Data.Int.Narrow.Narrow GHC.Int.Int64 GHC.Int.Int64
+ HaskellWorks.Data.Int.Narrow: instance HaskellWorks.Data.Int.Narrow.Narrow GHC.Int.Int64 GHC.Int.Int8
+ HaskellWorks.Data.Int.Narrow: instance HaskellWorks.Data.Int.Narrow.Narrow GHC.Int.Int8 GHC.Int.Int8
+ HaskellWorks.Data.Int.Narrow: instance HaskellWorks.Data.Int.Narrow.Narrow GHC.Word.Word16 GHC.Word.Word16
+ HaskellWorks.Data.Int.Narrow: instance HaskellWorks.Data.Int.Narrow.Narrow GHC.Word.Word16 GHC.Word.Word8
+ HaskellWorks.Data.Int.Narrow: instance HaskellWorks.Data.Int.Narrow.Narrow GHC.Word.Word32 GHC.Word.Word16
+ HaskellWorks.Data.Int.Narrow: instance HaskellWorks.Data.Int.Narrow.Narrow GHC.Word.Word32 GHC.Word.Word32
+ HaskellWorks.Data.Int.Narrow: instance HaskellWorks.Data.Int.Narrow.Narrow GHC.Word.Word32 GHC.Word.Word8
+ HaskellWorks.Data.Int.Narrow: instance HaskellWorks.Data.Int.Narrow.Narrow GHC.Word.Word64 GHC.Word.Word16
+ HaskellWorks.Data.Int.Narrow: instance HaskellWorks.Data.Int.Narrow.Narrow GHC.Word.Word64 GHC.Word.Word32
+ HaskellWorks.Data.Int.Narrow: instance HaskellWorks.Data.Int.Narrow.Narrow GHC.Word.Word64 GHC.Word.Word64
+ HaskellWorks.Data.Int.Narrow: instance HaskellWorks.Data.Int.Narrow.Narrow GHC.Word.Word64 GHC.Word.Word8
+ HaskellWorks.Data.Int.Narrow: instance HaskellWorks.Data.Int.Narrow.Narrow GHC.Word.Word8 GHC.Word.Word8
+ HaskellWorks.Data.Int.Narrow: narrow :: Narrow a b => a -> b
+ HaskellWorks.Data.Int.Signed: class Signed a where {
+ HaskellWorks.Data.Int.Signed: instance HaskellWorks.Data.Int.Signed.Signed GHC.Word.Word16
+ HaskellWorks.Data.Int.Signed: instance HaskellWorks.Data.Int.Signed.Signed GHC.Word.Word32
+ HaskellWorks.Data.Int.Signed: instance HaskellWorks.Data.Int.Signed.Signed GHC.Word.Word64
+ HaskellWorks.Data.Int.Signed: instance HaskellWorks.Data.Int.Signed.Signed GHC.Word.Word8
+ HaskellWorks.Data.Int.Signed: signed :: Signed a => a -> SignedOf a
+ HaskellWorks.Data.Int.Signed: type family SignedOf a;
+ HaskellWorks.Data.Int.Signed: }
+ HaskellWorks.Data.Int.Unsigned: class Unsigned a where {
+ HaskellWorks.Data.Int.Unsigned: instance HaskellWorks.Data.Int.Unsigned.Unsigned GHC.Int.Int16
+ HaskellWorks.Data.Int.Unsigned: instance HaskellWorks.Data.Int.Unsigned.Unsigned GHC.Int.Int32
+ HaskellWorks.Data.Int.Unsigned: instance HaskellWorks.Data.Int.Unsigned.Unsigned GHC.Int.Int64
+ HaskellWorks.Data.Int.Unsigned: instance HaskellWorks.Data.Int.Unsigned.Unsigned GHC.Int.Int8
+ HaskellWorks.Data.Int.Unsigned: type family UnsignedOf a;
+ HaskellWorks.Data.Int.Unsigned: unsigned :: Unsigned a => a -> UnsignedOf a
+ HaskellWorks.Data.Int.Unsigned: }
+ HaskellWorks.Data.Int.Widen: class Widen a b
+ HaskellWorks.Data.Int.Widen: instance HaskellWorks.Data.Int.Widen.Widen GHC.Int.Int16 GHC.Int.Int16
+ HaskellWorks.Data.Int.Widen: instance HaskellWorks.Data.Int.Widen.Widen GHC.Int.Int16 GHC.Int.Int32
+ HaskellWorks.Data.Int.Widen: instance HaskellWorks.Data.Int.Widen.Widen GHC.Int.Int16 GHC.Int.Int64
+ HaskellWorks.Data.Int.Widen: instance HaskellWorks.Data.Int.Widen.Widen GHC.Int.Int32 GHC.Int.Int32
+ HaskellWorks.Data.Int.Widen: instance HaskellWorks.Data.Int.Widen.Widen GHC.Int.Int32 GHC.Int.Int64
+ HaskellWorks.Data.Int.Widen: instance HaskellWorks.Data.Int.Widen.Widen GHC.Int.Int64 GHC.Int.Int64
+ HaskellWorks.Data.Int.Widen: instance HaskellWorks.Data.Int.Widen.Widen GHC.Int.Int8 GHC.Int.Int16
+ HaskellWorks.Data.Int.Widen: instance HaskellWorks.Data.Int.Widen.Widen GHC.Int.Int8 GHC.Int.Int32
+ HaskellWorks.Data.Int.Widen: instance HaskellWorks.Data.Int.Widen.Widen GHC.Int.Int8 GHC.Int.Int64
+ HaskellWorks.Data.Int.Widen: instance HaskellWorks.Data.Int.Widen.Widen GHC.Int.Int8 GHC.Int.Int8
+ HaskellWorks.Data.Int.Widen: instance HaskellWorks.Data.Int.Widen.Widen GHC.Word.Word16 GHC.Word.Word16
+ HaskellWorks.Data.Int.Widen: instance HaskellWorks.Data.Int.Widen.Widen GHC.Word.Word16 GHC.Word.Word32
+ HaskellWorks.Data.Int.Widen: instance HaskellWorks.Data.Int.Widen.Widen GHC.Word.Word16 GHC.Word.Word64
+ HaskellWorks.Data.Int.Widen: instance HaskellWorks.Data.Int.Widen.Widen GHC.Word.Word32 GHC.Word.Word32
+ HaskellWorks.Data.Int.Widen: instance HaskellWorks.Data.Int.Widen.Widen GHC.Word.Word32 GHC.Word.Word64
+ HaskellWorks.Data.Int.Widen: instance HaskellWorks.Data.Int.Widen.Widen GHC.Word.Word64 GHC.Word.Word64
+ HaskellWorks.Data.Int.Widen: instance HaskellWorks.Data.Int.Widen.Widen GHC.Word.Word8 GHC.Word.Word16
+ HaskellWorks.Data.Int.Widen: instance HaskellWorks.Data.Int.Widen.Widen GHC.Word.Word8 GHC.Word.Word32
+ HaskellWorks.Data.Int.Widen: instance HaskellWorks.Data.Int.Widen.Widen GHC.Word.Word8 GHC.Word.Word64
+ HaskellWorks.Data.Int.Widen: instance HaskellWorks.Data.Int.Widen.Widen GHC.Word.Word8 GHC.Word.Word8
+ HaskellWorks.Data.Int.Widen: widen :: Widen a b => a -> b
Files
- hw-int.cabal +4/−2
- src/HaskellWorks/Data/Int/Narrow.hs +98/−4
- src/HaskellWorks/Data/Int/Signed.hs +40/−0
- src/HaskellWorks/Data/Int/Unsigned.hs +40/−0
- src/HaskellWorks/Data/Int/Widen.hs +93/−1
hw-int.cabal view
@@ -1,7 +1,7 @@ cabal-version: 2.2 name: hw-int-version: 0.0.1.0+version: 0.0.2.0 synopsis: Additional facilities for Integers description: Additional faciltiies for Integers. Please see README.md category: Data@@ -45,6 +45,8 @@ HaskellWorks.Data.Int.Narrow.Narrow32 HaskellWorks.Data.Int.Narrow.Narrow64 HaskellWorks.Data.Int.Narrow.Narrow8+ HaskellWorks.Data.Int.Signed+ HaskellWorks.Data.Int.Unsigned HaskellWorks.Data.Int.Widen HaskellWorks.Data.Int.Widen.Widen16 HaskellWorks.Data.Int.Widen.Widen32@@ -74,7 +76,7 @@ , hw-int default-language: Haskell2010 type: exitcode-stdio-1.0- ghc-options: -threaded+ ghc-options: -threaded -rtsopts -with-rtsopts=-N main-is: DoctestDriver.hs HS-Source-Dirs: doctest build-tool-depends: doctest-discover:doctest-discover
src/HaskellWorks/Data/Int/Narrow.hs view
@@ -1,8 +1,102 @@+{-# LANGUAGE MultiParamTypeClasses #-}+ module HaskellWorks.Data.Int.Narrow ( module X+ , Narrow(..) ) where -import HaskellWorks.Data.Int.Narrow.Narrow8 as X-import HaskellWorks.Data.Int.Narrow.Narrow16 as X-import HaskellWorks.Data.Int.Narrow.Narrow32 as X-import HaskellWorks.Data.Int.Narrow.Narrow64 as X+import Data.Int+import Data.Word++import HaskellWorks.Data.Int.Narrow.Narrow16 as X+import HaskellWorks.Data.Int.Narrow.Narrow32 as X+import HaskellWorks.Data.Int.Narrow.Narrow64 as X+import HaskellWorks.Data.Int.Narrow.Narrow8 as X++class Narrow a b where+ -- | Cast the value to a smaller size.+ --+ -- If the value does not fit in the smaller size, data will be lost.+ --+ -- This gives a better indication of intent than `Prelude.fromIntegral'.+ narrow :: a -> b++instance Narrow Int8 Int8 where+ narrow = id+ {-# INLINE narrow #-}++instance Narrow Int16 Int8 where+ narrow = fromIntegral+ {-# INLINE narrow #-}++instance Narrow Int32 Int8 where+ narrow = fromIntegral+ {-# INLINE narrow #-}++instance Narrow Int64 Int8 where+ narrow = fromIntegral+ {-# INLINE narrow #-}++instance Narrow Int16 Int16 where+ narrow = fromIntegral+ {-# INLINE narrow #-}++instance Narrow Int32 Int16 where+ narrow = fromIntegral+ {-# INLINE narrow #-}++instance Narrow Int64 Int16 where+ narrow = fromIntegral+ {-# INLINE narrow #-}++instance Narrow Int32 Int32 where+ narrow = fromIntegral+ {-# INLINE narrow #-}++instance Narrow Int64 Int32 where+ narrow = fromIntegral+ {-# INLINE narrow #-}++instance Narrow Int64 Int64 where+ narrow = fromIntegral+ {-# INLINE narrow #-}++instance Narrow Word8 Word8 where+ narrow = id+ {-# INLINE narrow #-}++instance Narrow Word16 Word8 where+ narrow = fromIntegral+ {-# INLINE narrow #-}++instance Narrow Word32 Word8 where+ narrow = fromIntegral+ {-# INLINE narrow #-}++instance Narrow Word64 Word8 where+ narrow = fromIntegral+ {-# INLINE narrow #-}++instance Narrow Word16 Word16 where+ narrow = fromIntegral+ {-# INLINE narrow #-}++instance Narrow Word32 Word16 where+ narrow = fromIntegral+ {-# INLINE narrow #-}++instance Narrow Word64 Word16 where+ narrow = fromIntegral+ {-# INLINE narrow #-}++instance Narrow Word32 Word32 where+ narrow = fromIntegral+ {-# INLINE narrow #-}++instance Narrow Word64 Word32 where+ narrow = fromIntegral+ {-# INLINE narrow #-}++instance Narrow Word64 Word64 where+ narrow = fromIntegral+ {-# INLINE narrow #-}
+ src/HaskellWorks/Data/Int/Signed.hs view
@@ -0,0 +1,40 @@+{-# LANGUAGE TypeFamilies #-}++module HaskellWorks.Data.Int.Signed+ ( Signed(..)+ ) where++import Data.Int+import Data.Word++class Signed a where+ type SignedOf a++ -- | Cast the value to a larger size.+ --+ -- This is safer to use than 'Prelude.fromIntegral'.+ signed :: a -> SignedOf a++instance Signed Word8 where+ type SignedOf Word8 = Int8++ signed = fromIntegral+ {-# INLINE signed #-}++instance Signed Word16 where+ type SignedOf Word16 = Int16++ signed = fromIntegral+ {-# INLINE signed #-}++instance Signed Word32 where+ type SignedOf Word32 = Int32++ signed = fromIntegral+ {-# INLINE signed #-}++instance Signed Word64 where+ type SignedOf Word64 = Int64++ signed = fromIntegral+ {-# INLINE signed #-}
+ src/HaskellWorks/Data/Int/Unsigned.hs view
@@ -0,0 +1,40 @@+{-# LANGUAGE TypeFamilies #-}++module HaskellWorks.Data.Int.Unsigned+ ( Unsigned(..)+ ) where++import Data.Int+import Data.Word++class Unsigned a where+ type UnsignedOf a++ -- | Cast the value to a larger size.+ --+ -- This is safer to use than 'Prelude.fromIntegral'.+ unsigned :: a -> UnsignedOf a++instance Unsigned Int8 where+ type UnsignedOf Int8 = Word8++ unsigned = fromIntegral+ {-# INLINE unsigned #-}++instance Unsigned Int16 where+ type UnsignedOf Int16 = Word16++ unsigned = fromIntegral+ {-# INLINE unsigned #-}++instance Unsigned Int32 where+ type UnsignedOf Int32 = Word32++ unsigned = fromIntegral+ {-# INLINE unsigned #-}++instance Unsigned Int64 where+ type UnsignedOf Int64 = Word64++ unsigned = fromIntegral+ {-# INLINE unsigned #-}
src/HaskellWorks/Data/Int/Widen.hs view
@@ -1,8 +1,100 @@+{-# LANGUAGE MultiParamTypeClasses #-}+ module HaskellWorks.Data.Int.Widen ( module X+ , Widen(..) ) where -import HaskellWorks.Data.Int.Widen.Widen8 as X+import Data.Int+import Data.Word+ import HaskellWorks.Data.Int.Widen.Widen16 as X import HaskellWorks.Data.Int.Widen.Widen32 as X import HaskellWorks.Data.Int.Widen.Widen64 as X+import HaskellWorks.Data.Int.Widen.Widen8 as X++class Widen a b where+ -- | Cast the value to a larger size.+ --+ -- This is safer to use than 'Prelude.fromIntegral'.+ widen :: a -> b++instance Widen Int8 Int8 where+ widen = id+ {-# INLINE widen #-}++instance Widen Int8 Int16 where+ widen = fromIntegral+ {-# INLINE widen #-}++instance Widen Int8 Int32 where+ widen = fromIntegral+ {-# INLINE widen #-}++instance Widen Int8 Int64 where+ widen = fromIntegral+ {-# INLINE widen #-}++instance Widen Int16 Int16 where+ widen = fromIntegral+ {-# INLINE widen #-}++instance Widen Int16 Int32 where+ widen = fromIntegral+ {-# INLINE widen #-}++instance Widen Int16 Int64 where+ widen = fromIntegral+ {-# INLINE widen #-}++instance Widen Int32 Int32 where+ widen = fromIntegral+ {-# INLINE widen #-}++instance Widen Int32 Int64 where+ widen = fromIntegral+ {-# INLINE widen #-}++instance Widen Int64 Int64 where+ widen = fromIntegral+ {-# INLINE widen #-}++instance Widen Word8 Word8 where+ widen = id+ {-# INLINE widen #-}++instance Widen Word8 Word16 where+ widen = fromIntegral+ {-# INLINE widen #-}++instance Widen Word8 Word32 where+ widen = fromIntegral+ {-# INLINE widen #-}++instance Widen Word8 Word64 where+ widen = fromIntegral+ {-# INLINE widen #-}++instance Widen Word16 Word16 where+ widen = fromIntegral+ {-# INLINE widen #-}++instance Widen Word16 Word32 where+ widen = fromIntegral+ {-# INLINE widen #-}++instance Widen Word16 Word64 where+ widen = fromIntegral+ {-# INLINE widen #-}++instance Widen Word32 Word32 where+ widen = fromIntegral+ {-# INLINE widen #-}++instance Widen Word32 Word64 where+ widen = fromIntegral+ {-# INLINE widen #-}++instance Widen Word64 Word64 where+ widen = fromIntegral+ {-# INLINE widen #-}