-
Notifications
You must be signed in to change notification settings - Fork 248
Open
Labels
Description
I tried to write an Ocaml program in a scripting style, but I realized merlin (version 4.12-501) does not work with toplevel directives. The simplest example would be
$ cat a.ml
#use "topfind"
let () = print_endline "Hello, world!";;
$ ocaml a.ml
Hello, world!
$ ocamlmerlin single errors -filename a.ml < a.ml
{"class":"return","value":[{"start":{"line":1,"col":0},"end":{"line":1,"col":1},"type":"parser","sub":[],"valid":true,"message":"Syntax error"}],"notifications":[],"timing":{"clock":4,"cpu":3,"query":0,"pp":0,"reader":0,"ppx":0,"typer":3,"error":0}}The program I was trying to do looks like this
$ cat b.ml
#use "topfind"
#thread
#require "core"
open Core;;
let today = Date.create_exn ~y:2023 ~m:Month.Nov ~d:17;;
let yesterday = Date.create_exn ~y:2023 ~m:Month.Nov ~d:16;;
let () =
Printf.printf "%d\n" (Date.diff today yesterday);;
$ ocaml b.ml
1
$ ocamlmerlin single errors -filename b.ml < b.ml
{"class":"return","value":[{"start":{"line":1,"col":0},"end":{"line":1,"col":1},"type":"parser","sub":[],"valid":true,"message":"Syntax error"}],"notifications":[],"timing":{"clock":6,"cpu":5,"query":0,"pp":0,"reader":0,"ppx":0,"typer":5,"error":0}}I'm new to the language, and I have the feeling that this isn't how serious ocaml projects are designed to be run. But it's still useful for simple scripts and test out things.
The problem is similar to #1023 .
Reactions are currently unavailable