How to run ml/ocaml file without compiling?

I’m not an expert, but:

  1. #use” is more-primitive: it loads a file of source code, etc.
  2. #require” is related to findlib, and finds/loads a findlib package and its antecedents.

OK, so let me say that again: “#use” (from my experience/memory) loads a source-file, and is very, very primitive. So #use "topfind" looks for a file named “topfind” on the current search-path, and once found, parses/executes it. It’s very low-level.

I won’t describe what #require does, b/c it’s involved, but basically: go look at the findlib documentation.

#use also seems to prefer installed libraries:

utop # #use "test.ml";;
File "/home/gdweber/.opam/4.14.0/lib/base_quickcheck/test.ml", line 2, characters 8-17:
2 | include Test_intf
            ^^^^^^^^^
Error: Unbound module Test_intf
─( 18:15:45 )─< command 1 

To override this and load test.ml from my working directory, I needed to use the “./” prefix

utop # #use "./test.ml";;