[Git][ghc/ghc][master] chore: Merge GHC.Internal.TH.Quote into GHC.Internal.TH.Monad
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 23a50772 by Rajkumar Natarajan at 2026-03-10T14:11:37-04:00 chore: Merge GHC.Internal.TH.Quote into GHC.Internal.TH.Monad Move the QuasiQuoter datatype from GHC.Internal.TH.Quote to GHC.Internal.TH.Monad and delete the Quote module. Update submodule template-haskell-quasiquoter to use the merged upstream version that imports from the correct module. Co-authored-by: Cursor <cursoragent@cursor.com> - - - - - 10 changed files: - compiler/GHC/Builtin/Names/TH.hs - libraries/ghc-boot-th/GHC/Boot/TH/Quote.hs - libraries/ghc-internal/ghc-internal.cabal.in - libraries/ghc-internal/src/GHC/Internal/TH/Monad.hs - − libraries/ghc-internal/src/GHC/Internal/TH/Quote.hs - libraries/template-haskell-quasiquoter - testsuite/tests/linters/Makefile - testsuite/tests/plugins/plugins10.stdout - testsuite/tests/quotes/QQError.stderr - testsuite/tests/th/QQTopError.stderr Changes: ===================================== compiler/GHC/Builtin/Names/TH.hs ===================================== @@ -185,7 +185,7 @@ thSyn, thMonad, thLib, qqLib, liftLib :: Module thSyn = mkTHModule (fsLit "GHC.Internal.TH.Syntax") thMonad = mkTHModule (fsLit "GHC.Internal.TH.Monad") thLib = mkTHModule (fsLit "GHC.Internal.TH.Lib") -qqLib = mkTHModule (fsLit "GHC.Internal.TH.Quote") +qqLib = mkTHModule (fsLit "GHC.Internal.TH.Monad") liftLib = mkTHModule (fsLit "GHC.Internal.TH.Lift") ===================================== libraries/ghc-boot-th/GHC/Boot/TH/Quote.hs ===================================== @@ -1,5 +1,5 @@ {-# OPTIONS_HADDOCK not-home #-} module GHC.Boot.TH.Quote - (module GHC.Internal.TH.Quote) where + (QuasiQuoter(..)) where -import GHC.Internal.TH.Quote +import GHC.Internal.TH.Monad (QuasiQuoter(..)) ===================================== libraries/ghc-internal/ghc-internal.cabal.in ===================================== @@ -306,7 +306,6 @@ Library GHC.Internal.TH.Syntax GHC.Internal.TH.Lib GHC.Internal.TH.Lift - GHC.Internal.TH.Quote GHC.Internal.TH.Monad GHC.Internal.TopHandler GHC.Internal.TypeError ===================================== libraries/ghc-internal/src/GHC/Internal/TH/Monad.hs ===================================== @@ -20,6 +20,7 @@ -- Import "Language.Haskell.TH" or "Language.Haskell.TH.Syntax" instead! module GHC.Internal.TH.Monad ( module GHC.Internal.TH.Monad + , QuasiQuoter(..) ) where #ifdef BOOTSTRAP_TH @@ -313,6 +314,33 @@ class Monad m => Quote m where instance Quote Q where newName s = Q (qNewName s) +----------------------------------------------------- +-- +-- The QuasiQuoter type +-- +----------------------------------------------------- + +-- | The 'QuasiQuoter' type, a value @q@ of this type can be used +-- in the syntax @[q| ... string to parse ...|]@. In fact, for +-- convenience, a 'QuasiQuoter' actually defines multiple quasiquoters +-- to be used in different splice contexts. In the usual case of a +-- @QuasiQuoter@ that is only intended to be used in certain splice +-- contexts, the unused fields should just 'fail'. This is most easily +-- accomplished using 'namedefaultQuasiQuoter' or 'defaultQuasiQuoter'. +-- +-- This is exposed both from the @template-haskell-quasiquoter@ and @template-haskell@ packages. +-- Consider importing it from the more stable @template-haskell-quasiquoter@ if you don't need the full breadth of the @template-haskell@ interface. +data QuasiQuoter = QuasiQuoter { + -- | Quasi-quoter for expressions, invoked by quotes like @lhs = $[q|...]@ + quoteExp :: String -> Q Exp, + -- | Quasi-quoter for patterns, invoked by quotes like @f $[q|...] = rhs@ + quotePat :: String -> Q Pat, + -- | Quasi-quoter for types, invoked by quotes like @f :: $[q|...]@ + quoteType :: String -> Q Type, + -- | Quasi-quoter for declarations, invoked by top-level quotes + quoteDec :: String -> Q [Dec] + } + ----------------------------------------------------- -- -- The TExp type ===================================== libraries/ghc-internal/src/GHC/Internal/TH/Quote.hs deleted ===================================== @@ -1,46 +0,0 @@ -{-# LANGUAGE CPP, RankNTypes, ScopedTypeVariables, Trustworthy #-} -{- | -Module : GHC.Internal.TH.Quote -Description : Quasi-quoting support for Template Haskell - -Template Haskell supports quasiquoting, which permits users to construct -program fragments by directly writing concrete syntax. A quasiquoter is -essentially a function with takes a string to a Template Haskell AST. -This module defines the 'QuasiQuoter' datatype, which specifies a -quasiquoter @q@ which can be invoked using the syntax -@[q| ... string to parse ... |]@ when the @QuasiQuotes@ language -extension is enabled, and some utility functions for manipulating -quasiquoters. Nota bene: this package does not define any parsers, -that is up to you. - -This is an internal module. Please import 'Language.Haskell.TH.Quote' instead. --} -module GHC.Internal.TH.Quote( - QuasiQuoter(..), - ) where - -import GHC.Internal.TH.Syntax -import GHC.Internal.TH.Monad -import GHC.Internal.Base hiding (Type) - - --- | The 'QuasiQuoter' type, a value @q@ of this type can be used --- in the syntax @[q| ... string to parse ...|]@. In fact, for --- convenience, a 'QuasiQuoter' actually defines multiple quasiquoters --- to be used in different splice contexts. In the usual case of a --- @QuasiQuoter@ that is only intended to be used in certain splice --- contexts, the unused fields should just 'fail'. This is most easily --- accomplished using 'namedefaultQuasiQuoter' or 'defaultQuasiQuoter'. --- --- This is exposed both from the @template-haskell-quasiquoter@ and @template-haskell@ packages. --- Consider importing it from the more stable @template-haskell-quasiquoter@ if you don't need the full breadth of the @template-haskell@ interface. -data QuasiQuoter = QuasiQuoter { - -- | Quasi-quoter for expressions, invoked by quotes like @lhs = $[q|...]@ - quoteExp :: String -> Q Exp, - -- | Quasi-quoter for patterns, invoked by quotes like @f $[q|...] = rhs@ - quotePat :: String -> Q Pat, - -- | Quasi-quoter for types, invoked by quotes like @f :: $[q|...]@ - quoteType :: String -> Q Type, - -- | Quasi-quoter for declarations, invoked by top-level quotes - quoteDec :: String -> Q [Dec] - } ===================================== libraries/template-haskell-quasiquoter ===================================== @@ -1 +1 @@ -Subproject commit a47506eca032b139d9779fb8210d408c81d3fbd6 +Subproject commit e7c7af444a467fb8d56483583987002b43317576 ===================================== testsuite/tests/linters/Makefile ===================================== @@ -81,7 +81,6 @@ whitespace: libraries/base/include/HsEvent.h\ libraries/base/include/md5.h\ libraries/ghc-prim/GHC/Tuple.hs\ - libraries/template-haskell/Language/Haskell/TH/Quote.hs\ rts/STM.h\ rts/Sparks.h\ rts/Threads.h\ ===================================== testsuite/tests/plugins/plugins10.stdout ===================================== @@ -6,10 +6,9 @@ interfacePlugin: GHC.Internal.Base interfacePlugin: GHC.Internal.Data.NonEmpty interfacePlugin: GHC.Internal.Float interfacePlugin: GHC.Internal.Prim.Ext -interfacePlugin: GHC.Internal.TH.Quote +interfacePlugin: GHC.Internal.TH.Monad interfacePlugin: GHC.Internal.TH.Syntax typeCheckPlugin (rn) -interfacePlugin: GHC.Internal.TH.Monad interfacePlugin: GHC.Internal.Stack.Types interfacePlugin: GHC.Internal.Exception.Context typeCheckPlugin (tc) ===================================== testsuite/tests/quotes/QQError.stderr ===================================== @@ -1,5 +1,5 @@ QQError.hs:5:12: error: [GHC-83865] - • Couldn't match expected type ‘GHC.Internal.TH.Quote.QuasiQuoter’ + • Couldn't match expected type ‘GHC.Internal.TH.Monad.QuasiQuoter’ with actual type ‘a1 -> a1’ • Probable cause: ‘id’ is applied to too few arguments In the expression: [| [id|hello|] |] @@ -9,7 +9,7 @@ QQError.hs:5:12: error: [GHC-83865] | ^^ QQError.hs:7:13: error: [GHC-83865] - • Couldn't match expected type ‘GHC.Internal.TH.Quote.QuasiQuoter’ + • Couldn't match expected type ‘GHC.Internal.TH.Monad.QuasiQuoter’ with actual type ‘a0 -> a0’ • Probable cause: ‘id’ is applied to too few arguments In the expression: [| [id|hello|] |] ===================================== testsuite/tests/th/QQTopError.stderr ===================================== @@ -1,10 +1,10 @@ QQTopError.hs:4:9: error: [GHC-83865] - • Couldn't match expected type ‘GHC.Internal.TH.Quote.QuasiQuoter’ + • Couldn't match expected type ‘GHC.Internal.TH.Monad.QuasiQuoter’ with actual type ‘a0 -> a0’ • Probable cause: ‘id’ is applied to too few arguments - In the first argument of ‘GHC.Internal.TH.Quote.quoteExp’, namely + In the first argument of ‘GHC.Internal.TH.Monad.quoteExp’, namely ‘id’ - In the expression: GHC.Internal.TH.Quote.quoteExp id "hello" + In the expression: GHC.Internal.TH.Monad.quoteExp id "hello" In the quasi-quotation: [id|hello|] | 4 | main = [id|hello|] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/23a50772c9c55c46b1c4ffb8ef60a085... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/23a50772c9c55c46b1c4ffb8ef60a085... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Marge Bot (@marge-bot)