summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristiaanBaaij <>2018-09-14 13:05:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2018-09-14 13:05:00 (GMT)
commite413036ce16a24e8f1ffa923fe8e77980152ca41 (patch)
tree2d38eb0862954765ba484009b6206ab5143c6d66
parent642f6bb9b266d9b1ff1eb6f29986b47df59916f1 (diff)
version 0.6HEAD0.6master
-rwxr-xr-x[-rw-r--r--]CHANGELOG.md4
-rwxr-xr-x[-rw-r--r--]README.md0
-rw-r--r--ghc-typelits-knownnat.cabal2
-rw-r--r--src/GHC/TypeLits/KnownNat.hs11
4 files changed, 14 insertions, 3 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 58661f7..a676f5f 100644..100755
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,7 +1,7 @@
# Changelog for the [`ghc-typelits-knownnat`](http://hackage.haskell.org/package/ghc-typelits-knownnat) package
-## 0.5.1 *July 10th 2018*
-* Add support for GHC 8.6.1-alpha1
+## 0.6 *September 14th 2018*
+* Move `KnownNat2` instances for `Div` and `Mod` from `ghc-typelits-extra` to `ghc-typelits-knownnat`
## 0.5 *May 9th 2018*
* Fix Inferred constraint is too strong [#19](https://github.com/clash-lang/ghc-typelits-knownnat/issues/19)
diff --git a/README.md b/README.md
index 5a82bd6..5a82bd6 100644..100755
--- a/README.md
+++ b/README.md
diff --git a/ghc-typelits-knownnat.cabal b/ghc-typelits-knownnat.cabal
index 0db8dd0..4038dd5 100644
--- a/ghc-typelits-knownnat.cabal
+++ b/ghc-typelits-knownnat.cabal
@@ -1,5 +1,5 @@
name: ghc-typelits-knownnat
-version: 0.5.1
+version: 0.6
synopsis: Derive KnownNat constraints from other KnownNat constraints
description:
A type checker plugin for GHC that can derive \"complex\" @KnownNat@
diff --git a/src/GHC/TypeLits/KnownNat.hs b/src/GHC/TypeLits/KnownNat.hs
index 32d6dae..3b8956f 100644
--- a/src/GHC/TypeLits/KnownNat.hs
+++ b/src/GHC/TypeLits/KnownNat.hs
@@ -119,6 +119,9 @@ import Data.Proxy (Proxy (..))
#if MIN_VERSION_ghc(8,2,0)
import GHC.TypeNats
(KnownNat, Nat, type (+), type (*), type (^), type (-), natVal, type (<=))
+#if MIN_VERSION_base(4,11,0)
+import GHC.TypeNats (Div, Mod)
+#endif
import GHC.TypeLits (Symbol)
import Numeric.Natural (Natural)
#else
@@ -184,3 +187,11 @@ instance (KnownNat a, KnownNat b) => KnownNat2 $(nameToSymbol ''(^)) a b where
instance (KnownNat a, KnownNat b, b <= a) => KnownNat2 $(nameToSymbol ''(-)) a b where
natSing2 = SNatKn (natVal (Proxy @a) - natVal (Proxy @b))
{-# INLINE natSing2 #-}
+
+#if MIN_VERSION_base(4,11,0)
+instance (KnownNat x, KnownNat y, 1 <= y) => KnownNat2 $(nameToSymbol ''Div) x y where
+ natSing2 = SNatKn (quot (natVal (Proxy @x)) (natVal (Proxy @y)))
+
+instance (KnownNat x, KnownNat y, 1 <= y) => KnownNat2 $(nameToSymbol ''Mod) x y where
+ natSing2 = SNatKn (rem (natVal (Proxy @x)) (natVal (Proxy @y)))
+#endif