
Haddock pre-processor to insert type-checked examples
What already exists that compile-checks haddock examples?
While working on hyperbole, I realized I don't have enough discipline/attention to keep haddock examples correct as the package changes over time. (Discipline is the compiler's job!)
I wrote a custom pre-processor that replaces little `#EMBED` macros in the haddock with a top-level definition from a compiled module. It works like this:
{- | Run a 'Page' and return a 'Response'
@
#EMBED Example.Docs.BasicPage main
#EMBED Example.Docs.BasicPage page
@
-}
Goes to the module Example.Docs.BasicPage and finds `main` and `page`, ending up with this:
{- | Run a 'Page' and return a 'Response'
@
main :: IO ()
main = do
run 3000 $ liveApp quickStartDocument (runPage hello)
page :: Page es '[]
page = do
pure $ messageView "Hello World"
@
-}
-----------
It turns out to be a major pain to get a local pre-processor working without publishing it to hackage. I'm considering doing just that, but first I wanted to ask: what already exists to solve this problem?
I'm aware of doctest, but that only seems to check small `>>>` examples. I don't think it can accomplish what I'm asking for above.