-
Notifications
You must be signed in to change notification settings - Fork 3
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
Internal representation of MultiDim vectors is too general #91
Comments
How about (untested):
|
The above solution would also lead to better code when we implement virtual tuples #61. |
We probably want a closed type family:
This would avoid the |
Nesting any type of non-scalar types risks hitting Feldspar/feldspar-compiler#145. A couple of words of general caution too: *) I know that MultiDim triggered some CSE-oddities because of the choice of the representation, so talk to @josefs about that before changing things around for this. *) Closed type families are a GHC 7.8 feature. GHC 7.8 isn't released yet. Once there is a release there is no Haskell Platform. After GHC is released there is the usual shakedown of packages that don't work because of some changes, or dependencies who aren't updated, etc. I'm all for leveraging the and cool stuff in GHC 7.8, but please do so after there is a Haskell platform and things have settled a bit on Hackage. |
Yes, but only until we fix Feldspar/feldspar-compiler#3 :-) I agree we should only use features that are in the Platform. Without closed type families, we would get |
It seems that everyone agrees that the current representation of dimensions in the vector library is something we would like to move away from. I agree with Emil that we should aim for the tuple representation, but I expect that with the compiler we have now it would generate absolutely horrible code because of the way tuples are currently compiled. It seems that we have two ways of dealing with dimensions in multidim:
I don't understand exactly how Anders' solution would work. Ander, can you elaborate? I also have no idea how hard it would be to implement virtual tuples so I find it difficult to say which course of action would be easiest. |
It seems we can do without closed type families after all:
This should be equivalent to the closed version above (though I haven't tested). |
Josef wrote:
The main problem with virtual tuples is that they play badly with the copy-propagation-on-the-fly in But the only case where the result location is something different than a variable is when the program computes an array or a struct (I think). If we can guarantee that tuples are never stored in arrays or structs (as the virtual tuples proposal suggests), then copy propagation might not be a problem after all. So it might be easy to implement virtual tuples... |
Halfway through on this issue: Anders has working code based on the open type family sketched above for going from |
👍 |
When a MultiDim vector is converted to its internal representation, type information is lost.
becomes
The number of dimensions is converted into a runtime property and the information is lost at the type level.
Among other things, this makes it impossible to write a good
Arbitrary
instance that will generate only arrays with the correct number of dimensions.Can we make the internal representation an explicit (new)type instead of the pair and encode the dimensions so that the number of dimensions is still available in the type.
cc @josefs
The text was updated successfully, but these errors were encountered: