-
Notifications
You must be signed in to change notification settings - Fork 428
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add initial prototype for native/builtin fast pipe in Reason * implement fast pipe for fresh open expressions and underscore syntax * Add prototype for tuple dispatch with fast pipe * Address parsing feedback for fast pipe -> parses into ocaml |. |. parses into ocaml |. * Print fast pipe beautiful * Enhance printing of fast pipe in the neighbourhood of other infix operators * Modify precedence of -> to be just below . and #. examples: x.c->f->g === (x.c)->f->g x##c->f->g === (x##c)->f->g !a->f->g === !(a->f->g) * remove obsolete fast pipe attribute partitioning
- Loading branch information
1 parent
499bf19
commit f763db6
Showing
9 changed files
with
229 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
let (|.) = (x, y) => x + y; | ||
|
||
let a = 1; | ||
let b = 2; | ||
let c = 3; | ||
|
||
/* parses as 10 < (a->b->c) */ | ||
let t1: bool = 10 < a->b->c; | ||
|
||
type coordinate = { | ||
x: int, | ||
y: int, | ||
}; | ||
let coord = {x: 1, y: 1}; | ||
|
||
/* parses as (coord.x)->a->b->c */ | ||
let t2: int = coord.x->a->b->c; | ||
|
||
let (|.) = (x, y) => x || y; | ||
|
||
let a = true; | ||
let b = false; | ||
let c = true; | ||
|
||
/* parses as !(a->b->c) */ | ||
let t3: bool = ! a->b->c; |
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
let (|.) = (x, y) => x + y; | ||
|
||
let a = 1; | ||
let b = 2; | ||
let c = 3; | ||
|
||
/* parses as 10 < (a->b->c) */ | ||
let t1: bool = 10 < a->b->c; | ||
|
||
type coordinate = {x: int, y: int}; | ||
let coord = {x: 1, y: 1}; | ||
|
||
/* parses as (coord.x)->a->b->c */ | ||
let t2: int = coord.x->a->b->c; | ||
|
||
let (|.) = (x, y) => x || y; | ||
|
||
let a = true; | ||
let b = false; | ||
let c = true; | ||
|
||
/* parses as !(a->b->c) */ | ||
let t3: bool = !a->b->c; |
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
foo->f->g->h; | ||
|
||
bar->f->g->h; | ||
|
||
compilation | ||
->Plugin.buildAssets | ||
->Js.Json.stringify | ||
->Node.Fs.writeFileAsUtf8Sync(_, path); | ||
|
||
foo->bar->baz >>= monadicFunction |> bind; | ||
|
||
compilation | ||
->Plugin.buildAssets | ||
->Js.Json.stringify | ||
|> Cohttp_lwt_body.to_string | ||
>|= ( | ||
body => | ||
Printf.sprintf( | ||
"okokok", | ||
uri, | ||
meth, | ||
headers, | ||
body, | ||
) | ||
) | ||
>>= ( | ||
body => | ||
Server.respond_string(~status, ~body, ()) | ||
); | ||
|
||
x + y + foo->bar->baz; | ||
x + y * foo->bar->baz; | ||
x && y || foo->bar->baz; | ||
|
||
x < foo->bar->baz; | ||
foo !== bar->baz; | ||
x |> y >>= foo->bar->baz; | ||
let m = f => foo->bar->f; | ||
|
||
obj##x->foo->bar; |
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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
foo |. f |. g |. h; | ||
|
||
bar->f->g->h; | ||
|
||
compilation | ||
->Plugin.buildAssets | ||
->Js.Json.stringify | ||
->Node.Fs.writeFileAsUtf8Sync(_, path); | ||
|
||
foo->bar->baz >>= monadicFunction |> bind; | ||
|
||
compilation | ||
->Plugin.buildAssets | ||
->Js.Json.stringify | ||
|> Cohttp_lwt_body.to_string | ||
>|= ( | ||
body => | ||
Printf.sprintf( | ||
"okokok", | ||
uri, | ||
meth, | ||
headers, | ||
body, | ||
) | ||
) | ||
>>= ( | ||
body => | ||
Server.respond_string( | ||
~status, | ||
~body, | ||
(), | ||
) | ||
); | ||
|
||
x + y + foo->bar->baz; | ||
x + y * foo->bar->baz; | ||
x && y || foo->bar->baz; | ||
|
||
x < foo->bar->baz; | ||
foo !== bar->baz; | ||
x |> y >>= foo->bar->baz; | ||
let m = f => foo->bar->f; | ||
|
||
obj##x->foo->bar; |
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 |
---|---|---|
|
@@ -53,6 +53,7 @@ | |
(wrapped false) | ||
(modules | ||
(lexer_warning | ||
reason_ast | ||
reason_syntax_util | ||
reason_comment | ||
reason_layout | ||
|
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
open Ast_404 | ||
open Parsetree | ||
|
||
let processFastPipe e = | ||
match e.pexp_desc with | ||
| Pexp_apply( | ||
{pexp_desc = Pexp_ident({txt = Longident.Lident("|."); loc})} as identExp, | ||
args | ||
) -> | ||
let pipe = {identExp with pexp_desc = | ||
Pexp_ident {txt = Longident.Lident("->"); loc} | ||
} in | ||
{e with pexp_desc = Pexp_apply(pipe, args) } | ||
| _ -> e |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
val processFastPipe : Ast_404.Parsetree.expression -> Ast_404.Parsetree.expression |
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