Hello all! I’ve been working on a feature for yesod to allow you to write tests against web handlers while only depending on the handlers in question, instead of the entire application. Depending on our YesodDispatch instance for tests required depending on around 10,000 modules right now, but individual handler modules often have just 1,000-3,000. This is the difference between loading the modules and running the tests in 2-3 seconds vs 15-20 seconds, and is a major improvement for our developer test cycle in ghciwatch and upcoming buck2 build system.
For a demonstration on how this works, see the PR to hspec-yesod that leverages it. Nested routes are generated and dispatched separately, and the setUrlNested arg route (or setUrl (WithParentArgs arg route) uses type class dispatch to do The Right Thing - you only need the instance for the route fragment itself in scope, not the entire Route site.
However, this feature - as I implemented it - is a breaking change to yesod-core. Here’s the PR in question. When upgrading our app, we did not have any errors or warnings. The main breaking changes are in the mkDispatchClause and MkDispatchSettings functions - many of the sort-of-internal functions have different types, some things are deleted, etc.
I would greatly appreciate any commentary on this. If you use yesod, try compiling this on your project - if there are any breaking changes or problems, please let me know so I can try to accommodate you. If this really ruins your codebase, or it causes serious problems, let me know so we can figure out a path forward that spares you.
EDIT:
OK, I’ve demonstrated the change in the work repository and fully integrated it! Benefit: 12,000 module dependencies down to 7,000 (most of which are from bloated authorization dependency code). Time to load just the test module in question: from 255s down to 170s (85 seconds saved for initial load). Time to reload that module: from 15s to 8s. Massive improvements.