[Git][ghc/ghc][master] Support multiline strings in TH
Marge Bot (@marge-bot)
gitlab at gitlab.haskell.org
Tue Aug 13 17:39:39 UTC 2024
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
682a6a41 by Brandon Chinn at 2024-08-13T13:39:17-04:00
Support multiline strings in TH
- - - - -
4 changed files:
- compiler/GHC/HsToCore/Quote.hs
- + testsuite/tests/th/TH_MultilineStrings.hs
- + testsuite/tests/th/TH_MultilineStrings.stdout
- testsuite/tests/th/all.T
Changes:
=====================================
compiler/GHC/HsToCore/Quote.hs
=====================================
@@ -3026,6 +3026,7 @@ repLiteral lit
HsChar _ _ -> Just charLName
HsCharPrim _ _ -> Just charPrimLName
HsString _ _ -> Just stringLName
+ HsMultilineString _ _ -> Just stringLName
HsRat _ _ _ -> Just rationalLName
_ -> Nothing
=====================================
testsuite/tests/th/TH_MultilineStrings.hs
=====================================
@@ -0,0 +1,18 @@
+{-# LANGUAGE MultilineStrings #-}
+{-# LANGUAGE TemplateHaskell #-}
+
+import Language.Haskell.TH (runQ)
+
+{-
+Test the MultilineStrings proposal
+https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0569-multiline-strings.rst
+-}
+
+main :: IO ()
+main = do
+ print =<< runQ [|
+ """
+ hello
+ world
+ """
+ |]
=====================================
testsuite/tests/th/TH_MultilineStrings.stdout
=====================================
@@ -0,0 +1 @@
+LitE (StringL "hello\nworld")
=====================================
testsuite/tests/th/all.T
=====================================
@@ -622,3 +622,4 @@ test('T24572a', normal, compile, [''])
test('T24572b', normal, compile_fail, [''])
test('T24572c', normal, compile_fail, [''])
test('T24572d', normal, compile, [''])
+test('TH_MultilineStrings', normal, compile_and_run, [''])
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/682a6a41626f9d9ef499080eb51189e92f130593
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/682a6a41626f9d9ef499080eb51189e92f130593
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20240813/c92e1607/attachment-0001.html>
More information about the ghc-commits
mailing list