Use JSaddle.Warp.debug
when run from GHCI
#770
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
jsaddle-warp
support added in #768 uses therun
function.While working on similar support previously, I found that
debug
is much more useful thanrun
in practice due to supporting live reloading, but it's meant to be used in GHCI, and withcabal run
it just exits. With this PR, we usedebug
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 justdebug
, in order to also serve static files. But, similarly to setting a port other than8008
, 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 thatjsaddle-warp
will be obsolete before too long, once we have better GHCI support for Wasm.