{"id":31027071,"url":"https://github.com/matthewelse/sriracha","last_synced_at":"2025-09-13T18:51:15.450Z","repository":{"id":309235341,"uuid":"1035156839","full_name":"matthewelse/sriracha","owner":"matthewelse","description":"🌶️ ⚡️ hot reloading ⚡️ for OCaml","archived":false,"fork":false,"pushed_at":"2025-08-10T17:22:51.000Z","size":40,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-10T19:12:54.229Z","etag":null,"topics":["hot-reload","ocaml","ocaml-library"],"latest_commit_sha":null,"homepage":"","language":"OCaml","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/matthewelse.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-08-09T19:19:15.000Z","updated_at":"2025-08-10T17:22:55.000Z","dependencies_parsed_at":"2025-08-10T19:24:31.509Z","dependency_job_id":null,"html_url":"https://github.com/matthewelse/sriracha","commit_stats":null,"previous_names":["matthewelse/sriracha"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/matthewelse/sriracha","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matthewelse%2Fsriracha","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matthewelse%2Fsriracha/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matthewelse%2Fsriracha/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matthewelse%2Fsriracha/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/matthewelse","download_url":"https://codeload.github.com/matthewelse/sriracha/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matthewelse%2Fsriracha/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275013280,"owners_count":25390481,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-13T02:00:10.085Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hot-reload","ocaml","ocaml-library"],"created_at":"2025-09-13T18:51:13.201Z","updated_at":"2025-09-13T18:51:15.440Z","avatar_url":"https://github.com/matthewelse.png","language":"OCaml","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e🌶️ \u003cspan style=\"font-family: monospace\"\u003esriracha\u003c/span\u003e 🌶️\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ci align=\"center\"\u003eType-safe ⚡️ hot \u003cs\u003esauce\u003c/s\u003e source reloading ⚡️ for OCaml 🐪\u003c/i\u003e\n\u003c/p\u003e\n\n## Introduction\n\nSriracha is a library for type-safe hot-reloading of OCaml functions, inspired by\n[subsecond](https://github.com/DioxusLabs/dioxus/tree/main/packages/subsecond).\n\n## Usage\n\n🌶️ `sriracha` 🌶️ consist of two parts: the loader, and the application.\n\nIn short, the loader is a lightweight application that dynamically loads your application,\nstarts it, and decides when to live-reload your application. The `sriracha` library provides\nthe glue between the two.\n\nBoth the loader and application should depend on the core Sriracha library. Your application\nshould (perhaps surprisingly) depend on your loader[^loader], `ppx_sriracha`, and `ppx_typerep_conv`.\n\n[^loader]: This allows your loader to specify what type of main function it expects (`unit -\u003e unit`,\n`unit -\u003e unit Deferred.t`, etc.).\n\nBasic example of loaders for Lwt (+Dream) and Async are provided in `loader/`, but for more\ncomplicated use-cases, you likely want to build your own loader.\n\nSee [hot_loader_async.ml](loader/async/hot_loader_async.ml) for a basic hot-loader built on top of async.\n\nSee [example.ml](example/basic/basic.ml) for an example application.\n\n\u003ch3\u003eRunning the example application\u003c/h3\u003e\n\n```bash\n# run this in one terminal\n$ dune build example/basic/basic.cmxs loader/async/bin/loader.exe --watch\n\n# in another terminal\n$ _build/default/loader/async/bin/loader.exe _build/default/example/basic/basic.cmxs\n```\n\nYou can then make edits to `example.ml` (e.g. changing the text printed by `do_something`).\nNotice how only changes in, or \"downstream\" of `do_something` affect the runtime behaviour.\n\n\u003ch3\u003eRunning the example dream application\u003c/h3\u003e\n\n```bash\n# run this in one terminal\n$ dune build example/dream/dream_example.cmxs loader/lwt/bin/loader.exe --watch\n\n# in another terminal\n$ _build/default/loader/lwt/bin/loader.exe _build/default/example/dream/dream_example.cmxs -L digestif.c -L dream\n```\n\nYou can then make edits to `server.ml` (e.g. changing the text returned to the user).\n\n## How it works\n\nSriracha makes use of the OCaml [`Dynlink`](https://ocaml.org/manual/5.3/api/Dynlink.html#top)\nlibrary. It builds a type-safe jump table from function name to function pointer, and redirects\ncalls to hot-reloadable functions via the jump table. This jump table is updated as the program\nlive reloads.\n\nThere are two parts to an application using Sriracha: the loader, and the application.\n\nThe loader is a very simple (approximately application agnostic) executable, which bundles\nall of the application's dependencies (see notes below -- this is quite annoying), and is\nresponsible for (re-)loading the application, and launching it.\n\nThe application is just the application you want to live reload. For the most part, all you\nneed to do is to define an entry point for the loader to call, and to annotate reloadable\nfunctions as `let%hot`.\n\nIt's likely that a more complete integration with this library will require e.g. your web\nframework to be aware of hot reloading. In the future, we'll likely provide hooks to\nreceive updates about e.g. hot reloads happening to clean-up after old versions of your\ncode as necessary.\n\n\u003c!-- for some reason this doesn't render properly as ## without this comment here --\u003e\n## Ideas\n\n- [x] add a flag to `ppx_sriracha` to statically remove all of the hot-reloading points in\n  release builds.\n- [ ] handle nested function calls correctly (e.g. detect a new function being called\n  within an old function.\n- [ ] add some better notes about caveats/limitations of the library, e.g. the interaction\n  with global state, etc.\n- [x] build a more complete example, e.g. a web server with Dream.\n- [ ] thread safety?\n\n\u003c!-- for some reason this doesn't render properly as ## --\u003e\n\u003ch2\u003eMisc notes\u003c/h2\u003e\n\nReasons this was hard to get right:\n\n- Dependencies have to be linked into the loader, and it's quite easy for those dependencies\n  to accidentally be dead-code eliminated.\n- User applications can't have both dynamic and static versions of a single application\n  (which would also solve the dependency problem), since you end up with module name clashes.\n  _Maybe we can do some name mangling?_\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatthewelse%2Fsriracha","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmatthewelse%2Fsriracha","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatthewelse%2Fsriracha/lists"}