Skip to content

Commit

Permalink
chore: Simplify Function inlays
Browse files Browse the repository at this point in the history
  • Loading branch information
spotandjake committed Feb 2, 2024
1 parent e94e17e commit 7925321
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions compiler/src/language_server/inlayhint.re
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ let build_hint =
{label: ": " ++ message, position};
};

let rec string_of_typ = (typ: Types.type_expr) => {
switch (typ.desc) {
| TTyArrow(_, _, _) => "Function"
| TTyLink(type_expr)
| TTySubst(type_expr) => string_of_typ(type_expr)
| _ => Printtyp.string_of_type_scheme(typ)
};
};

let find_hints = program => {
let hints = ref([]);
open Typedtree;
Expand Down Expand Up @@ -72,8 +81,8 @@ let find_hints = program => {
line: bind_end.pos_lnum - 1,
character: bind_end.pos_cnum - bind_end.pos_bol,
};
let typeSignature =
Printtyp.string_of_type_scheme(vb_pat.pat_type);
let typ = vb_pat.pat_type;
let typeSignature = string_of_typ(typ);
hints := [build_hint(p, typeSignature), ...hints^];
| _ => ()
}
Expand Down

0 comments on commit 7925321

Please sign in to comment.