Search code examples
visual-studio-codeocamldevelopment-environment

How can I print the output of each line in an .ml file


I have an .ml file and I want to be able to run it line-by-line as if I was typing it in the top-level ocaml interpreter

The problem is, if I simply type "ocaml file.ml" in the terminal, I don't get the output from the REPL, and I can't debug and compile it, since it contains the #use directive.

I've tried using several different extensions for Visual Code, but none of them worked for me.

Is there anything I can do to simply be able to run the file and get the output from the ocaml REPL?

Thanks.


Solution

  • I never used VS Code (if you are referring it as 'Visual Code'), but SLIME in emacs or its Vim version of it is probably what you want.

    Based on that, I tried searching for an VS Code extension that does works like SLIME: SendToREPL. (Disclaimer: the author claims it works for Python, Node, and reply (not sure what it is though), but I am quite confident that it will work for OCaml REPL/UTop.)