Actually, I can boil it down to something even smaller that triggers the error for n > 9000:
testCase :: forall a. Int -> Widget HTML a
testCase n = D.div' $ (\x -> D.text $ (show x) <> "\t") <$> (A.range 0 n)
Full script including this testCase is in the gist above.