Watch, recompile and reload code in the repl

Hello, new damler here!

Q1: There is any way to reload modules in the repl without having to restart it?

Q2. There is any way to watch daml files for changes and recompile code automatically when using daml start? daml start takes too long to start but it’s pretty quick to recompile so it doesn’t looks ideal to wrap the command with a bash script.

Hello @cortsf and welcome to the community. I hope you enjoy learning Daml and that you continue doing so.

You can add and remove modules to/from scope using :module +/- ModA ModB command in the REPL. See the documentation for more detail. But if you want to change the dar file, then to the best of my knowledge the dar file can only be passed to REPL on startup as a command line parameter, hence you can’t update the dar file loaded in REPL without restarting it.

You can’t automatically recompile based on changes to daml files. But you can rebuild the package and reset the ledger with updated package without fully stopping and restarting the sandbox and other components. Once daml start launches all the components, you should see the message in the terminal saying “Press ‘r’ to re-build and upload the package to the sandbox. Press ‘Ctrl-C’ to quit”. Just follow the suggestion and hit ‘r’.

1 Like

Thanks, I was looking to re-load the dar. For recompiling the dar automatically I think I can fake the r key press with a script and hook it to the emacs save function. Not fancy but it will work :blush: