-
Notifications
You must be signed in to change notification settings - Fork 50
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
Restricting functor arguments #108
Comments
How does type inspection help you with Accelerate's restriction on arrays? |
We need an instance (KnownNat n, Additive a) => Additive (Vector n a) where ... ... so that we can create an instance KnownNat n => Additive1 (Vector n) where
additive1 :: forall a. Sat Additive a |- Sat Additive (Vector n a)
additive1 = Entail (Sub Dict) In particular, we can't put more constraints in the context of the Now, Accelerate restricts the things I can put in vectors via an instance (KnownNat n, Additive a) => Additive (Vector n a) where
zero
| Just HRefl <- typeRep @a `eqTypeRep` typeRep @Double
= Vector (Acc.use (Acc.fromList (Acc.Z Acc.:. fromInteger (natVal (Proxy :: Proxy n))) (repeat 0)))
| otherwise = undefined |
Thanks for the motivation. It seems a shame to bypass type safety and introduce partiality. Maybe there's a better way. |
The problem is that
Maybe instead of having an |
I don't know whether such an alternative could work out. Explicit constraint entailment (including |
I guess one idea is to design an alternative to |
Yes, Accelerate has one. ( I contend the underlying problem is that |
Let's at least explore doing the right thing here. How would generalizing |
Roughly, there'd be two "GPU categories", one for scalar computations, and the other one for arrays. |
The problem implementing that is that it would require a major overhaul of the plugin, which has a fairly deep-rooted assumption that there's only one category involved in a function application. |
@conal I'm also hazy on how quantified constraints would help solve this problem. They allow encoding the implication differently, but it would still be an implication, no? PS: Quantified constraints AFAICS aren't where we need them to be, see my attempt here: https://github.com/mikesperber/concat/tree/quantified-constraints |
Okay. Then let's look for a different principled solution rather than beginning (or continuing) a chain of unprincipled workarounds, each just a little worse than the preceding. |
Just to be clear: I certainly didn't mean to suggest putting the Do you have an idea in which direction you'd like to go? |
Oh! I may have misunderstood. Weren't you suggesting making |
No, that's what we had to do to move forward with minimal changes. But you're right, I wasn't clear about what I wanted to do - sorry about that. I can see two rough directions:
I haven't worked either through, but will be happy to do it if you think a particular direction would be acceptable. |
We're currently implementing a Category that will execute on the GPU via Accelerate.
A recurring issue is that in Accelerate, we can have arrays of numeric types (and tuples of them), but not nested arrays.
This goes counter to
ConCat.Category
'sOkFunctor
class that assumes that functors nest arbitarily.We can work around this for
OkFunctor
by makingOk
imply type inspection, but no such luck withAdditive1
. The best I could come up with is makingTypeable
a prerequisite forAdditive
, like this:active-group@c800667
I tried making
Typeable
a prerquisite foradditive1
instead, but this requires far more invasive and widespread changes, so I gave up eventually.The text was updated successfully, but these errors were encountered: