positive-integer 0.1.1.0 → 0.1.2.0
raw patch · 3 files changed
+32/−3 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Numeric.PositiveInteger: fromTypeNat1 :: forall proxy (n :: Nat). KnownNat n => proxy (1 + n) -> PositiveInteger
+ Numeric.PositiveInteger: withTypeNat1 :: PositiveInteger -> (forall (proxy :: Natural -> Type) (n :: Nat). KnownNat n => proxy (1 + n) -> a) -> a
Files
- changelog.md +10/−0
- lib/Numeric/PositiveInteger.hs +20/−1
- positive-integer.cabal +2/−2
+ changelog.md view
@@ -0,0 +1,10 @@+## 0.1.2.0+* Added `fromTypeNat1`.+* Added `withTypeNat1`.++## 0.1.1.0+* Added `fromTypeNat`.+* Added `withTypeNat`.++## 0.1.0.0+* First version.
lib/Numeric/PositiveInteger.hs view
@@ -4,6 +4,8 @@ {-# LANGUAGE GADTs #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE TypeApplications #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE FlexibleContexts #-} -- | This module provides a type for the positive integers, together -- with conversion functions and other operations.@@ -30,6 +32,8 @@ -- ** Type-level conversions , fromTypeNat , withTypeNat+ , fromTypeNat1+ , withTypeNat1 -- * Operations , next , add@@ -49,7 +53,7 @@ import Numeric.Natural (Natural) import Text.Read (readPrec) import Control.Monad qualified as Monad-import GHC.TypeNats (KnownNat, SomeNat (..), someNatVal, natVal, cmpNat)+import GHC.TypeNats (KnownNat, SomeNat (..), someNatVal, natVal, cmpNat, type (+)) import Data.Type.Ord (type (>), OrderingI (..)) import Data.Proxy (Proxy (..)) @@ -130,6 +134,21 @@ GTI -> f proxy -- This case should be impossible. _ -> error "Positive integer is not positive!"++-- | Convert a type-level natural in @n + 1@ form to a positive integer.+--+-- @since 0.1.2.0+fromTypeNat1 :: forall proxy n . KnownNat n => proxy (1+n) -> PositiveInteger+fromTypeNat1 _ = PositiveInteger $ 1 + natVal (Proxy @n)++-- | Convert a positive integer to a type-level natural in @n + 1@ form+-- and apply a function to it.+--+-- @since 0.1.2.0+withTypeNat1 :: PositiveInteger -> (forall proxy n . KnownNat n => proxy (1 + n) -> a) -> a+withTypeNat1 (PositiveInteger n) f =+ case someNatVal $ n - 1 of+ SomeNat (_ :: Proxy n) -> f (Proxy @(1 + n)) -- | Return the next positive integer. next :: PositiveInteger -> PositiveInteger
positive-integer.cabal view
@@ -1,5 +1,5 @@ name: positive-integer-version: 0.1.1.0+version: 0.1.2.0 category: Numeric synopsis: Type of positive integers. description: Type of positive integers together with related functions.@@ -10,7 +10,7 @@ license: MIT license-file: license cabal-version: 1.18-extra-doc-files: readme.md+extra-doc-files: readme.md, changelog.md library default-language: Haskell2010