sint 0.1.0.0 → 0.2.0
raw patch · 4 files changed
+35/−16 lines, 4 filesdep ~basedep ~portray
Dependency ranges changed: base, portray
Files
- CHANGELOG.md +6/−1
- README.md +11/−0
- sint.cabal +8/−13
- src/Data/SInt.hs +10/−2
CHANGELOG.md view
@@ -1,3 +1,8 @@-# 0.1.0.0+# 0.2.0 (2021-10-24)++* Make `unSInt` part of a unidirectional pattern synonym.+ * Migration: replace record updates of `unSInt` with `SI#`.++# 0.1.0.0 (2021-09-07) Initial version.
+ README.md view
@@ -0,0 +1,11 @@+# sint++A singleton type for `Nat` represented as `Int`.++This package implements a type `SInt` that links a runtime `Int` with a+type-level `Nat`, along with some arithmetic and reflection capabilities.++This is useful when mixing type-level `Nat`s with GHC array primitives that+expect `Int`s as sizes and indices.++See the module intro of `Data.SInt` for more details.
sint.cabal view
@@ -1,14 +1,12 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.33.0.+-- This file has been generated from package.yaml by hpack version 0.34.4. -- -- see: https://github.com/sol/hpack------ hash: ceb4a5946c62e4214f0149eb3292465831eb7758e6dd5435ab1fb3d771813708 name: sint-version: 0.1.0.0-synopsis: A singleton type for `Nat` represented as `Int`.+version: 0.2.0+synopsis: Nat singletons represented by Int description: This package implements a type `SInt` that links a runtime `Int` with a type-level `Nat`, along with some arithmetic and reflection capabilities. .@@ -27,6 +25,7 @@ build-type: Simple extra-source-files: CHANGELOG.md+ README.md source-repository head type: git@@ -36,28 +35,24 @@ library exposed-modules: Data.SInt- other-modules:- Paths_sint hs-source-dirs: src build-depends: base >=4.12 && <4.16- , portray >=0.1 && <0.2- , portray-diff >=0.1 && <0.2+ , portray >=0.1 && <0.3+ , portray-diff ==0.1.* default-language: Haskell2010 test-suite SInt-test type: exitcode-stdio-1.0 main-is: Main.hs- other-modules:- Paths_sint hs-source-dirs: test build-depends: QuickCheck , base >=4.12 && <4.16- , portray >=0.1 && <0.2- , portray-diff >=0.1 && <0.2+ , portray >=0.1 && <0.3+ , portray-diff ==0.1.* , sint , test-framework , test-framework-quickcheck2
src/Data/SInt.hs view
@@ -57,7 +57,7 @@ #include "MachDeps.h" module Data.SInt- ( SInt(SI#, unSInt), trySIntVal, sintVal, reifySInt, withSInt+ ( SInt(SI#, SI, unSInt), trySIntVal, sintVal, reifySInt, withSInt , addSInt, subSInt, subSIntLE, subSIntL, mulSInt, divSIntL, divSIntR , staticSIntVal -- * Internal@@ -96,8 +96,16 @@ -- construct 'SInt's, and treat this constructor equivalently to -- 'unsafeCoerce'. pattern SI# :: Int -> SInt n-pattern SI# {unSInt} = MkSInt unSInt+pattern SI# x = MkSInt x {-# COMPLETE SI# #-}++-- | A unidirectional pattern for safely deconstructing 'SInt's.+--+-- This lets us export 'unSInt' as if it were a field selector, without making+-- it legal to use in record updates (because this pattern is unidirectional).+pattern SI :: Int -> SInt n+pattern SI {unSInt} <- MkSInt unSInt+{-# COMPLETE SI #-} -- | Use an 'Int' as an existentially-quantified 'SInt'. withSInt :: HasCallStack => Int -> (forall n. SInt n -> r) -> r