-
Notifications
You must be signed in to change notification settings - Fork 430
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow function application on the right side of fast pipe.
Fast pipe desugars to |. Why? It's easy stub-able like: let (|.) = (a, f) => f(a); This results into the rhs of -> not taking function application to make this work: a->f(b) is parsed as (a->f)(b). The fact that there isn't function application on the rhs, has resulted into a wide range of problems with fastpipe. In printing you actually want the layout to break as if there was a function application on the rhs! The printing problems were fixed at the cost of a tremendous amount of complexity in the printer. Are the semantics (evaluation order etc) identical when defined in user space like this, as opposed to ppx? No, they aren't… ``` let fn1 = (~foo=?, ()) => 1; let fn2 = (~bar=?, x) => 2; /* Ok */ fn1(~foo=1, ())->(fn2(~bar=2)) /* Ok */ fn1(~foo=1,()) |. fn2(~bar=2) /* Error: This expression has type int. It is not a function. */ fn1(~foo=1, ())->fn2(~bar=2) /* Explanation */ fn1(~foo=1, ())->fn2(~bar=2) /* this translates to: */ fn2(1)(~bar=2) /* however, because `~bar` is optional, `fn2(1)` already produced a value. Therefore: */ 2(~bar=2) ``` In retrospect, not having function application on the rhs was a terrible mistake. Fast pipe is all about function application in its current form. If it was done via ppx, then you wouldn't get the error in the example above.
- Loading branch information
1 parent
221c40a
commit 1dc2043
Showing
15 changed files
with
92 additions
and
42,083 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
File "reservedField.re", line 1, characters 11-15: | ||
Error: 1050: type is a reserved keyword, it cannot be used as an identifier. Try `type_` or `_type` instead | ||
Error: type is a reserved keyword, it cannot be used as an identifier. Try `type_` or `_type` instead |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
File "reservedRecord.re", line 1, characters 24-28: | ||
Error: 1821: type is a reserved keyword, it cannot be used as an identifier. Try `type_` or `_type` instead | ||
Error: type is a reserved keyword, it cannot be used as an identifier. Try `type_` or `_type` instead |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
File "reservedRecordPunned.re", line 1, characters 22-26: | ||
Error: 3369: type is a reserved keyword, it cannot be used as an identifier. Try `type_` or `_type` instead | ||
Error: type is a reserved keyword, it cannot be used as an identifier. Try `type_` or `_type` instead |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
File "reservedRecordType.re", line 1, characters 11-15: | ||
Error: 766: type is a reserved keyword, it cannot be used as an identifier. Try `type_` or `_type` instead | ||
Error: type is a reserved keyword, it cannot be used as an identifier. Try `type_` or `_type` instead |
2 changes: 1 addition & 1 deletion
2
formatTest/errorTests/expected_output/reservedRecordTypePunned.re
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
File "reservedRecordTypePunned.re", line 1, characters 11-15: | ||
Error: 766: type is a reserved keyword, it cannot be used as an identifier. Try `type_` or `_type` instead | ||
Error: type is a reserved keyword, it cannot be used as an identifier. Try `type_` or `_type` instead |
190 changes: 0 additions & 190 deletions
190
formatTest/typeCheckedTests/expected_output/fastPipe.re
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.