[Git][ghc/ghc][wip/marge_bot_batch_merge_job] 2 commits: chore: Merge GHC.Internal.TH.Quote into GHC.Internal.TH.Monad
Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 919a7731 by Rajkumar Natarajan at 2026-03-09T16:51:14-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> - - - - - 87ad1dd8 by Simon Jakobi at 2026-03-09T16:51:14-04:00 Add regression test for #16122 - - - - - 13 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/simplCore/should_compile/T16122.hs - + testsuite/tests/simplCore/should_compile/T16122.stderr - testsuite/tests/simplCore/should_compile/all.T - 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/simplCore/should_compile/T16122.hs ===================================== @@ -0,0 +1,12 @@ +{-# LANGUAGE TypeApplications #-} +-- Test that the Core for f isn't "worse" than g's. +-- The optimized Core for f used to involve dictionary-passing. See #16122. +module T16122 (f, g) where + +import Data.Int (Int64) + +f :: Double -> Int64 +f = round + +g :: Double -> Int64 +g = fromIntegral @Int @Int64 . round ===================================== testsuite/tests/simplCore/should_compile/T16122.stderr ===================================== @@ -0,0 +1,26 @@ +f = \ x -> + I64# + (case x of { D# ds1 -> + case {__ffi_static_ccall_unsafe ghc-internal:rintDouble :: Double# + -> State# RealWorld + -> (# State# RealWorld, Double# #)} + ds1 realWorld# + of + { (# _, ds3 #) -> + intToInt64# (double2Int# ds3) + } + }) + +g = \ x -> + I64# + (case x of { D# ds1 -> + case {__ffi_static_ccall_unsafe ghc-internal:rintDouble :: Double# + -> State# RealWorld + -> (# State# RealWorld, Double# #)} + ds1 realWorld# + of + { (# _, ds3 #) -> + intToInt64# (double2Int# ds3) + } + }) + ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -295,6 +295,10 @@ test('T15631', normal, makefile_test, ['T15631']) test('T15673', normal, compile, ['-O']) +test('T16122', [when(wordsize(32), skip)], + multimod_compile_filter, + ['T16122', '-O -ddump-simpl -dsuppress-all -dsuppress-uniques -dno-typeable-binds', + "sed -n '/^f = /,/^$/p;/^g = /,/^$/p'"]) test('T16288', normal, multimod_compile, ['T16288B', '-O -dcore-lint -v0']) test('T16348', normal, compile, ['-O']) test('T16918', normal, compile, ['-O']) ===================================== 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/-/compare/bf3db183f293cfa6603be29358ec9dc... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/bf3db183f293cfa6603be29358ec9dc... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Marge Bot (@marge-bot)