From 2984c6560b9d9b7d0b148989a1b91a7c4cbd701c Mon Sep 17 00:00:00 2001 From: Herbert Valerio Riedel Date: Sat, 1 Mar 2014 15:25:00 +0100 Subject: [PATCH] Minor improvements and fixes - bump to 0.1.1.0 - add changelog.md - Fix `intCastIso` to be reflexive wrt non-fixed integer types - Simplified `IsIntBaseTypeEq` equations - Add `Data.Type.Equality.(==)` instance for `IntBaseTypeK` --- Data/IntCast.hs | 15 +++++++-------- changelog.md | 11 +++++++++++ int-cast.cabal | 8 +++++--- 3 files changed, 23 insertions(+), 11 deletions(-) create mode 100644 changelog.md diff --git a/Data/IntCast.hs b/Data/IntCast.hs index f5d71ca..cc9b6c6 100644 --- a/Data/IntCast.hs +++ b/Data/IntCast.hs @@ -57,6 +57,7 @@ import Foreign.C.Types -- non-Haskell 2010 import GHC.TypeLits import Data.Bits +import Data.Type.Equality -- | (Kind) Meta-information about integral types. -- @@ -164,23 +165,21 @@ type IsIntSubType a b = IsIntBaseSubType (IntBaseType a) (IntBaseType b) -- Same bit-size predicate type family IsIntBaseTypeIso a b :: Bool where - IsIntBaseTypeIso (FixedIntTag n) (FixedIntTag n) = True + IsIntBaseTypeIso a a = True IsIntBaseTypeIso (FixedIntTag n) (FixedWordTag n) = True IsIntBaseTypeIso (FixedWordTag n) (FixedIntTag n) = True - IsIntBaseTypeIso (FixedWordTag n) (FixedWordTag n) = True IsIntBaseTypeIso a b = False type IsIntTypeIso a b = IsIntBaseTypeIso (IntBaseType a) (IntBaseType b) -type family IsIntBaseTypeEq a b :: Bool where - IsIntBaseTypeEq (FixedIntTag n) (FixedIntTag n) = True - IsIntBaseTypeEq (FixedWordTag n) (FixedWordTag n) = True - IsIntBaseTypeEq BigIntTag BigIntTag = True - IsIntBaseTypeEq BigWordTag BigWordTag = True - IsIntBaseTypeEq a b = False +type family IsIntBaseTypeEq (a :: IntBaseTypeK) (b :: IntBaseTypeK) :: Bool where + IsIntBaseTypeEq a a = True + IsIntBaseTypeEq a b = False type IsIntTypeEq a b = IsIntBaseTypeEq (IntBaseType a) (IntBaseType b) +type instance a == b = IsIntBaseTypeEq a b + -- | Statically checked integer conversion which satisfies the property -- -- * @'toInteger' ≡ 'toInteger' . intCast@ diff --git a/changelog.md b/changelog.md new file mode 100644 index 0000000..0328802 --- /dev/null +++ b/changelog.md @@ -0,0 +1,11 @@ +## 0.1.1.0 + + * Fix `intCastIso` to be reflexive wrt non-fixed integer types + + * Simplified `IsIntBaseTypeEq` equations + + * Add `Data.Type.Equality.(==)` instance for `IntBaseTypeK` + +## 0.1.0.0 + + * initial release diff --git a/int-cast.cabal b/int-cast.cabal index a2c8708..a429da3 100644 --- a/int-cast.cabal +++ b/int-cast.cabal @@ -1,5 +1,5 @@ name: int-cast -version: 0.1.0.0 +version: 0.1.1.0 synopsis: Checked conversions between integral types homepage: https://github.com/hvr/int-cast bug-reports: https://github.com/hvr/int-cast/issues @@ -13,6 +13,8 @@ cabal-version: >=1.10 description: Provides statically or dynamically checked conversions between integral types. +extra-source-files: changelog.md + source-repository head type: git location: https://github.com/hvr/int-cast.git @@ -20,7 +22,7 @@ source-repository head source-repository this type: git location: https://github.com/hvr/int-cast.git - tag: 0.1.0.0 + tag: 0.1.1.0 library default-language: Haskell2010 @@ -39,4 +41,4 @@ test-suite int-cast-test hs-source-dirs: test . main-is: Suite.hs ghc-options: -Wall - build-depends: int-cast, base, test-framework ==0.8.*, test-framework-quickcheck2 ==0.3.* \ No newline at end of file + build-depends: int-cast, base, QuickCheck ==2.6.*, test-framework ==0.8.*, test-framework-quickcheck2 ==0.3.*, nats ==0.1.*