https://github.com/let-def/hotcaml Skip to content Sign up * Why GitHub? + Features + Mobile + Actions + Codespaces + Packages + Security + Code review + Issues + Integrations + GitHub Sponsors + Customer stories * Team * Enterprise * Explore + Explore GitHub + Learn and contribute + Topics + Collections + Trending + Learning Lab + Open source guides + Connect with others + The ReadME Project + Events + Community forum + GitHub Education + GitHub Stars program * Marketplace * Pricing + Plans + Compare plans + Contact Sales + Education [ ] * # In this repository All GitHub | Jump to | * No suggested jump to results * # In this repository All GitHub | Jump to | * # In this user All GitHub | Jump to | * # In this repository All GitHub | Jump to | Sign in Sign up {{ message }} let-def / hotcaml Public * Notifications * Fork 0 * Star 37 * Hotcaml: an interpreter with watching and reloading AGPL-3.0 License 37 stars 0 forks Star Notifications * Code * Issues 0 * Pull requests 0 * Actions * Projects 0 * Wiki * Security * Insights More * Code * Issues * Pull requests * Actions * Projects * Wiki * Security * Insights master Switch branches/tags [ ] Branches Tags Could not load branches Nothing to show {{ refName }} default View all branches Could not load tags Nothing to show {{ refName }} default View all tags 1 branch 0 tags Code Latest commit @let-def let-def Create README.md ... 5fed12a Jan 18, 2022 Create README.md 5fed12a Git stats * 11 commits Files Permalink Failed to load latest commit information. Type Name Latest commit message Commit time .gitignore generate opam file May 27, 2021 LICENSE Create LICENSE Jan 18, 2022 Makefile Prepare for first publication Jan 18, 2022 README.md Create README.md Jan 18, 2022 dune generate opam file May 27, 2021 dune-project generate opam file May 27, 2021 hotcaml.ml Fix hotreload after parse error (don't drop dependencies) Jun 11, 2021 hotcaml.opam generate opam file May 27, 2021 hotcaml_lwt.ml Fix hotreload after parse error (don't drop dependencies) Jun 11, 2021 hotlink.ml Add Hotlink helper May 27, 2021 hotlink.mli Add Hotlink helper May 27, 2021 test.ml Initial May 23, 2021 test1.ml Initial May 23, 2021 test_unload.ml Add unload hook test Jan 18, 2022 View code Hotcaml: an OCaml interpreter with watching and reloading Starting hotcaml Synchronous and asynchronous frontends Observing reload process Cold execution README.md Hotcaml: an OCaml interpreter with watching and reloading Hotcaml is an OCaml interpreter that starts from a source file and loads it dependencies. When one of the source file changes and passes the typechecker, it is reloaded, as well as all its reverse dependencies. To get started, clone the repository and type make. Two frontends are built: hotcaml.exe and hotcaml_lwt.exe. Starting hotcaml An hotcaml invocation takes three kinds of arguments: hotcaml [ -package pkg ]* [ -I path ]* entrypoint.ml* The pkg 's should be valid findlib package names. They will be loaded in order during startup. The path's are paths that will be looked up for dependencies. Finally, the entrypoints are the actual code that we want to interpret. Each entrypoint is loaded and interpreted in order. Dependencies of an entrypoint are looked up in the path's and then in the loaded packages. Once execution of the entrypoints is done, the interpreter will watch the disk for changes. If one of the source file change, it is reloaded and interpretation resumes from this module, followed by all its reverse dependencies. If one of the dependency does not typecheck, reloading is postponed until all errors are solved. Synchronous and asynchronous frontends Contrary to the normal execution of an OCaml program, modules can be loaded and unloaded, multiples times, during the execution. The synchronous hotcaml only look for changes after execution is done. This is not really convenient for interactive programs, where we might want to reload during execution rather than after. hotcaml_lwt provides an asynchronous frontend: lwt threads continue to execute after loading, and modules can be reloaded concurrentlly. Observing reload process The Hotlink module can be used to customize behavior of hot-loaded programs. Hotlink.is_hot_loaded () : bool is true only when called from a module that has been hot-loaded. Hotlink.is_hot_unloaded () : bool is true only when called from a module that was hot-loaded and has now been unloaded. Hotlink.on_unload : (unit -> unit) -> unit allows to register a callback that will be invoked when an hot-loaded module is unloaded. Hotlink.on_unload_or_at_exit : (unit -> unit) -> unit calls the callback either during unloading or when exiting the program. Cold execution In a normal, "cold" execution, the Hotlink module exhibits a compatible, reasonable, behavior: * Hotlink.is_hot_loaded and Hotlink.is_hot_unloaded are always false * Hotlink.on_unload does nothing * Hotlink.on_unload_or_at_exit behaves like at_exit This allows to have modules that are compatible with both classical OCaml and with hotcaml, and adjust their behavior based on the situation. About Hotcaml: an interpreter with watching and reloading Resources Readme License AGPL-3.0 License Stars 37 stars Watchers 2 watching Forks 0 forks Releases No releases published Packages 0 No packages published Languages * OCaml 99.8% * Makefile 0.2% * (c) 2022 GitHub, Inc. * Terms * Privacy * Security * Status * Docs * Contact GitHub * Pricing * API * Training * Blog * About You can't perform that action at this time. You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.