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
-
87ad1dd8
by Simon Jakobi at 2026-03-09T16:51:14-04:00
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:
| ... | ... | @@ -185,7 +185,7 @@ thSyn, thMonad, thLib, qqLib, liftLib :: Module |
| 185 | 185 | thSyn = mkTHModule (fsLit "GHC.Internal.TH.Syntax")
|
| 186 | 186 | thMonad = mkTHModule (fsLit "GHC.Internal.TH.Monad")
|
| 187 | 187 | thLib = mkTHModule (fsLit "GHC.Internal.TH.Lib")
|
| 188 | -qqLib = mkTHModule (fsLit "GHC.Internal.TH.Quote")
|
|
| 188 | +qqLib = mkTHModule (fsLit "GHC.Internal.TH.Monad")
|
|
| 189 | 189 | liftLib = mkTHModule (fsLit "GHC.Internal.TH.Lift")
|
| 190 | 190 | |
| 191 | 191 |
| 1 | 1 | {-# OPTIONS_HADDOCK not-home #-}
|
| 2 | 2 | module GHC.Boot.TH.Quote
|
| 3 | - (module GHC.Internal.TH.Quote) where
|
|
| 3 | + (QuasiQuoter(..)) where
|
|
| 4 | 4 | |
| 5 | -import GHC.Internal.TH.Quote |
|
| 5 | +import GHC.Internal.TH.Monad (QuasiQuoter(..)) |
| ... | ... | @@ -306,7 +306,6 @@ Library |
| 306 | 306 | GHC.Internal.TH.Syntax
|
| 307 | 307 | GHC.Internal.TH.Lib
|
| 308 | 308 | GHC.Internal.TH.Lift
|
| 309 | - GHC.Internal.TH.Quote
|
|
| 310 | 309 | GHC.Internal.TH.Monad
|
| 311 | 310 | GHC.Internal.TopHandler
|
| 312 | 311 | GHC.Internal.TypeError
|
| ... | ... | @@ -20,6 +20,7 @@ |
| 20 | 20 | -- Import "Language.Haskell.TH" or "Language.Haskell.TH.Syntax" instead!
|
| 21 | 21 | module GHC.Internal.TH.Monad
|
| 22 | 22 | ( module GHC.Internal.TH.Monad
|
| 23 | + , QuasiQuoter(..)
|
|
| 23 | 24 | ) where
|
| 24 | 25 | |
| 25 | 26 | #ifdef BOOTSTRAP_TH
|
| ... | ... | @@ -313,6 +314,33 @@ class Monad m => Quote m where |
| 313 | 314 | instance Quote Q where
|
| 314 | 315 | newName s = Q (qNewName s)
|
| 315 | 316 | |
| 317 | +-----------------------------------------------------
|
|
| 318 | +--
|
|
| 319 | +-- The QuasiQuoter type
|
|
| 320 | +--
|
|
| 321 | +-----------------------------------------------------
|
|
| 322 | + |
|
| 323 | +-- | The 'QuasiQuoter' type, a value @q@ of this type can be used
|
|
| 324 | +-- in the syntax @[q| ... string to parse ...|]@. In fact, for
|
|
| 325 | +-- convenience, a 'QuasiQuoter' actually defines multiple quasiquoters
|
|
| 326 | +-- to be used in different splice contexts. In the usual case of a
|
|
| 327 | +-- @QuasiQuoter@ that is only intended to be used in certain splice
|
|
| 328 | +-- contexts, the unused fields should just 'fail'. This is most easily
|
|
| 329 | +-- accomplished using 'namedefaultQuasiQuoter' or 'defaultQuasiQuoter'.
|
|
| 330 | +--
|
|
| 331 | +-- This is exposed both from the @template-haskell-quasiquoter@ and @template-haskell@ packages.
|
|
| 332 | +-- Consider importing it from the more stable @template-haskell-quasiquoter@ if you don't need the full breadth of the @template-haskell@ interface.
|
|
| 333 | +data QuasiQuoter = QuasiQuoter {
|
|
| 334 | + -- | Quasi-quoter for expressions, invoked by quotes like @lhs = $[q|...]@
|
|
| 335 | + quoteExp :: String -> Q Exp,
|
|
| 336 | + -- | Quasi-quoter for patterns, invoked by quotes like @f $[q|...] = rhs@
|
|
| 337 | + quotePat :: String -> Q Pat,
|
|
| 338 | + -- | Quasi-quoter for types, invoked by quotes like @f :: $[q|...]@
|
|
| 339 | + quoteType :: String -> Q Type,
|
|
| 340 | + -- | Quasi-quoter for declarations, invoked by top-level quotes
|
|
| 341 | + quoteDec :: String -> Q [Dec]
|
|
| 342 | + }
|
|
| 343 | + |
|
| 316 | 344 | -----------------------------------------------------
|
| 317 | 345 | --
|
| 318 | 346 | -- The TExp type
|
| 1 | -{-# LANGUAGE CPP, RankNTypes, ScopedTypeVariables, Trustworthy #-}
|
|
| 2 | -{- |
|
|
| 3 | -Module : GHC.Internal.TH.Quote
|
|
| 4 | -Description : Quasi-quoting support for Template Haskell
|
|
| 5 | - |
|
| 6 | -Template Haskell supports quasiquoting, which permits users to construct
|
|
| 7 | -program fragments by directly writing concrete syntax. A quasiquoter is
|
|
| 8 | -essentially a function with takes a string to a Template Haskell AST.
|
|
| 9 | -This module defines the 'QuasiQuoter' datatype, which specifies a
|
|
| 10 | -quasiquoter @q@ which can be invoked using the syntax
|
|
| 11 | -@[q| ... string to parse ... |]@ when the @QuasiQuotes@ language
|
|
| 12 | -extension is enabled, and some utility functions for manipulating
|
|
| 13 | -quasiquoters. Nota bene: this package does not define any parsers,
|
|
| 14 | -that is up to you.
|
|
| 15 | - |
|
| 16 | -This is an internal module. Please import 'Language.Haskell.TH.Quote' instead.
|
|
| 17 | --}
|
|
| 18 | -module GHC.Internal.TH.Quote(
|
|
| 19 | - QuasiQuoter(..),
|
|
| 20 | - ) where
|
|
| 21 | - |
|
| 22 | -import GHC.Internal.TH.Syntax
|
|
| 23 | -import GHC.Internal.TH.Monad
|
|
| 24 | -import GHC.Internal.Base hiding (Type)
|
|
| 25 | - |
|
| 26 | - |
|
| 27 | --- | The 'QuasiQuoter' type, a value @q@ of this type can be used
|
|
| 28 | --- in the syntax @[q| ... string to parse ...|]@. In fact, for
|
|
| 29 | --- convenience, a 'QuasiQuoter' actually defines multiple quasiquoters
|
|
| 30 | --- to be used in different splice contexts. In the usual case of a
|
|
| 31 | --- @QuasiQuoter@ that is only intended to be used in certain splice
|
|
| 32 | --- contexts, the unused fields should just 'fail'. This is most easily
|
|
| 33 | --- accomplished using 'namedefaultQuasiQuoter' or 'defaultQuasiQuoter'.
|
|
| 34 | ---
|
|
| 35 | --- This is exposed both from the @template-haskell-quasiquoter@ and @template-haskell@ packages.
|
|
| 36 | --- Consider importing it from the more stable @template-haskell-quasiquoter@ if you don't need the full breadth of the @template-haskell@ interface.
|
|
| 37 | -data QuasiQuoter = QuasiQuoter {
|
|
| 38 | - -- | Quasi-quoter for expressions, invoked by quotes like @lhs = $[q|...]@
|
|
| 39 | - quoteExp :: String -> Q Exp,
|
|
| 40 | - -- | Quasi-quoter for patterns, invoked by quotes like @f $[q|...] = rhs@
|
|
| 41 | - quotePat :: String -> Q Pat,
|
|
| 42 | - -- | Quasi-quoter for types, invoked by quotes like @f :: $[q|...]@
|
|
| 43 | - quoteType :: String -> Q Type,
|
|
| 44 | - -- | Quasi-quoter for declarations, invoked by top-level quotes
|
|
| 45 | - quoteDec :: String -> Q [Dec]
|
|
| 46 | - } |
| 1 | -Subproject commit a47506eca032b139d9779fb8210d408c81d3fbd6 |
|
| 1 | +Subproject commit e7c7af444a467fb8d56483583987002b43317576 |
| ... | ... | @@ -81,7 +81,6 @@ whitespace: |
| 81 | 81 | libraries/base/include/HsEvent.h\
|
| 82 | 82 | libraries/base/include/md5.h\
|
| 83 | 83 | libraries/ghc-prim/GHC/Tuple.hs\
|
| 84 | - libraries/template-haskell/Language/Haskell/TH/Quote.hs\
|
|
| 85 | 84 | rts/STM.h\
|
| 86 | 85 | rts/Sparks.h\
|
| 87 | 86 | rts/Threads.h\
|
| ... | ... | @@ -6,10 +6,9 @@ interfacePlugin: GHC.Internal.Base |
| 6 | 6 | interfacePlugin: GHC.Internal.Data.NonEmpty
|
| 7 | 7 | interfacePlugin: GHC.Internal.Float
|
| 8 | 8 | interfacePlugin: GHC.Internal.Prim.Ext
|
| 9 | -interfacePlugin: GHC.Internal.TH.Quote
|
|
| 9 | +interfacePlugin: GHC.Internal.TH.Monad
|
|
| 10 | 10 | interfacePlugin: GHC.Internal.TH.Syntax
|
| 11 | 11 | typeCheckPlugin (rn)
|
| 12 | -interfacePlugin: GHC.Internal.TH.Monad
|
|
| 13 | 12 | interfacePlugin: GHC.Internal.Stack.Types
|
| 14 | 13 | interfacePlugin: GHC.Internal.Exception.Context
|
| 15 | 14 | typeCheckPlugin (tc)
|
| 1 | 1 | QQError.hs:5:12: error: [GHC-83865]
|
| 2 | - • Couldn't match expected type ‘GHC.Internal.TH.Quote.QuasiQuoter’
|
|
| 2 | + • Couldn't match expected type ‘GHC.Internal.TH.Monad.QuasiQuoter’
|
|
| 3 | 3 | with actual type ‘a1 -> a1’
|
| 4 | 4 | • Probable cause: ‘id’ is applied to too few arguments
|
| 5 | 5 | In the expression: [| [id|hello|] |]
|
| ... | ... | @@ -9,7 +9,7 @@ QQError.hs:5:12: error: [GHC-83865] |
| 9 | 9 | | ^^
|
| 10 | 10 | |
| 11 | 11 | QQError.hs:7:13: error: [GHC-83865]
|
| 12 | - • Couldn't match expected type ‘GHC.Internal.TH.Quote.QuasiQuoter’
|
|
| 12 | + • Couldn't match expected type ‘GHC.Internal.TH.Monad.QuasiQuoter’
|
|
| 13 | 13 | with actual type ‘a0 -> a0’
|
| 14 | 14 | • Probable cause: ‘id’ is applied to too few arguments
|
| 15 | 15 | In the expression: [| [id|hello|] |]
|
| 1 | +{-# LANGUAGE TypeApplications #-}
|
|
| 2 | +-- Test that the Core for f isn't "worse" than g's.
|
|
| 3 | +-- The optimized Core for f used to involve dictionary-passing. See #16122.
|
|
| 4 | +module T16122 (f, g) where
|
|
| 5 | + |
|
| 6 | +import Data.Int (Int64)
|
|
| 7 | + |
|
| 8 | +f :: Double -> Int64
|
|
| 9 | +f = round
|
|
| 10 | + |
|
| 11 | +g :: Double -> Int64
|
|
| 12 | +g = fromIntegral @Int @Int64 . round |
| 1 | +f = \ x ->
|
|
| 2 | + I64#
|
|
| 3 | + (case x of { D# ds1 ->
|
|
| 4 | + case {__ffi_static_ccall_unsafe ghc-internal:rintDouble :: Double#
|
|
| 5 | + -> State# RealWorld
|
|
| 6 | + -> (# State# RealWorld, Double# #)}
|
|
| 7 | + ds1 realWorld#
|
|
| 8 | + of
|
|
| 9 | + { (# _, ds3 #) ->
|
|
| 10 | + intToInt64# (double2Int# ds3)
|
|
| 11 | + }
|
|
| 12 | + })
|
|
| 13 | + |
|
| 14 | +g = \ x ->
|
|
| 15 | + I64#
|
|
| 16 | + (case x of { D# ds1 ->
|
|
| 17 | + case {__ffi_static_ccall_unsafe ghc-internal:rintDouble :: Double#
|
|
| 18 | + -> State# RealWorld
|
|
| 19 | + -> (# State# RealWorld, Double# #)}
|
|
| 20 | + ds1 realWorld#
|
|
| 21 | + of
|
|
| 22 | + { (# _, ds3 #) ->
|
|
| 23 | + intToInt64# (double2Int# ds3)
|
|
| 24 | + }
|
|
| 25 | + })
|
|
| 26 | + |
| ... | ... | @@ -295,6 +295,10 @@ test('T15631', |
| 295 | 295 | normal,
|
| 296 | 296 | makefile_test, ['T15631'])
|
| 297 | 297 | test('T15673', normal, compile, ['-O'])
|
| 298 | +test('T16122', [when(wordsize(32), skip)],
|
|
| 299 | + multimod_compile_filter,
|
|
| 300 | + ['T16122', '-O -ddump-simpl -dsuppress-all -dsuppress-uniques -dno-typeable-binds',
|
|
| 301 | + "sed -n '/^f = /,/^$/p;/^g = /,/^$/p'"])
|
|
| 298 | 302 | test('T16288', normal, multimod_compile, ['T16288B', '-O -dcore-lint -v0'])
|
| 299 | 303 | test('T16348', normal, compile, ['-O'])
|
| 300 | 304 | test('T16918', normal, compile, ['-O'])
|
| 1 | 1 | QQTopError.hs:4:9: error: [GHC-83865]
|
| 2 | - • Couldn't match expected type ‘GHC.Internal.TH.Quote.QuasiQuoter’
|
|
| 2 | + • Couldn't match expected type ‘GHC.Internal.TH.Monad.QuasiQuoter’
|
|
| 3 | 3 | with actual type ‘a0 -> a0’
|
| 4 | 4 | • Probable cause: ‘id’ is applied to too few arguments
|
| 5 | - In the first argument of ‘GHC.Internal.TH.Quote.quoteExp’, namely
|
|
| 5 | + In the first argument of ‘GHC.Internal.TH.Monad.quoteExp’, namely
|
|
| 6 | 6 | ‘id’
|
| 7 | - In the expression: GHC.Internal.TH.Quote.quoteExp id "hello"
|
|
| 7 | + In the expression: GHC.Internal.TH.Monad.quoteExp id "hello"
|
|
| 8 | 8 | In the quasi-quotation: [id|hello|]
|
| 9 | 9 | |
|
| 10 | 10 | 4 | main = [id|hello|]
|