The fastest way to feed ghc type errors to LLM
I see couple of Haskellers around here embracing agentic coding especially since the jump of capabilities we got in claude 4.5/6 releases. I’ve also been experimenting with claude-code recently and saw some sparks of great productivity improvements.
When using claude-code, there are at least two downsides of letting it run cabal/stack build on an ad-hoc basis:
the feedback loop is slow (compared to what you can get with ghcid / ghciwatch or just reloading things in ghci when coding manually)
it’s wasting tokens (if you’re compiling 200 module project, you’ll see 200+ lines of build progress logs
[ 17 of 226] Compiling PI.Core.ProjectPermissioneven if the project compiles fine, the repeated build outputs just pollute the context)
I see some hope in claude hooks, which allow you to run arbitrary scripts/commands in response to events like claude writing/editing a file. When a hook command is executed in response to an event, it either exits with 0 (in which case the agentic harness doesn’t bother the LLM with the output of that command), or it exits with 2 and the stderr of the script (think type errors) is fed back to claude so it can react to it. I’ve noticed a great UX improvement in my agentic coding sessions when using hooks with my toy elm projects. Here’s an example hook that just runs elm compiler every time elm file is written or edited. It works great, in effect turning “work on something until Claude thinks it’s done” loops into more productive “work on something until the compiler agrees with Claude it’s done” loops. You just instruct claude in CLAUDE.md not to run any build commands explicitly and assure it it will get GHC compiler errors from the hook if anything gets broken. This works awesome with Elm as it can compile 100k-line project in under 2 seconds.
Is there a way to get fast type-check-only feedback from GHC/cabal/stack (similar to rust’s cargo check) for use in an automated hook?
stack build --fast/cabal build --disable-optimizationare usable, but still slow (unnecessary code gen and linking steps). It seems like it’s not possible to use-no-codewith cabal build (thread)ghciwatch is great for manual coding, but I haven’t found a way to execute it in non-interactive “one off” compilation way or how to get its output in an “on demand” way
I’m curious if anyone managed to figure out something to get fast feedback loop for their LLM agents.
Discussion in the ATmosphere