{{ message }}
/ Arend Public

# Syntax for partially applied functions#147

Closed
opened this issue Feb 24, 2020 · 9 comments
Closed

# Syntax for partially applied functions#147

opened this issue Feb 24, 2020 · 9 comments
Labels
Milestone

### valis commented Feb 24, 2020

 Implement a notation for partially functions such as `f(a,-,c)`. I suggest `__` because `-` and `_` are already taken. The lambda should be inserted only in specific positions such as the argument of an application (but not in infix operator). ``````f a __ c == (\lam x => f a x c) (\lam c => f __ c) == (\lam c x => f x c) pmap __.1 s == pmap (\lam t => t.1) s __ a == (\lam f => f a) x + __.2 == (\lam t => x + t.2) field {__} + y == (\lam s => field {s} + y) a * __ + b * c == (\lam x => a * x + b * c) f __ + 3 == (\lam x => f x + 3) (__.1, __.2) == (\lam t => t.1, \lam t => t.2) (\case f __ \with { }) == (\lam x => \case f x \with { }) `````` If `__` occurs more than once in an expression, this can be interpreted either as a lambda with two parameters or as a lambda with one parameter which is used twice. For example, `__ * a + __ * b` could be interpreted as either `\lam x y => x * a + y * b` or `\lam x => x * a + x * b`. The first interpretation looks more natural to me. The text was updated successfully, but these errors were encountered:
added the feature label Feb 24, 2020

### ice1000 commented Mar 27, 2020

 `__ * a + __ * b` may also be `(\lam x => x * a) + (\lam x => x * b)`, no?

### ice1000 commented Mar 27, 2020 • edited

 If it shall desugar app exprs recursively, how about parentheses? Say, `f (a __ b)`, should it become `\lam x => f (a x b)` or `f (\lam x => a x b)`?

### valis commented Mar 27, 2020

 `__ * a + __ * b` may also be `(\lam x => x * a) + (\lam x => x * b)`, no? It could be, but it shouldn't be.

### valis commented Mar 27, 2020

 If it shall desugar app exprs recursively, how about parentheses? Say, `f (a __ b)`, should it become `\lam x => f (a x b)` or `f (\lam x => a x b)`? Parenthesis is not part of the AST. In you example, it's an argument of an application. The original messages mentions this: The lambda should be inserted only in specific positions such as the argument of an application (but not in infix operator).

### ice1000 commented Mar 27, 2020

 So, IIUC, `a * (__ + b)` should be `\lam x => a * (x + b)`, right?

closed this as completed Mar 27, 2020
reopened this Mar 27, 2020

### valis commented Mar 27, 2020

 Basically, it should be inserted immediately except for a few special cases. I list a few of them in my original message (there might be more though). So, if it does not make sense to insert lambda in some place, it should be inserted higher. For example, this happens in `\case` expressions. It also happens in `\Pi` and `\Sigma` types, which I did not mention. Binops is a special case. It certainly possible to have a lambda under binop, but it rarely happens in practice and it is more natural to desugar `__ * a + b` into `\lam x => x * a + b` than `(\lam x => x * a) + b`.

### valis commented Mar 27, 2020

 So, IIUC, `a * (__ + b)` should be `\lam x => a * (x + b)`, right? Yes

### ice1000 commented Mar 28, 2020

 `1 + \case __ \with {}` is translated to `\lam i => i + \case i \with {}`

