简体   繁体   中英

how to reload OCaml modules in utop

Is it possible reload modules in OCaml's utop ?

My development workflow goes something like this when playing around with OCaml code:

First, open up a file example.ml in Vim and hack on it. Switch to another terminal and run utop . From within utop , load the code with the directive #use "example.ml";; .

Go back to Vim and make some changes in the code. After changing the code, I want to play around with the new changes. Go back to utop and rerun the directive #use "example.ml" .

It would be nice if there were a #reload directive that would reload all previously loaded modules, but there doesn't appear to be. Is there some way to easily reload all previously loaded modules?

Ideally this would work similarly to GHCi's :reload command.

At the time this question was asked, I believe dune had not yet established itself as the build system for OCaml. Using dune, you can simply launch a utop instance with locally defined libraries loaded (as explained here ) by doing :

$ dune utop <dir> -- <args>

Where is a directory under which dune will search (recursively) for all libraries that will be loaded

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM