···1515 Option.iter (fun s -> log ("stdout: " ^ s)) o.stdout;
1616 Option.iter (fun s -> log ("stderr: " ^ s)) o.stderr;
1717 Option.iter (fun s -> log ("sharp_ppf: " ^ s)) o.sharp_ppf;
1818- Option.iter (fun s -> log ("caml_ppf: " ^ s)) o.caml_ppf
1818+ Option.iter (fun s -> log ("caml_ppf: " ^ s)) o.caml_ppf;
1919+ let strloc (line,col) =
2020+ "(" ^ string_of_int line ^ "," ^ string_of_int col ^ ")"
2121+ in
2222+ Option.iter (fun h ->
2323+ let open Toplevel_api_gen in
2424+ log ("highlight " ^ strloc (h.line1, h.col1) ^ " to " ^ strloc (h.line2, h.col2))) o.highlight
19252026let _ =
2127 let ( let* ) = Lwt_result.bind in
+7-1
idl/toplevel_api.ml
···34343535type init_libs = { cmi_urls : string list; cmas : cma list } [@@deriving rpcty]
36363737-(** For now we are only using a simple error type *)
3837type err = InternalError of string [@@deriving rpcty]
39384039module E = Idl.Error.Make (struct
···6261 let implementation = implement description
6362 let unit_p = Param.mk Types.unit
6463 let phrase_p = Param.mk Types.string
6464+ let typecheck_result_p = Param.mk exec_result
6565 let exec_result_p = Param.mk exec_result
6666 let completion_p = Param.mk completion_result
6767···8888 "must be initialised first.";
8989 ]
9090 (unit_p @-> returning exec_result_p err)
9191+9292+ let typecheck =
9393+ declare
9494+ "typecheck"
9595+ [ "Typecheck a phrase without actually executing it." ]
9696+ (phrase_p @-> returning typecheck_result_p err)
91979298 let exec =
9399 declare "exec"
+9-6
idl/toplevel_api_gen.ml
···441441 and _ = init_libs
442442 end[@@ocaml.doc "@inline"][@@merlin.hide ]
443443type err =
444444- | InternalError of string [@@ocaml.doc
445445- " For now we are only using a simple error type "]
446446-[@@deriving rpcty]
444444+ | InternalError of string [@@deriving rpcty]
447445include
448446 struct
449447 let _ = fun (_ : err) -> ()
···481479 and err =
482480 {
483481 Rpc.Types.name = "err";
484484- Rpc.Types.description =
485485- ["For now we are only using a simple error type"];
482482+ Rpc.Types.description = [];
486483 Rpc.Types.ty = typ_of_err
487484 }
488485 let _ = typ_of_err
···511508 let implementation = implement description
512509 let unit_p = Param.mk Types.unit
513510 let phrase_p = Param.mk Types.string
511511+ let typecheck_result_p = Param.mk exec_result
514512 let exec_result_p = Param.mk exec_result
515513 let completion_p = Param.mk completion_result
516514 let init_libs =
···520518 "MUST include the urls from which they may be fetched"]
521519 init_libs
522520 let init =
523523- declare "init" ["Initialise the toplevel."]
521521+ declare "init"
522522+ ["Initialise the toplevel. This must be called before any other API."]
524523 (init_libs @-> (returning unit_p err))
525524 let setup =
526525 declare "setup"
···528527 "printed when starting a toplevel. Note that the toplevel";
529528 "must be initialised first."]
530529 (unit_p @-> (returning exec_result_p err))
530530+ let typecheck =
531531+ declare "typecheck"
532532+ ["Typecheck a phrase without actually executing it."]
533533+ (phrase_p @-> (returning typecheck_result_p err))
531534 let exec =
532535 declare "exec"
533536 ["Execute a phrase using the toplevel. The toplevel must have been";