I'm currently playing with it to see if it would be useful to implement break-less hot-reloads across ghcid reboots in my upcoming static site generator: https://github.com/srid/ema
I use the foreign store to keep a TMVar of ws connection, but then I just realized that I need to somehow re-use the server thread too (across ghcid reboot)!
well, i'm using ghcid -T :main - so there is one process, but multiple threads may be forked (when haskell process exists, these threads won't be killed unless you clean them up manually)
i currently use race_ to have them killed when ghcid reboots, but right now i'm thinking maybe I should leave them running, but store the threadid in foreign-store and establish a communication mechanism with them so the rebooted process can talk with them.
the idea is that when you edit your blaze-html HTML DSL (or clay CSS DSL), and ghcid reloads the changed module and restarts main - the browser's websocket connection remains connected (so as to ensure a timely hot-reload)
Came across this interesting library:
https://hackage.haskell.org/package/foreign-store
It is used in https://github.com/j-mueller/ghci-websockets (which is pretty cool)
I'm currently playing with it to see if it would be useful to implement break-less hot-reloads across ghcid reboots in my upcoming static site generator: https://github.com/srid/ema
I use the foreign store to keep a TMVar of ws connection, but then I just realized that I need to somehow re-use the server thread too (across ghcid reboot)!
Would be happy to do pair programming on that ^^ right now
The upper one is horrifying, but the lower one is really cool :big_smile:
I imagine some
.pid
file and separate process would work, with downside of making communication with it more complicatedwell, i'm using
ghcid -T :main
- so there is one process, but multiple threads may be forked (when haskell process exists, these threads won't be killed unless you clean them up manually)i currently use
race_
to have them killed when ghcid reboots, but right now i'm thinking maybe I should leave them running, but store the threadid in foreign-store and establish a communication mechanism with them so the rebooted process can talk with them.the idea is that when you edit your blaze-html HTML DSL (or clay CSS DSL), and ghcid reloads the changed module and restarts main - the browser's websocket connection remains connected (so as to ensure a timely hot-reload)
Oh, BTW, I wonder whether
hint
wouldn't be a good fit for this: https://hackage.haskell.org/package/hint-0.9.0.4/docs/Language-Haskell-Interpreter.html#v:loadModules