added a commit that referenced this issue Apr 3, 2020
``` Move code from DesugarVisitor to ExpressionResolveNameVisitor (#147) ```
``` 9f0f355 ```
added a commit that referenced this issue Apr 3, 2020
``` Improve the desugaring logic (#147) ```
``` fcce614 ```
added a commit that referenced this issue Apr 3, 2020
``` Move code from DesugarVisitor to ExpressionResolveNameVisitor (#147) ```
``` d58c281 ```
added a commit that referenced this issue Apr 3, 2020
``` Improve the desugaring logic (#147) ```
``` d93892a ```
added this to the 1.4 milestone Apr 3, 2020
added a commit that referenced this issue Apr 3, 2020
``` Work for pi and sigma (#147) ```
``` 12ac9a7 ```
added a commit that referenced this issue Apr 3, 2020
``` Extract createAppHoleRef (#147) ```
``` 75418b9 ```
added a commit that referenced this issue Apr 3, 2020
``` Reuse more code (#147) ```
``` de420b0 ```
added a commit that referenced this issue Apr 3, 2020
``` Test about Pi and Sigma (#147) ```
``` db801a1 ```
added a commit that referenced this issue Apr 5, 2020
``` Refactor (#147) ```
``` 284a961 ```
added a commit that referenced this issue Apr 6, 2020
``` Move code from DesugarVisitor to ExpressionResolveNameVisitor (#147) ```
``` df1ec8b ```
added a commit that referenced this issue Apr 6, 2020
``` Improve the desugaring logic (#147) ```
``` b94ed0f ```
added a commit that referenced this issue Apr 6, 2020
``` Work for pi and sigma (#147) ```
``` 95bbb07 ```
added a commit that referenced this issue Apr 6, 2020
``` Extract createAppHoleRef (#147) ```
``` 4f1c5ff ```
added a commit that referenced this issue Apr 6, 2020
``` Reuse more code (#147) ```
``` d0911c8 ```
added a commit that referenced this issue Apr 6, 2020
``` Test about Pi and Sigma (#147) ```
``` 9f6ad00 ```
added a commit that referenced this issue Apr 6, 2020
``` Refactor (#147) ```
``` 1dfde1b ```
added a commit that referenced this issue Apr 6, 2020
``` Move code from DesugarVisitor to ExpressionResolveNameVisitor (#147) ```
``` 9b98888 ```
added a commit that referenced this issue Apr 6, 2020
``` Improve the desugaring logic (#147) ```
``` 607e397 ```
added a commit that referenced this issue Apr 6, 2020
``` Work for pi and sigma (#147) ```
``` 7c74a28 ```
added a commit that referenced this issue Apr 6, 2020
``` Extract createAppHoleRef (#147) ```
``` 99e0954 ```
added a commit that referenced this issue Apr 6, 2020
``` Reuse more code (#147) ```
``` 6d4d7a6 ```
added a commit that referenced this issue Apr 6, 2020
``` Test about Pi and Sigma (#147) ```
``` e005727 ```
added a commit that referenced this issue Apr 6, 2020
``` Refactor (#147) ```
``` 10d7585 ```
added a commit that referenced this issue Apr 13, 2020
``` Move code from DesugarVisitor to ExpressionResolveNameVisitor (#147) ```
``` 1d83516 ```
added a commit that referenced this issue Apr 13, 2020
``` Improve the desugaring logic (#147) ```
``` 82119b7 ```
added a commit that referenced this issue Apr 13, 2020
``` Work for pi and sigma (#147) ```
``` bdfb2c6 ```
added a commit that referenced this issue Apr 13, 2020
``` Extract createAppHoleRef (#147) ```
``` 2ff0ce0 ```
added a commit that referenced this issue Apr 13, 2020
``` Reuse more code (#147) ```
``` c68653c ```
added a commit that referenced this issue Apr 13, 2020
``` Test about Pi and Sigma (#147) ```
``` d771cfe ```
added a commit that referenced this issue Apr 13, 2020
``` Refactor (#147) ```
``` 1e9d076 ```
added a commit that referenced this issue Apr 13, 2020
``` Move code from DesugarVisitor to ExpressionResolveNameVisitor (#147) ```
``` 7bb6c66 ```
added a commit that referenced this issue Apr 13, 2020
``` Improve the desugaring logic (#147) ```
``` 027fc0a ```
added a commit that referenced this issue Apr 13, 2020
``` Work for pi and sigma (#147) ```
``` 7c81291 ```
added a commit that referenced this issue Apr 13, 2020
``` Extract createAppHoleRef (#147) ```
``` 7c1b1b7 ```
added a commit that referenced this issue Apr 13, 2020
``` Reuse more code (#147) ```
``` 988f769 ```
added a commit that referenced this issue Apr 13, 2020
``` Test about Pi and Sigma (#147) ```
``` ed9226e ```
added a commit that referenced this issue Apr 13, 2020
``` Refactor (#147) ```
``` 02d0d5c ```
added a commit that referenced this issue Apr 13, 2020
``` Move code from DesugarVisitor to ExpressionResolveNameVisitor (#147) ```
``` 0c6d4d4 ```
added a commit that referenced this issue Apr 13, 2020
``` Improve the desugaring logic (#147) ```
``` 9a393fa ```
added a commit that referenced this issue Apr 13, 2020
``` Work for pi and sigma (#147) ```
``` 9338a98 ```
added a commit that referenced this issue Apr 13, 2020
``` Extract createAppHoleRef (#147) ```
``` 425831f ```
added a commit that referenced this issue Apr 13, 2020
``` Reuse more code (#147) ```
``` 7af86f3 ```
added a commit that referenced this issue Apr 13, 2020
``` Test about Pi and Sigma (#147) ```
``` 1a67207 ```
added a commit that referenced this issue Apr 13, 2020
``` Refactor (#147) ```
``` f64bd4a ```

### ice1000 commented Apr 17, 2020

 Shall be fixed by #199?

closed this as completed Apr 21, 2020