ghc-typelits-extra icon indicating copy to clipboard operation
ghc-typelits-extra copied to clipboard

[RFC] Drop equality cases from Min/Max

Open bgamari opened this issue 7 years ago • 4 comments

I've recently been playing around with the Thoralf plugin for more sophisticated solving. Unfortunately, it gets a bit confused with the equality case in Min and Max. However, if I'm not mistaken it is redundant anyways.

bgamari avatar Oct 08 '18 18:10 bgamari

Actually, it seems that this breaks the ghc-typelits-knownnat solver for reasons I haven't yet pieced together.

bgamari avatar Oct 08 '18 18:10 bgamari

Ah, so single clause closed type families are sorta treated like type synonyms, and so the KnownNat2 instance used by ghc-typelits-knownnat will no longer work. As it won’t see a KnownNat (Max x y), but KnownNat (If (x <=? y) y x)

christiaanb avatar Oct 08 '18 18:10 christiaanb

I have updated this to keep the reflexive cases for GHC < 8.6, since these compilers don't support the KnownBool solver recently introduced in ghc-typelits-knownnat.

bgamari avatar Oct 24 '18 00:10 bgamari

I applied these changes manually, but it seems the test suite would no longer pass since we added more "reasoning-about-max/min" capabilities to the solver, and so the solver itself now needs min/max not to be a type-synonym.... I guess we could fix this internally by treating If (X <=? Y) X Y as Min and If (X <=? Y) Y X as Max.

christiaanb avatar Mar 11 '20 08:03 christiaanb