singleton-nats 0.4.0.3 → 0.4.0.4
raw patch · 2 files changed
+33/−6 lines, 2 filesdep ~singletonsPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: singletons
API changes (from Hackage documentation)
- Data.Nat: instance Data.Singletons.Prelude.Eq.PEq 'Data.Proxy.Proxy
- Data.Nat: instance Data.Singletons.Prelude.Num.PNum 'Data.Proxy.Proxy
- Data.Nat: instance Data.Singletons.Prelude.Ord.POrd 'Data.Proxy.Proxy
- Data.Nat: instance Data.Singletons.SingI n0 => Data.Singletons.SingI ('Data.Nat.S n0)
- Data.Nat: instance Data.Singletons.SuppressUnusedWarnings.SuppressUnusedWarnings Data.Nat.Compare_6989586621679052581Sym0
- Data.Nat: instance Data.Singletons.SuppressUnusedWarnings.SuppressUnusedWarnings Data.Nat.Compare_6989586621679052581Sym1
+ Data.Nat: instance Data.Singletons.Prelude.Eq.PEq Data.Nat.Nat
+ Data.Nat: instance Data.Singletons.Prelude.Num.PNum Data.Nat.Nat
+ Data.Nat: instance Data.Singletons.Prelude.Ord.POrd Data.Nat.Nat
+ Data.Nat: instance Data.Singletons.SingI n => Data.Singletons.SingI ('Data.Nat.S n)
+ Data.Nat: instance Data.Singletons.SuppressUnusedWarnings.SuppressUnusedWarnings Data.Nat.Compare_6989586621679056907Sym0
+ Data.Nat: instance Data.Singletons.SuppressUnusedWarnings.SuppressUnusedWarnings Data.Nat.Compare_6989586621679056907Sym1
- Data.Nat: class (~) (Proxy * a0) kproxy0 (Proxy * a0) => PNum a0 (kproxy0 :: Proxy * a0)
+ Data.Nat: class PNum a
- Data.Nat: class SNum a0
+ Data.Nat: class SNum a
- Data.Nat: data SSym0 (l_aabK :: TyFun Nat Nat)
+ Data.Nat: data SSym0 (l_abnq :: TyFun Nat Nat)
- Data.Nat: type SSym1 (t_aabJ :: Nat) = S t_aabJ
+ Data.Nat: type SSym1 (t_abnp :: Nat) = S t_abnp
Files
- Data/Nat.hs +30/−3
- singleton-nats.cabal +3/−3
Data/Nat.hs view
@@ -2,7 +2,8 @@ UndecidableInstances, ScopedTypeVariables, DataKinds, FlexibleInstances, GADTs, TypeFamilies, TemplateHaskell, InstanceSigs, TypeOperators, PolyKinds, StandaloneDeriving,- FlexibleContexts, AllowAmbiguousTypes, CPP, OverloadedStrings #-}+ FlexibleContexts, AllowAmbiguousTypes, CPP, OverloadedStrings,+ EmptyCase #-} module Data.Nat ( Nat(..)@@ -50,7 +51,9 @@ natAbs n = n |]) +#if !(MIN_VERSION_singletons(2,4,0)) deriving instance Show (SNat n)+#endif instance Eq (SNat n) where (==) _ _ = True@@ -63,23 +66,47 @@ #else instance PNum ('Proxy :: Proxy Nat) where #endif+#if MIN_VERSION_singletons(2,4,0)+ type a + b = NatPlus a b+ type a - b = NatMinus a b+ type a * b = NatMul a b+#else type a :+ b = NatPlus a b type a :- b = NatMinus a b type a :* b = NatMul a b+#endif type Abs a = NatAbs a type Signum (a :: Nat) = Error "Data.Nat: signum not implemented" type FromInteger (a :: Lit.Nat) = Lit a instance SNum Nat where+#if MIN_VERSION_singletons(2,4,0)+ (%+) = sNatPlus+ (%*) = sNatMul+ (%-) = sNatMinus+#else (%:+) = sNatPlus (%:*) = sNatMul (%:-) = sNatMinus+#endif sAbs = sNatAbs sSignum = case toSing "Data.Nat: signum not implemented" of SomeSing s -> sError s- sFromInteger n = case n %:== (sing :: Sing 0) of+ sFromInteger n = case n +#if MIN_VERSION_singletons(2,4,0)+ %==+#else+ %:==+#endif+ (sing :: Sing 0) of STrue -> unsafeCoerce SZ- SFalse -> unsafeCoerce (SS (sFromInteger (n %:- (sing :: Sing 1))))+ SFalse -> unsafeCoerce (SS (sFromInteger (n+#if MIN_VERSION_singletons(2,4,0)+ %-+#else+ %:-+#endif+ (sing :: Sing 1)))) {-| Converts a runtime 'Integer' to an existentially wrapped 'Nat'. Returns 'Nothing' if the argument is negative -}
singleton-nats.cabal view
@@ -1,6 +1,6 @@ name: singleton-nats-version: 0.4.0.3+version: 0.4.0.4 synopsis: Unary natural numbers relying on the singletons infrastructure. description: Unary natural number relying on the <https://hackage.haskell.org/package/singletons singletons> infrastructure. More information about the general usage of singletons can be found on the <https://github.com/goldfirere/singletons singletons github> page. category: Data, Dependent Types@@ -14,7 +14,7 @@ build-type: Simple cabal-version: >=1.10-tested-with: GHC == 8.0.1, GHC == 8.2.1+tested-with: GHC == 8.0.1, GHC == 8.2.1, GHC == 8.4.1 source-repository head type: git@@ -26,6 +26,6 @@ build-depends: base >=4.8.1.0 && <5,- singletons >= 2.2 && < 2.4+ singletons >= 2.2 && < 2.5 default-language: Haskell2010