-
Notifications
You must be signed in to change notification settings - Fork 108
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
Strided index sets #309
Comments
Great suggestion! I've changed the name to "strided" since this is the more commonly used name I think (at least in the NumPy/Python world). |
This is possible in user space now that #877 has landed. Here's one definition:
Now one can create e.g. even and odd indices:
Here's how to use this to loop over the relevant indices in a table:
However, there's a possible footgun: Below is what I wrote first, which typechecks but gives the wrong answer:
One problem is that the word 'ordinal' has two plausible meanings in this context. Perhaps the general answer to this kind of problem is to train users to avoid using casting in general. Another crazy idea is to allow datatypes with no constructors, but which are simply wrappers for another datatype. Then we should be able to write something like:
Where |
Well the About the final suggestion, I don't think having data types that work as you described is doable. You want them to behave exactly like the one they're derived from, except for the purpose of typeclass synthesis. But if you never even syntactically indicate where you expect a value to act like the derived type, then how is Dex supposed to know which typeclass to use? One potential way to work around it would be to allow subtyping. Then,
then, with your definitions, I get this:
|
It would be useful to have a stepped range index set.
To allow one to index e.g. selecting every even or every odd position.
Right now to achieve that i end up having to do:
The text was updated successfully, but these errors were encountered: