How to load a file myfile.ml that I can use it my file ? And where should I put this file to compilator find it ? I can't do it now. Thanks in advance!
you can also run utop with the -init option:
utop -init yourfile.ml
You don't say what kind of system you're using. It's also not clear whether you're trying to load code into the toplevel (the interpreter), use external functions from an OCaml program or something else. It would help if you explained more carefully.
In the meantime, here's a session with a Unix-like system (Mac OS X) that shows how to load a file into the toplevel:
$ cat myfile.ml
let f x = x + 1
$ ocaml
OCaml version 4.00.1
# #use "myfile.ml";;
val f : int -> int = <fun>
# f 14;;
- : int = 15
#
For this purpose, it doesn't matter too much where your file is. You just need to specify its name in the #use
directive. If you don't know how to specify a filename, that's not an OCaml problem--and it's probably the first thing you need to figure out :-)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With