Skip to content
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

Add more constraints on RankNTypes function args #1480

Closed
DigitalBrains1 opened this issue Aug 13, 2020 · 1 comment
Closed

Add more constraints on RankNTypes function args #1480

DigitalBrains1 opened this issue Aug 13, 2020 · 1 comment

Comments

@DigitalBrains1
Copy link
Member

We don't always specify all constraints that could be specified on Nat in our functions. For instance, riseEvery requires an SNat larger than zero, but it also accepts zero, which causes a runtime error. Usually it's not a problem because we can pass a more-constrained argument to a less-constrained function.

But when we're talking about the argument of a higher-order function (using higher-rank type), the reverse is true. We have

smap :: forall k a b. KnownNat k => (forall l. SNat l -> a -> b) -> Vec k a -> Vec k b

(same for dfold, dtfold, vfold). This precludes using functions that restrict l (ell) to be smaller than k, like at, take, drop, select, splitAt, etc. These all require l be smaller than k, and GHC/CλaSH can't prove that this is the case.

This lead to this Google Group thread.

We should add constraints on these function arguments to allow using constrained functions.

@leonschoorl
Copy link
Member

Same idea as #1054

@leonschoorl leonschoorl closed this as not planned Won't fix, can't repro, duplicate, stale Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants