Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use JSaddle.Warp.debug when run from GHCI #770

Merged
merged 3 commits into from
Feb 21, 2025
Merged

Conversation

georgefst
Copy link
Contributor

The jsaddle-warp support added in #768 uses the run function.

While working on similar support previously, I found that debug is much more useful than run in practice due to supporting live reloading, but it's meant to be used in GHCI, and with cabal run it just exits. With this PR, we use debug if and only if we're in GHCI. Matching on "<interactive>" is a bit ugly, but it's the only way I know of detecting this.

Most usefully, with this change, it's possible to use a command like ghcid -c 'cabal repl simple' -Wr for reloading on file save, or, if you're feeling fancy, ghcid -c 'cabal repl --enable-multi-repl simple miso' -W -T Main.main. This is particularly nice with something like #749, which I'll try to get back to soon.

We might often want debugOr rather than just debug, in order to also serve static files. But, similarly to setting a port other than 8008, maybe it's best for now if users just use their own CPP in that case. One step at a time.

We could also investigate upstream why debug can't be used everywhere (I expect it's due to forking to a background thread), but I'm hopeful that jsaddle-warp will be obsolete before too long, once we have better GHCI support for Wasm.

@dmjio dmjio merged commit cada710 into dmjio:master Feb 21, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants