Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 741da00c by Ben Gamari at 2025-11-12T03:38:20-05:00 template-haskell: Better describe getQ semantics Clarify that the state is a type-indexed map, as suggested by #26484. - - - - - 1 changed file: - libraries/ghc-internal/src/GHC/Internal/TH/Monad.hs Changes: ===================================== libraries/ghc-internal/src/GHC/Internal/TH/Monad.hs ===================================== @@ -904,8 +904,17 @@ addModFinalizer act = Q (qAddModFinalizer (unQ act)) addCorePlugin :: String -> Q () addCorePlugin plugin = Q (qAddCorePlugin plugin) --- | Get state from the 'Q' monad. Note that the state is local to the --- Haskell module in which the Template Haskell expression is executed. +-- | Get state from the 'Q' monad. The state maintained by 'Q' is isomorphic to +-- a type-indexed finite map. That is, +-- +-- @ +-- do putQ @Int 42 +-- putQ @Char 'a' +-- getQ @Int -- == (Just 42) +-- @ +-- +-- Note that the state is local to the Haskell module in which the Template +-- Haskell expression is executed. getQ :: Typeable a => Q (Maybe a) getQ = Q qGetQ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/741da00c0b27ee515926d24f6354b71f... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/741da00c0b27ee515926d24f6354b71f... You're receiving this email because of your account on gitlab.haskell.org.