-
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
Reduce indentation hell. #1147
Reduce indentation hell. #1147
Conversation
Fixes google-research#1137 in spirit, if not precisely as filed (i.e., this implements the generalization in the comments, not the original ask). Also add `Lexer.debug`, leaning on Megaparsec's `dbg`, which actually turns out to be very helpful for debugging the concrete syntax parser.
14fb07f
to
626ee4d
Compare
Offline, @dougalm, @apaszke, and I considered changing the syntax further to add a Option A:
Pros: Option B: As implemented, i.e.
Pros: |
When reading the resulting code, @dougalm and I found that type-changing wrapper functions (most commonly Consider
You'd think that the return type would be determined by the last line, but it's actually not -- it's determined by the first However, using We therefore propose a convention, at least for the time being: The We considered enforcing this convention with a special type-checking rule, but decided against because (i) that's work, and (ii) it's probably better to see what uses for type-changing |
By the way, with this change Dex can mimic Haskell's
Amusingly, this usage adheres to the convention proposed above: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Remarkably small patch. I suspect we'll eventually want to add a version of CBind
to UExpr
too, so that we can throw type-informed errors during inference (e.g. to ensure that the CPS function doesn't change the result type) but let's see how this feature gets used in practice first.
Implement <- as syntactic sugar for continuation lambdas.
Apply it throughout the prelude to see how it looks. If this is registering as a good change, we can propagate it throughout the rest of the corpus as well.
This fixes #1137 in spirit, if not precisely as filed (i.e., this implements the generalization in the comments, not the original ask).