Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Try and outright solve substituted constraint
Browse files Browse the repository at this point in the history
Partially Fixes [#65]#65.
rowanG077 committed Aug 18, 2022
1 parent a68b722 commit cdb0006
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@

## Unreleased
* Solve unflattened wanteds instead of the wanteds passed to the plugin. Fixes [#1901]https://github.com/clash-lang/clash-compiler/issues/1901.
* Try and outright solve substituted constraint, the same as is done with the unsubstituted constraint. Partially Fixes [#65]https://github.com/clash-lang/ghc-typelits-natnormalise/issues/65.

## 0.7.6 *June 20th 2021*
* Do not vacuously solve `forall a b . 1 <=? a^b ~ True`
1 change: 1 addition & 0 deletions src/GHC/TypeLits/Normalise.hs
Original file line number Diff line number Diff line change
@@ -659,6 +659,7 @@ simplifyNats opts@Opts {..} ordCond eqsG eqsW = do
-- `1 <= x^y`
-- OR
(instantSolveIneq depth u:
instantSolveIneq depth uS:
-- This inequality is either a given constraint, or it is a wanted
-- constraint, which in normal form is equal to another given
-- constraint, hence it can be solved.
9 changes: 9 additions & 0 deletions tests/Tests.hs
Original file line number Diff line number Diff line change
@@ -498,6 +498,12 @@ tyFamMonotonicityFun _ = ()
tyFamMonotonicity :: (2 <= F2 dom) => Proxy (dom :: Symbol) -> ()
tyFamMonotonicity dom = tyFamMonotonicityFun dom

oneLtPowSubst :: forall a b. (b ~ (2^a)) => Proxy a -> Proxy a
oneLtPowSubst = go
where
go :: 1 <= b => Proxy a -> Proxy a
go = id

main :: IO ()
main = defaultMain tests

@@ -598,6 +604,9 @@ tests = testGroup "ghc-typelits-natnormalise"
, testCase "2 <= P (G2 dom) implies 1 <= P (G2 dom)" $
show (tyFamMonotonicity (Proxy :: Proxy Dom)) @?=
"()"
, testCase "b ~ (2^a) => 1 <= b" $
show (oneLtPowSubst (Proxy :: Proxy 0)) @?=
"Proxy"
]
, testGroup "errors"
[ testCase "x + 2 ~ 3 + x" $ testProxy1 `throws` testProxy1Errors

0 comments on commit cdb0006

Please sign in to comment.