Skip to content

Commit

Permalink
Minor improvements and fixes
Browse files Browse the repository at this point in the history
- 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`
  • Loading branch information
hvr committed Mar 1, 2014
1 parent d1f8e84 commit 2984c65
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
15 changes: 7 additions & 8 deletions Data/IntCast.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
--
Expand Down Expand Up @@ -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@
Expand Down
11 changes: 11 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -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
8 changes: 5 additions & 3 deletions int-cast.cabal
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -13,14 +13,16 @@ 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

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
Expand All @@ -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.*
build-depends: int-cast, base, QuickCheck ==2.6.*, test-framework ==0.8.*, test-framework-quickcheck2 ==0.3.*, nats ==0.1.*

0 comments on commit 2984c65

Please sign in to comment.