-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The constraint 0 < d+1 does not seem to resolve? #70
Comments
GHC 9.2 changed a lot of things about how type level comparisons are done. The gist of it is that prior to 9.2 we only had to do reasoning involving While the plugin was updated to support GHC 9.2 and 9.4 the reasoning it does still only works on See this fragment in the code that only matches on ghc-typelits-natnormalise/src-pre-ghc-9.4/GHC/TypeLits/Normalise.hs Lines 752 to 771 in 127c525
The fix(untested) for your code is to rewrite it in terms of libFunc :: forall (i :: Nat) d. i <= (d - 1) => ()
libFunc = ()
useFunc :: forall (d :: Nat). ()
useFunc = libFunc @0 @(d+1) |
Hmm, changing libFunc to have the constraint i <= d-1 indeed allows me to circumvent the issue. How much work do you expect it to be to include support for the other comparison types? I.e. would that be something that can be fixed relatively "locally" to the lines 751-771 there? E.g. would it be possible to deal with the x < y case by e.g. rewriting x' to whatever the appropriate representation of (1+x') is? If so I might take a stab at trying to fix that. However, the documentation around what is happening there is somewhat sparse..... |
Yeah I'd expect you could at least get some rudimentary support for the other operators by just rewriting mechanically to Most of the data types you are seeing are from GHC itself which fortunately can be browsed and searched on hackage: https://hackage.haskell.org/package/ghc-9.2.4 You can enable tracing of the type checker with the Generally when I'm working on this codebase I add a single module in I think that should be enough information to get started. Good luck if you do try to add support :)! |
In the following little code snippet I have to functions, function "libFunc", which has a constraint i < d for two Typelits (e.g. indexing with an index i into some sort of vector of length d). If I use libFunc to index element 0 in a vector of length (d+1) I get the constraint 0 < d+1. This constraint is vacuously true, and hence I was expecting the plugin to resolve this constraint for me. Is this a bug, or was I expecting too much?
I'm using ghc-9.2.4 and ghc-typelits-natnormalise-0.7.7.
The text was updated successfully, but these errors were encountered: