clash-lang / ghc-typelits-knownnat

Derive KnownNat constraints from other KnownNat constraints
Other
14 stars 10 forks source link

Plugin loops between two unknowns #30

Closed christiaanb closed 5 years ago

christiaanb commented 5 years ago

Given:

[G] x :: KnownNat (a + b)
[W] p :: KnownNat a

The plugin tries to solve this by generating:

evidence p = x - q

new wanted:
[W] q :: KnownNat b

the solver loop does another turn, and we get:

[G] x :: KnownNat (a + b)
[W] q :: KnownNat b

which the plugin solves by:

evidence q = x - k

new wanted:
[W] k :: KnownNat a

and we're back to solving KnownNat a again, thus looking forever if it wasn't for the type checker solver iteration limit. This is https://github.com/clash-lang/clash-compiler/issues/608