-
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
Fun/Trouble with dependent types #709
Comments
also:
|
Thanks for the bug reports! We have two things going on here. (1) there's a scope-escape bug in the compiler and (2) even when fixed, we can't handle programs like these. The compiler is riddled with these sorts of naming bugs, which is why we embarked on an adventure to prevent them by encoding name scopes at the type level in Haskell, see this branch: https://github.com/google-research/dex-lang/tree/safe-names-dev . We're almost ready to merge it. I just need to finish AD and some loose ends. If you try your programs on the safe-names-dev branch, here's what you get:
And that's why we can't handle programs like these. We allow application in types at the surface level, but they have to be trivially reducible. This lets us use aliases like |
Thanks for the prompt reply, @dougalm! It's a bit of a bummer that this doesn't work. I've got the following use case, perhaps you have an idea for an alternative encoding:
|
Great example! I can't think of a way to encode this in Dex today other than to use an ordinary ADT for
But Dex's current ADTs are only halfway to being GADTs. You can have dependence between arguments but each branch still produces the same type But even if we fixed that, GADTs don't feel like the perfect solution here. For one thing, you'd like to have some guarantee that all of this case analysis is just compile time stuff and at run time you're working with functions that are fully specialized to the particular configuration of your neural net. So we should think about what it would take to support your example as written. It'll require changing the way we represent types internally because we'll have to allow applications and/or case expressions in types. And it'll require changing the way we reason about type equality, because we'll have to consider an environment that gets refined as you go under a branch of a case expression and learn that, e.g., |
I agree that GADTs don't feel right here, because I've done that before... https://github.com/hasktorch/hasktorch/blob/9560d149b06af17e2d4e73d1e116afd2b0baff86/experimental/gradually-typed/src/Torch/GraduallyTyped/NN/Normalization.hs#L42 I'll open a feature request 😃 |
This is superseded by #710 so closing this! |
Consider:
I'm being presented with:
Thus this ticket 😃
The text was updated successfully, but these errors were encountered: