[Git][ghc/ghc][wip/abstract-q] fix fail impl
Teo Camarasu pushed to branch wip/abstract-q at Glasgow Haskell Compiler / GHC Commits: d52a3009 by Teo Camarasu at 2026-03-17T20:38:56+00:00 fix fail impl - - - - - 3 changed files: - compiler/GHC/Tc/Gen/Splice.hs - libraries/ghc-internal/src/GHC/Internal/TH/Monad.hs - libraries/ghci/GHCi/TH.hs Changes: ===================================== compiler/GHC/Tc/Gen/Splice.hs ===================================== @@ -1559,9 +1559,10 @@ location = do { m <- getModule metaHandlersTcM :: TH.MetaHandlers TcM metaHandlersTcM = TH.MetaHandlers { - mNewName = \s -> do { u <- newUnique - ; let i = toInteger (getKey u) - ; return (TH.mkNameU s i) } + mFail = fail + , mNewName = \s -> do { u <- newUnique + ; let i = toInteger (getKey u) + ; return (TH.mkNameU s i) } -- 'msg' is forced to ensure exceptions don't escape, -- see Note [Exceptions in TH] ===================================== libraries/ghc-internal/src/GHC/Internal/TH/Monad.hs ===================================== @@ -184,7 +184,8 @@ instance Quasi IO where metaHandlersIO :: MetaHandlers IO metaHandlersIO = MetaHandlers { - mNewName = newNameIO + mFail = fail + , mNewName = newNameIO , mReport = \b msg -> if b then hPutStrLn stderr ("Template Haskell error: " ++ msg) @@ -221,8 +222,9 @@ instance Quote IO where newName = newNameIO data MetaHandlers m = MetaHandlers { + mFail :: String -> m a -- | Fresh names. See 'newName'. - mNewName :: String -> m Name + , mNewName :: String -> m Name ------- Error reporting and recovery ------- -- | Report an error (True) or warning (False) @@ -351,7 +353,7 @@ instance Monad Q where (>>) = (*>) instance MonadFail Q where - fail s = report True s >> Q (\_ _ -> fail "Q monad failure") + fail s = report True s >> Q (\r h -> r $ mFail m "Q monad failure") instance Functor Q where fmap f (Q x) = Q $ \r h -> fmap f (x r h) ===================================== libraries/ghci/GHCi/TH.hs ===================================== @@ -180,7 +180,8 @@ runQinGHCiQ (TH.Q m) = GHCiQ $ \sRef -> m (runInIO sRef) metaHandlersGHCiQ runInIO sRef (GHCiQ m) = m sRef metaHandlersGHCiQ = TH.MetaHandlers { - mNewName = \str -> ghcCmd (NewName str) + mFail = fail + , mNewName = \str -> ghcCmd (NewName str) , mReport = \isError msg -> ghcCmd (Report isError msg) -- See Note [TH recover with -fexternal-interpreter] in GHC.Tc.Gen.Splice View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d52a300923f0533dadc4e96e14eb4423... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d52a300923f0533dadc4e96e14eb4423... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Teo Camarasu (@teo)