Skip to content

Instantly share code, notes, and snippets.

@wavewave
Created May 16, 2023 17:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wavewave/d35f8ce60f7034ba2792c79f288153ae to your computer and use it in GitHub Desktop.
Save wavewave/d35f8ce60f7034ba2792c79f288153ae to your computer and use it in GitHub Desktop.
getDoc retrigger unnecessary recompilation with obscure message
$ ghci A B
GHCi, version 9.6.1: https://www.haskell.org/ghc/ :? for help
[1 of 2] Compiling A ( A.hs, interpreted )
[2 of 2] Compiling B ( B.hs, interpreted )
Ok, two modules loaded.
-- change B.hs (add a space)
ghci> :r
[2 of 2] Compiling B ( src/B.hs, interpreted ) [Source file changed]
src/B.hs:9:11: error: [GHC-87897]
• Exception when trying to run compile-time code:
<interactive>:1:1: error:
attempting to use module `main:A' (src/A.hs) which is not loaded
Code: (getDoc (DeclDoc ''Double)
>>=
\ doc
-> [| doc |]
pending(rn) [<doc, Language.Haskell.TH.Syntax.lift doc>])
• In the untyped splice:
$(getDoc (DeclDoc ''Double) >>= \ doc -> [| doc |])
|
9 | let s = $(getDoc (DeclDoc ''Double) >>= \doc -> [|doc|])
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Failed, one module loaded.
module A where
irrelevant :: IO ()
irrelevant = putStrLn "irrelevant"
{-# LANGUAGE TemplateHaskell #-}
module B (test) where
import Language.Haskell.TH
test :: IO ()
test = do
let s = $(getDoc (DeclDoc ''Double) >>= \doc -> [|doc|])
print s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment