{"id":16333946,"url":"https://github.com/nmattia/haskell-hot-swap","last_synced_at":"2025-07-26T15:16:18.761Z","repository":{"id":94700783,"uuid":"59557103","full_name":"nmattia/haskell-hot-swap","owner":"nmattia","description":"Hot swapping compiled code while keeping a websocket connection open","archived":false,"fork":false,"pushed_at":"2016-05-24T09:47:09.000Z","size":6,"stargazers_count":26,"open_issues_count":0,"forks_count":1,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-04T10:38:47.147Z","etag":null,"topics":["dynamic-loading","experimental","ghc","haskell","websocket-connection"],"latest_commit_sha":null,"homepage":"","language":"Haskell","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/nmattia.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}},"created_at":"2016-05-24T08:57:22.000Z","updated_at":"2023-07-12T19:14:39.000Z","dependencies_parsed_at":"2023-04-27T04:45:39.550Z","dependency_job_id":null,"html_url":"https://github.com/nmattia/haskell-hot-swap","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/nmattia/haskell-hot-swap","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nmattia%2Fhaskell-hot-swap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nmattia%2Fhaskell-hot-swap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nmattia%2Fhaskell-hot-swap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nmattia%2Fhaskell-hot-swap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nmattia","download_url":"https://codeload.github.com/nmattia/haskell-hot-swap/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nmattia%2Fhaskell-hot-swap/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267184149,"owners_count":24049128,"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-07-26T02:00:08.937Z","response_time":62,"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":["dynamic-loading","experimental","ghc","haskell","websocket-connection"],"created_at":"2024-10-10T23:37:01.782Z","updated_at":"2025-07-26T15:16:18.744Z","avatar_url":"https://github.com/nmattia.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"\nThe inspiration for this came from [this\npost](http://purelyfunctional.org/posts/2016-05-20-dynamic-loading-haskell-module.html)\nby [cocreature](https://github.com/cocreature)\n\n# Toy example of Haskell hot swap of compiled code\n\nThis toy example consists of three parts:\n\n * client: the client is built with `build-client.sh` and run with `./client`.\n   The client communicates with a server over websocket connection.\n\n * Processing.o: the processing module, built with `build-processing.sh`. This\n   module is loaded dynamically by the server.\n\n * server: the server is build with `build-server.sh` and run with `./server`.\n\nWhenever the client sends a message to the server, the server processes the\nstring using `Processing.o`, unless the string is `:reload`. When the string is\n`:reload`, the server reloads the processing module. The websocket connection\nis never closed.\n\n## Usage\n\n``` bash\n./build-server.sh\n./build-processing.sh\n./build-client.sh\n\n./server \u0026\n./client\n\u003e hi\n\u003e You said 'hi'\n```\n\nAt this point, you can modify `src/Processing.sh`, and call\n`./build-processing.sh`. Whenever you send `:reload` to the server (through the\nclient) the server will reload the processing module while keeping the\nconnection open.\n\n## Gotchas\n\nThe `Processing` module needs to be linked manually. In order to link against\n`bytestring`, for instance, you need to find where your bytestring library is\ninstalled (if you are using Stack, try running `stack path --global-pkg-db` and\nlook around for something called `bytesXXXX.a`). In\n[build-processing.sh](build-processing.sh) I load the `bytestring` library from\nthe environment (I suggest using [direnv](http://direnv.net)).\n\n\n## Improvements\n\nI'll soon add another example using the\n[plugins](https://hackage.haskell.org/package/plugins) package, which also uses\ninterface files to make sure we are loading consistent code. However, I haven't\nfigured out how to automatically link against the libraries. Unfortunately,\n`cabal` seems to simply use `ghc`, which itself only links if the output\nproduces an executable (exports a `main` function). Please get in touch if you\nhave ideas.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnmattia%2Fhaskell-hot-swap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnmattia%2Fhaskell-hot-swap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnmattia%2Fhaskell-hot-swap/lists"}