packages feed

finite-typelits 0.1.2.0 → 0.1.3.0

raw patch · 2 files changed

+13/−1 lines, 2 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Data.Finite.Internal: instance GHC.TypeLits.KnownNat n => GHC.Read.Read (Data.Finite.Internal.Finite n)

Files

finite-typelits.cabal view
@@ -1,5 +1,5 @@ name:                finite-typelits-version:             0.1.2.0+version:             0.1.3.0 synopsis:            A type inhabited by finitely many values, indexed by type-level naturals. description:         A type inhabited by finitely many values, indexed by type-level naturals. homepage:            https://github.com/mniip/finite-typelits
src/Data/Finite/Internal.hs view
@@ -16,10 +16,14 @@     )     where +import GHC.Read import GHC.TypeLits import GHC.Generics import Control.DeepSeq+import Control.Monad import Data.Ratio+import Text.Read.Lex+import Text.ParserCombinators.ReadPrec  -- | Finite number type. @'Finite' n@ is inhabited by exactly @n@ values. Invariants: --@@ -61,6 +65,14 @@  instance Show (Finite n) where     showsPrec d (Finite x) = showParen (d > 9) $ showString "finite " . showsPrec 10 x++instance KnownNat n => Read (Finite n) where+    readPrec = parens $ Text.ParserCombinators.ReadPrec.prec 10 $ do +                 expectP (Ident "finite")+                 x <- readPrec+                 let result = finite x+                 guard (x >= 0 && x < natVal result) +                 return result  -- | Modulo arithmetic. Only the 'fromInteger' function is supposed to be useful. instance KnownNat n => Num (Finite n) where