Yesod with Tailwind CSS: How to minimize (hamlet) compile times in development?

Skip to first unread message

Stephen Michel

Dec 6, 2021, 9:46:21 PM12/6/21
to Yesod Web Framework
Hi all,

I'm fairly new to Haskell.

Is it possible to get something close to reload mode for hamlet, or otherwise get compile times low enough to make using Tailwind CSS with Yesod pleasant? I'm willing to give up features like type-safe routes, even in production, if necessary to achieve this.

On a new scaffolded site with `stack new`, I can only get builds down to 2.8 seconds for a trivial change, which is mostly spent recompiling files that I wouldn't expect would be necessary (e.g. Model).

I could find absolutely nothing about this on the internet, so I'm not sure whether this should be a feature request or bug report for yesod itself, or documentation which could be added to the the yesod book or cookbooks.

So for now, I just created a new repo with the code to reproduce and opened an issue there (with slightly more detail):

Thank you,
Stephen Michel

Dec 7, 2021, 5:45:36 AM12/7/21
to Yesod Web Framework
Do you already use GHCi to test your app during development?

`stack build` is very slow, but `:r` in GHCi is extremly fast.

Just place a .ghci file in your project directory with this content:

:load app/DevelMain.hs

Then start GHCi with `stack ghci`. After changes in the code you can type `:r` and `update` in GHCi to reload. I run GHCi in a tmux session and my editor sends this commands to GHCi automatically.

Stephen Michel

Feb 16, 2022, 9:20:02 PMFeb 16
to Yesod Web Framework
Late reply, but just for the record— I ended up resolving the issue. I documented the process in excessive detail in the [issue] I linked in the first email. Here's a quick summary:

- In hindsight, my original question emphasized Tailwind too much; the core problem was really just about the speed of compile times in development.
- Thank you (and others) for pointing me towards GHCi, which was the solution (via `ghcid`). It achieved a **42x speedup** over `yesod devel`, taking an incremental recompile from 2.8s to 66.4ms.
- I haven't figured out everything yet (specifically automatic reloads). Perhaps DevelMain.hs actually has implemented this already, I just don't know how to use it? But I'm busy now and won't come back to this project for a bit.
- The single biggest improvement to my experience starting with yesod would be if the book instructed me [how] to use GHCi/ghcid with DevelMain.hs instead of `yesod devel`. When I have time again I'll open an issue about that.


Reply all
Reply to author
0 new messages