Developing Yesod application with faster feedback (interpretation mode)?

211 views Asked by At

When I use yesod devel it just recompiles whole application every time I change template file or any module.

Is there any way to get faster feedback on development? I mean do not recompile, but use ghci or something with Yesod?

2

There are 2 answers

0
rul On

I've never tried it myself, but I think that what you're looking for is wai-handler-devel. Quoting the documentation:

This handler automatically reloads your source code upon any changes. It works by using the hint package, essentially embedding GHC inside the handler.

It's also mentioned in the yesod book, which also has useful information:

(...) wai-handler-devel lets you develop your applications without worrying about stopping to compile.

Yesod provides an alternate approach for a devel server, known as yesod devel. The difference from wai-handler-devel is that yesod devel actually compiles your code each time, respecting all settings in your cabal file. This is the recommended aproach for general Yesod development.

1
J. Abrahamson On

I'm not familiar with Yesod, but I often build web applications in GHCi by continually restarting the web server. For instance, using something like async we can set up a server thread which dies after 15 seconds (enough time perhaps to test a feature).

-- | run 'defaultMain' for a few seconds then kill it
quicky :: IO ()
quicky = Async.withAsync defaultMain $ \_ ->
  replicateM_ 3 (threadDelay (round 5e6) >> putStrLn "(tick)")

I've used this directly atop Warp in the past quite successfully.