Skip to content

Commit

Permalink
Fix n <= 0 constrained being reported as impossible.
Browse files Browse the repository at this point in the history
  • Loading branch information
rowanG077 committed Jun 11, 2024
1 parent 84f500a commit 0467c01
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog for the [`ghc-typelits-natnormalise`](http://hackage.haskell.org/package/ghc-typelits-natnormalise) package

## Unreleased
* Fix `n <= 0` constrained being reported as impossible.

## 0.7.10 *May 22nd 2024*
* Support for GHC 9.10.1

Expand Down
8 changes: 5 additions & 3 deletions src/GHC/TypeLits/Normalise/Unify.hs
Original file line number Diff line number Diff line change
Expand Up @@ -568,8 +568,8 @@ unifiers' ct (S ((P [I i]):ps1)) (S ((P [I j]):ps2))
unifiers' ct s1@(S ps1) s2@(S ps2) = case sopToIneq k1 of
Just (s1',s2',_)
| s1' /= s1 || s2' /= s1
, maybe True (uncurry (&&) . second Set.null) (runWriterT (isNatural s1'))
, maybe True (uncurry (&&) . second Set.null) (runWriterT (isNatural s2'))
, maybe False (uncurry (&&) . second Set.null) (runWriterT (isNatural s1'))
, maybe False (uncurry (&&) . second Set.null) (runWriterT (isNatural s2'))
-> unifiers' ct s1' s2'
_ | null psx
, length ps1 == length ps2
Expand Down Expand Up @@ -655,7 +655,9 @@ isNatural (S []) = return True
isNatural (S [P []]) = return True
isNatural (S [P (I i:ps)])
| i >= 0 = isNatural (S [P ps])
| otherwise = return False
| otherwise = WriterT Nothing
-- If i is not a natural number then their sum *might* be natural,
-- but we simply can't be sure since ps might be zero
isNatural (S [P (V _:ps)]) = isNatural (S [P ps])
isNatural (S [P (E s p:ps)]) = do
sN <- isNatural s
Expand Down

0 comments on commit 0467c01

Please sign in to comment.