Skip to content

Commit

Permalink
feat(compiler)!: Change -> to => in type signatures
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-snezhko committed Jun 11, 2023
1 parent 618c1ba commit c5cdab8
Show file tree
Hide file tree
Showing 103 changed files with 1,656 additions and 1,516 deletions.
2 changes: 1 addition & 1 deletion compiler/src/formatting/format.re
Original file line number Diff line number Diff line change
Expand Up @@ -1792,7 +1792,7 @@ and print_type =
},
),
Doc.space,
Doc.text("->"),
Doc.text("=>"),
Doc.space,
print_type(~original_source, ~comments, parsed_type),
])
Expand Down
1 change: 0 additions & 1 deletion compiler/src/parsing/lexer.re
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,6 @@ let rec token = lexbuf => {
| "/" => positioned(SLASH)
| "|" => positioned(PIPE)
| "-" => positioned(DASH)
| "->" => positioned(ARROW)
| "=>" => positioned(THICKARROW)
| "type" => positioned(TYPE)
| "enum" => positioned(ENUM)
Expand Down
67 changes: 41 additions & 26 deletions compiler/src/parsing/parser.messages
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ program: MODULE UIDENT EOL FOREIGN WASM LIDENT COLON UIDENT AS LIDENT YIELD
## The known suffix of the stack is as follows:
## FOREIGN WASM id_str COLON typ option(as_prefix(id_str))
##
program: MODULE UIDENT EOL FOREIGN WASM LIDENT COLON EOL LIDENT ARROW
program: MODULE UIDENT EOL FOREIGN WASM LIDENT COLON EOL LIDENT THICKARROW
##
## Ends in an error in state: 757.
##
Expand All @@ -366,7 +366,7 @@ program: MODULE UIDENT EOL FOREIGN WASM LIDENT COLON EOL UIDENT AS LIDENT YIELD
## The known suffix of the stack is as follows:
## FOREIGN WASM id_str COLON eols typ option(as_prefix(id_str))
##
program: MODULE UIDENT EOL FOREIGN WASM LIDENT COLON LIDENT ARROW
program: MODULE UIDENT EOL FOREIGN WASM LIDENT COLON LIDENT THICKARROW
##
## Ends in an error in state: 749.
##
Expand Down Expand Up @@ -2860,7 +2860,7 @@ program: MODULE UIDENT EOL UIDENT LPAREN COMMA WHILE
## In state 43, spurious reduction of production comma -> COMMA
## In state 275, spurious reduction of production option(comma) -> comma
##
program: MODULE UIDENT EOL UIDENT LPAREN UIDENT ARROW
program: MODULE UIDENT EOL UIDENT LPAREN UIDENT THICKARROW
##
## Ends in an error in state: 473.
##
Expand Down Expand Up @@ -3300,7 +3300,7 @@ program: MODULE UIDENT EOL LBRACE BREAK RBRACE LBRACK WASMI64 THICKARROW
## In state 243, spurious reduction of production non_stmt_expr -> annotated_expr
## In state 62, spurious reduction of production expr -> non_stmt_expr
##
program: MODULE UIDENT EOL PREFIX_150 LBRACK RBRACK LBRACK BIGINT ARROW
program: MODULE UIDENT EOL PREFIX_150 LBRACK RBRACK LBRACK BIGINT THICKARROW
##
## Ends in an error in state: 560.
##
Expand Down Expand Up @@ -3396,7 +3396,7 @@ program: MODULE UIDENT EOL LBRACE LIDENT COMMA EOL LIDENT COLON BREAK WHILE
## The known suffix of the stack is as follows:
## punned_record_field comma lseparated_nonempty_list_inner(comma,record_field)
##
program: MODULE UIDENT EOL LBRACE ELLIPSIS BIGINT COMMA ELLIPSIS BIGINT ARROW
program: MODULE UIDENT EOL LBRACE ELLIPSIS BIGINT COMMA ELLIPSIS BIGINT THICKARROW
##
## Ends in an error in state: 227.
##
Expand All @@ -3423,7 +3423,7 @@ program: MODULE UIDENT EOL LBRACE ELLIPSIS BIGINT COMMA ELLIPSIS BIGINT ARROW

Expected a comma followed by more record fields or an immediate `}` to complete the record expression.

program: MODULE UIDENT EOL UIDENT LBRACE ELLIPSIS UIDENT ARROW
program: MODULE UIDENT EOL UIDENT LBRACE ELLIPSIS UIDENT THICKARROW
##
## Ends in an error in state: 488.
##
Expand Down Expand Up @@ -3511,7 +3511,7 @@ program: MODULE UIDENT EOL LBRACE LIDENT COMMA LIDENT COMMA EOL WHILE

Expected more record fields or an immediate `}` to complete the record expression.

program: MODULE UIDENT EOL LBRACE ELLIPSIS BIGINT ARROW
program: MODULE UIDENT EOL LBRACE ELLIPSIS BIGINT THICKARROW
##
## Ends in an error in state: 222.
##
Expand Down Expand Up @@ -4378,7 +4378,7 @@ program: MODULE UIDENT EOL LET UIDENT DOT EOL WHILE
##
## Ends in an error in state: 92.
##
## lseparated_nonempty_list_inner(dot,type_id_str) -> lseparated_nonempty_list_inner(dot,type_id_str) DOT eols . type_id_str [ WHEN THICKARROW STAR SLASH SEMI RPAREN RCARET RBRACK RBRACE PIPE LPAREN LCARET INFIX_90 INFIX_80 INFIX_70 INFIX_60 INFIX_50 INFIX_40 INFIX_30 INFIX_120 INFIX_110 INFIX_100 FROM EQUAL EOL EOF ELSE DOT DASH COMMA COLON AS ARROW ]
## lseparated_nonempty_list_inner(dot,type_id_str) -> lseparated_nonempty_list_inner(dot,type_id_str) DOT eols . type_id_str [ WHEN THICKARROW STAR SLASH SEMI RPAREN RCARET RBRACK RBRACE PIPE LPAREN LCARET INFIX_90 INFIX_80 INFIX_70 INFIX_60 INFIX_50 INFIX_40 INFIX_30 INFIX_120 INFIX_110 INFIX_100 FROM EQUAL EOL EOF ELSE DOT DASH COMMA COLON AS THICKARROW ]
##
## The known suffix of the stack is as follows:
## lseparated_nonempty_list_inner(dot,type_id_str) DOT eols
Expand All @@ -4394,8 +4394,8 @@ program: MODULE UIDENT EOL LET UIDENT DOT WHILE
##
## Ends in an error in state: 90.
##
## lseparated_nonempty_list_inner(dot,type_id_str) -> lseparated_nonempty_list_inner(dot,type_id_str) DOT . type_id_str [ WHEN THICKARROW STAR SLASH SEMI RPAREN RCARET RBRACK RBRACE PIPE LPAREN LCARET INFIX_90 INFIX_80 INFIX_70 INFIX_60 INFIX_50 INFIX_40 INFIX_30 INFIX_120 INFIX_110 INFIX_100 FROM EQUAL EOL EOF ELSE DOT DASH COMMA COLON AS ARROW ]
## lseparated_nonempty_list_inner(dot,type_id_str) -> lseparated_nonempty_list_inner(dot,type_id_str) DOT . eols type_id_str [ WHEN THICKARROW STAR SLASH SEMI RPAREN RCARET RBRACK RBRACE PIPE LPAREN LCARET INFIX_90 INFIX_80 INFIX_70 INFIX_60 INFIX_50 INFIX_40 INFIX_30 INFIX_120 INFIX_110 INFIX_100 FROM EQUAL EOL EOF ELSE DOT DASH COMMA COLON AS ARROW ]
## lseparated_nonempty_list_inner(dot,type_id_str) -> lseparated_nonempty_list_inner(dot,type_id_str) DOT . type_id_str [ WHEN THICKARROW STAR SLASH SEMI RPAREN RCARET RBRACK RBRACE PIPE LPAREN LCARET INFIX_90 INFIX_80 INFIX_70 INFIX_60 INFIX_50 INFIX_40 INFIX_30 INFIX_120 INFIX_110 INFIX_100 FROM EQUAL EOL EOF ELSE DOT DASH COMMA COLON AS THICKARROW ]
## lseparated_nonempty_list_inner(dot,type_id_str) -> lseparated_nonempty_list_inner(dot,type_id_str) DOT . eols type_id_str [ WHEN THICKARROW STAR SLASH SEMI RPAREN RCARET RBRACK RBRACE PIPE LPAREN LCARET INFIX_90 INFIX_80 INFIX_70 INFIX_60 INFIX_50 INFIX_40 INFIX_30 INFIX_120 INFIX_110 INFIX_100 FROM EQUAL EOL EOF ELSE DOT DASH COMMA COLON AS THICKARROW ]
##
## The known suffix of the stack is as follows:
## lseparated_nonempty_list_inner(dot,type_id_str) DOT
Expand Down Expand Up @@ -4579,7 +4579,7 @@ program: MODULE UIDENT EOL LPAREN WASMI64 EOL WHILE
##
## Ends in an error in state: 113.
##
## rparen -> eols . RPAREN [ WHILE WHEN WASMI64 WASMI32 WASMF64 WASMF32 VOID UIDENT TYPE TRUE THROW THICKARROW STRING STAR SLASH SEMI RPAREN RECORD RCARET RBRACK RBRACE PREFIX_150 PIPE NUMBER_INT NUMBER_FLOAT MATCH LPAREN LIDENT LET LCARET LBRACKRCARET LBRACK LBRACE INT64 INT32 INFIX_ASSIGNMENT_10 INFIX_90 INFIX_80 INFIX_70 INFIX_60 INFIX_50 INFIX_40 INFIX_30 INFIX_120 INFIX_110 INFIX_100 INCLUDE IF GETS FUN FROM FOR FLOAT64 FLOAT32 FALSE FAIL PROVIDE EQUAL EOL EOF ENUM ELSE DOT DASH CONTINUE COMMA COLON CHAR BREAK BIGINT AT ASSERT AS ARROW ]
## rparen -> eols . RPAREN [ WHILE WHEN WASMI64 WASMI32 WASMF64 WASMF32 VOID UIDENT TYPE TRUE THROW THICKARROW STRING STAR SLASH SEMI RPAREN RECORD RCARET RBRACK RBRACE PREFIX_150 PIPE NUMBER_INT NUMBER_FLOAT MATCH LPAREN LIDENT LET LCARET LBRACKRCARET LBRACK LBRACE INT64 INT32 INFIX_ASSIGNMENT_10 INFIX_90 INFIX_80 INFIX_70 INFIX_60 INFIX_50 INFIX_40 INFIX_30 INFIX_120 INFIX_110 INFIX_100 INCLUDE IF GETS FUN FROM FOR FLOAT64 FLOAT32 FALSE FAIL PROVIDE EQUAL EOL EOF ENUM ELSE DOT DASH CONTINUE COMMA COLON CHAR BREAK BIGINT AT ASSERT AS THICKARROW ]
##
## The known suffix of the stack is as follows:
## eols
Expand Down Expand Up @@ -5058,7 +5058,7 @@ program: MODULE UIDENT EOL RECORD UIDENT LCARET LIDENT EOL WHILE
##
## Ends in an error in state: 86.
##
## rcaret -> eols . RCARET [ WHEN THICKARROW STAR SLASH SEMI RPAREN RCARET RBRACK RBRACE PIPE LCARET LBRACE INFIX_90 INFIX_80 INFIX_70 INFIX_60 INFIX_50 INFIX_40 INFIX_30 INFIX_120 INFIX_110 INFIX_100 FROM EQUAL EOL EOF ELSE DASH COMMA COLON AS ARROW ]
## rcaret -> eols . RCARET [ WHEN THICKARROW STAR SLASH SEMI RPAREN RCARET RBRACK RBRACE PIPE LCARET LBRACE INFIX_90 INFIX_80 INFIX_70 INFIX_60 INFIX_50 INFIX_40 INFIX_30 INFIX_120 INFIX_110 INFIX_100 FROM EQUAL EOL EOF ELSE DASH COMMA COLON AS THICKARROW ]
##
## The known suffix of the stack is as follows:
## eols
Expand Down Expand Up @@ -5839,7 +5839,7 @@ program: MODULE UIDENT EOL WASMI64 COLON WHILE

Expected a type to complete the type annotation.

program: MODULE UIDENT EOL WASMI64 COLON FUN LIDENT ARROW EOL WHILE
program: MODULE UIDENT EOL WASMI64 COLON FUN LIDENT THICKARROW EOL WHILE
##
## Ends in an error in state: 78.
##
Expand All @@ -5854,9 +5854,9 @@ program: MODULE UIDENT EOL WASMI64 COLON FUN LIDENT ARROW EOL WHILE
## may provide an INCOMPLETE view of the future (what was expected next).
## In state 3, spurious reduction of production nonempty_list(eol) -> EOL
## In state 5, spurious reduction of production eols -> nonempty_list(eol)
## In state 77, spurious reduction of production arrow -> ARROW eols
## In state 77, spurious reduction of production arrow -> THICKARROW eols
##
program: MODULE UIDENT EOL WASMI64 COLON FUN LPAREN RPAREN ARROW EOL WHILE
program: MODULE UIDENT EOL WASMI64 COLON FUN LPAREN RPAREN THICKARROW EOL WHILE
##
## Ends in an error in state: 122.
##
Expand All @@ -5871,7 +5871,22 @@ program: MODULE UIDENT EOL WASMI64 COLON FUN LPAREN RPAREN ARROW EOL WHILE
## may provide an INCOMPLETE view of the future (what was expected next).
## In state 3, spurious reduction of production nonempty_list(eol) -> EOL
## In state 5, spurious reduction of production eols -> nonempty_list(eol)
## In state 77, spurious reduction of production arrow -> ARROW eols
## In state 77, spurious reduction of production arrow -> THICKARROW eols
##
program: MODULE UIDENT EOL UIDENT COLON FUN UIDENT THICKARROW YIELD
##
## Ends in an error in state: 217.
##
## typ -> FUN data_typ thickarrow . typ [ WHEN THICKARROW STAR SLASH SEMI RPAREN RCARET RBRACK RBRACE PIPE LCARET INFIX_90 INFIX_80 INFIX_70 INFIX_60 INFIX_50 INFIX_40 INFIX_30 INFIX_120 INFIX_110 INFIX_100 FROM EQUAL EOL EOF ELSE DASH COMMA COLON AS AND ]
##
## The known suffix of the stack is as follows:
## FUN data_typ thickarrow
##
## WARNING: This example involves spurious reductions.
## This implies that, although the LR(1) items shown above provide an
## accurate view of the past (what has been recognized so far), they
## may provide an INCOMPLETE view of the future (what was expected next).
## In state 37, spurious reduction of production thickarrow -> THICKARROW
##

Expected a type for the result of the function type.
Expand Down Expand Up @@ -6059,31 +6074,31 @@ program: MODULE UIDENT EOL WASMI64 COLON LPAREN UIDENT WHEN

Expected `)` for a grouped type or a comma followed by more types for a tuple type.

program: MODULE UIDENT EOL WASMI64 COLON UIDENT ARROW EOL WHILE
program: MODULE UIDENT EOL UIDENT COLON FUN UIDENT YIELD
##
## Ends in an error in state: 107.
## Ends in an error in state: 216.
##
## typ -> data_typ arrow . typ [ WHEN THICKARROW STAR SLASH SEMI RPAREN RCARET RBRACK RBRACE PIPE LCARET INFIX_90 INFIX_80 INFIX_70 INFIX_60 INFIX_50 INFIX_40 INFIX_30 INFIX_120 INFIX_110 INFIX_100 FROM EQUAL EOL EOF ELSE DASH COMMA COLON AS ]
## typ -> FUN data_typ . thickarrow typ [ WHEN THICKARROW STAR SLASH SEMI RPAREN RCARET RBRACK RBRACE PIPE LCARET INFIX_90 INFIX_80 INFIX_70 INFIX_60 INFIX_50 INFIX_40 INFIX_30 INFIX_120 INFIX_110 INFIX_100 FROM EQUAL EOL EOF ELSE DASH COMMA COLON AS AND ]
##
## The known suffix of the stack is as follows:
## data_typ arrow
## FUN data_typ
##
## WARNING: This example involves spurious reductions.
## This implies that, although the LR(1) items shown above provide an
## accurate view of the past (what has been recognized so far), they
## may provide an INCOMPLETE view of the future (what was expected next).
## In state 3, spurious reduction of production nonempty_list(eol) -> EOL
## In state 5, spurious reduction of production eols -> nonempty_list(eol)
## In state 77, spurious reduction of production arrow -> ARROW eols
## In state 106, spurious reduction of production qualified_uid -> lseparated_nonempty_list_inner(dot,type_id_str)
## In state 167, spurious reduction of production data_typ -> qualified_uid
##

Expected a type for the result of the function type.
# This error can't appear as the FUN token wouldn't have been injected.
Expected `=>` followed by the function type's result type.

program: MODULE UIDENT EOL WASMI64 COLON UIDENT LCARET EOL WHILE
##
## Ends in an error in state: 82.
##
## data_typ -> type_id lcaret . typs rcaret [ WHEN THICKARROW STAR SLASH SEMI RPAREN RCARET RBRACK RBRACE PIPE LCARET INFIX_90 INFIX_80 INFIX_70 INFIX_60 INFIX_50 INFIX_40 INFIX_30 INFIX_120 INFIX_110 INFIX_100 FROM EQUAL EOL EOF ELSE DASH COMMA COLON AS ARROW ]
## data_typ -> type_id lcaret . typs rcaret [ WHEN THICKARROW STAR SLASH SEMI RPAREN RCARET RBRACK RBRACE PIPE LCARET INFIX_90 INFIX_80 INFIX_70 INFIX_60 INFIX_50 INFIX_40 INFIX_30 INFIX_120 INFIX_110 INFIX_100 FROM EQUAL EOL EOF ELSE DASH COMMA COLON AS THICKARROW ]
##
## The known suffix of the stack is as follows:
## type_id lcaret
Expand All @@ -6103,7 +6118,7 @@ program: MODULE UIDENT EOL WASMI64 COLON UIDENT LCARET UIDENT RPAREN
##
## Ends in an error in state: 83.
##
## data_typ -> type_id lcaret typs . rcaret [ WHEN THICKARROW STAR SLASH SEMI RPAREN RCARET RBRACK RBRACE PIPE LCARET INFIX_90 INFIX_80 INFIX_70 INFIX_60 INFIX_50 INFIX_40 INFIX_30 INFIX_120 INFIX_110 INFIX_100 FROM EQUAL EOL EOF ELSE DASH COMMA COLON AS ARROW ]
## data_typ -> type_id lcaret typs . rcaret [ WHEN THICKARROW STAR SLASH SEMI RPAREN RCARET RBRACK RBRACE PIPE LCARET INFIX_90 INFIX_80 INFIX_70 INFIX_60 INFIX_50 INFIX_40 INFIX_30 INFIX_120 INFIX_110 INFIX_100 FROM EQUAL EOL EOF ELSE DASH COMMA COLON AS THICKARROW ]
##
## The known suffix of the stack is as follows:
## type_id lcaret typs
Expand Down
12 changes: 4 additions & 8 deletions compiler/src/parsing/parser.mly
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module Grain_parsing = struct end
%token <string> STRING BYTES CHAR
%token LBRACK LBRACKRCARET RBRACK LPAREN RPAREN LBRACE RBRACE LCARET RCARET
%token COMMA SEMI AS
%token THICKARROW ARROW
%token THICKARROW
%token EQUAL GETS
%token UNDERSCORE
%token COLON QUESTION DOT ELLIPSIS
Expand Down Expand Up @@ -98,7 +98,6 @@ module Grain_parsing = struct end
lcaret
comma
eos
arrow
thickarrow
equal
const
Expand Down Expand Up @@ -189,9 +188,6 @@ comma:
%inline dot:
| DOT opt_eols {}

arrow:
| ARROW opt_eols {}

thickarrow:
| THICKARROW opt_eols {}

Expand Down Expand Up @@ -299,9 +295,9 @@ data_typ:
| qualified_uid %prec _below_infix { Type.constr ~loc:(to_loc $loc) $1 [] }

typ:
| data_typ arrow typ { Type.arrow ~loc:(to_loc $loc) [TypeArgument.mk ~loc:(to_loc $loc($1)) Unlabeled $1] $3 }
| FUN LIDENT arrow typ { Type.arrow ~loc:(to_loc $loc) [TypeArgument.mk ~loc:(to_loc $loc($2)) Unlabeled (Type.var $2)] $4 }
| FUN lparen arg_typs? rparen arrow typ { Type.arrow ~loc:(to_loc $loc) (Option.value ~default:[] $3) $6 }
| FUN data_typ thickarrow typ { Type.arrow ~loc:(to_loc $loc) [TypeArgument.mk ~loc:(to_loc $loc($2)) Unlabeled $2] $4 }
| FUN LIDENT thickarrow typ { Type.arrow ~loc:(to_loc $loc) [TypeArgument.mk ~loc:(to_loc $loc($2)) Unlabeled (Type.var $2)] $4 }
| FUN lparen arg_typs? rparen thickarrow typ { Type.arrow ~loc:(to_loc $loc) (Option.value ~default:[] $3) $6 }
| lparen tuple_typs rparen { Type.tuple ~loc:(to_loc $loc) $2 }
| lparen typ rparen { $2 }
| LIDENT { Type.var ~loc:(to_loc $loc) $1 }
Expand Down
72 changes: 69 additions & 3 deletions compiler/src/parsing/wrapped_lexer.re
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ let fake_triple = (t, (_, pos, _)) => (t, pos, pos);

exception Lex_balanced_failed(list(positioned(token)), option(exn));
exception Lex_fast_forward_failed(list(positioned(token)), option(exn));
exception Lex_data_typ_failed(list(positioned(token)), option(exn));

let inject_fun =
fun
Expand All @@ -66,8 +67,7 @@ let inject_fun =

let is_triggering_token =
fun
| (THICKARROW, _, _)
| (ARROW, _, _) => true
| (THICKARROW, _, _) => true
| _ => false;

let rec lex_fast_forward_step = (state, stop, acc, tok) => {
Expand Down Expand Up @@ -144,12 +144,28 @@ and check_id_fn = (state, closing, acc) => {
lex_balanced_step(state, closing, acc, tok);
}

and check_data_typ = (state, closing, acc) => {
switch (lex_data_typ(state)) {
| exception (Lex_data_typ_failed([token, ...rest], exn)) =>
lex_balanced_step(state, closing, rest @ acc, token)
| [token, ...rest] =>
let acc =
switch (token) {
| (THICKARROW, _, _) => inject_fun(acc)
| _ => acc
};
lex_balanced_step(state, closing, rest @ acc, token);
| _ => failwith("Impossible: wrapped_lexer check_data_typ not matched")
};
}

and lex_balanced_step = (state, closing, acc, tok) => {
let acc = [tok, ...acc];
switch (tok, closing) {
| ((RPAREN, _, _), RPAREN)
| ((RBRACE, _, _), RBRACE)
| ((RBRACK, _, _), RBRACK) =>
| ((RBRACK, _, _), RBRACK)
| ((RCARET, _, _), RCARET) =>
pop_fn_ctx(state);
acc;
| ((RPAREN | RBRACE | RBRACK | EOF, _, _), _) =>
Expand Down Expand Up @@ -182,6 +198,7 @@ and lex_balanced_step = (state, closing, acc, tok) => {
| LPAREN => check_lparen_fn(state, closing, [triple', ...tokens @ acc])
| LIDENT(_)
| UNDERSCORE => check_id_fn(state, closing, [triple', ...tokens @ acc])
| UIDENT(_) => check_data_typ(state, closing, [triple', ...tokens @ acc])
| _ =>
// Recurse normally
lex_balanced_step(state, closing, tokens @ acc, triple')
Expand All @@ -208,6 +225,8 @@ and lex_balanced_step = (state, closing, acc, tok) => {
)
| ((LIDENT(_) | UNDERSCORE, _, _), _) when !ignore_fns(state) =>
check_id_fn(state, closing, acc)
| ((UIDENT(_), p, _), _) when !ignore_fns(state) =>
check_data_typ(state, closing, acc)
| _ => lex_balanced(state, closing, acc)
};
}
Expand Down Expand Up @@ -244,6 +263,52 @@ and lookahead_fun = (state, (tok, _, _) as lparen) =>
}
}

and lex_qualified_uid = (state, acc) => {
switch (token(state)) {
| exception exn => raise(Lex_data_typ_failed(acc, Some(exn)))
| (DOT, _, _) as dot =>
switch (token(state)) {
| exception exn => raise(Lex_data_typ_failed(acc, Some(exn)))
| (UIDENT(_), _, _) as uident =>
lex_qualified_uid(state, [uident, dot, ...acc])
| tok => raise(Lex_data_typ_failed([tok, dot, ...acc], None))
}
| token => [token, ...acc]
};
}

and lex_data_typ = state => {
switch (lex_qualified_uid(state, [])) {
| [(LCARET, _, _), ..._] as quid_tokens =>
switch (lex_balanced(~push=DiscoverFunctions, state, RCARET, [])) {
| exception (Lex_balanced_failed(tokens, exn)) =>
raise(Lex_data_typ_failed(tokens, exn))
| brack_tokens =>
let tokens = brack_tokens @ quid_tokens;
switch (token(state)) {
| exception exn => raise(Lex_data_typ_failed(tokens, Some(exn)))
| tok => [tok, ...tokens]
};
}
| tokens => tokens
};
}

and lookahead_fun_data_typ = (state, uident) => {
switch (lex_data_typ(state)) {
| exception (Lex_data_typ_failed(tokens, exn)) =>
state.queued_tokens = List.rev(tokens);
state.queued_exn = exn;
uident;
| [(THICKARROW, _, _), ..._] as tokens =>
state.queued_tokens = [uident, ...List.rev(tokens)];
fake_triple(FUN, uident);
| tokens =>
state.queued_tokens = List.rev(tokens);
uident;
};
}

and lookahead_match = state => {
switch (lex_fast_forward(state, LPAREN, [])) {
| exception (Lex_fast_forward_failed(tokens, exn)) =>
Expand Down Expand Up @@ -307,6 +372,7 @@ let token = state => {
tok;
}
}
| (UIDENT(_), _, _) as tok => lookahead_fun_data_typ(state, tok)
| token => token
}
| ([x, ...xs], _) =>
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/typed/oprint.re
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ and print_out_type_1 = ppf =>
if (parens) {
pp_print_char(ppf, ')');
};
pp_print_string(ppf, " ->");
pp_print_string(ppf, " =>");
pp_print_space(ppf, ());
print_out_type_1(ppf, ty2);
pp_close_box(ppf, ());
Expand Down
2 changes: 1 addition & 1 deletion compiler/test/graindoc/descriptions.expected.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Value Doc
### DescriptionGrainDoc.**docFunction**

```grain
docFunction : (x: Number) -> Number
docFunction : (x: Number) => Number
```

Function Doc
Expand Down
Loading

0 comments on commit c5cdab8

Please sign in to comment.