summaryrefslogtreecommitdiff
path: root/testsuite/tests/quotes
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2019-11-27 15:29:44 +0000
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-01-12 21:28:47 -0500
commit9129210f7e9937c1065330295f06524661575839 (patch)
tree8eee18f92d23eb2fe39adecda1d547fa8d9fa7cb /testsuite/tests/quotes
parent49f83a0de12a7c02f4a6e99d26eaa362a373afa5 (diff)
downloadhaskell-9129210f7e9937c1065330295f06524661575839.tar.gz
Overloaded Quotation Brackets (#246)
This patch implements overloaded quotation brackets which generalise the desugaring of all quotation forms in terms of a new minimal interface. The main change is that a quotation, for example, [e| 5 |], will now have type `Quote m => m Exp` rather than `Q Exp`. The `Quote` typeclass contains a single method for generating new names which is used when desugaring binding structures. The return type of functions from the `Lift` type class, `lift` and `liftTyped` have been restricted to `forall m . Quote m => m Exp` rather than returning a result in a Q monad. More details about the feature can be read in the GHC proposal. https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0246-overloaded-bracket.rst
Diffstat (limited to 'testsuite/tests/quotes')
-rw-r--r--testsuite/tests/quotes/T6062.hs1
-rw-r--r--testsuite/tests/quotes/T8455.hs1
-rw-r--r--testsuite/tests/quotes/T8759a.hs1
-rw-r--r--testsuite/tests/quotes/T9824.hs1
-rw-r--r--testsuite/tests/quotes/TH_bracket1.hs2
-rw-r--r--testsuite/tests/quotes/TH_bracket2.hs1
-rw-r--r--testsuite/tests/quotes/TH_bracket3.hs1
-rw-r--r--testsuite/tests/quotes/TH_localname.stderr22
-rw-r--r--testsuite/tests/quotes/TH_typed_csp.hs6
-rw-r--r--testsuite/tests/quotes/all.T1
10 files changed, 26 insertions, 11 deletions
diff --git a/testsuite/tests/quotes/T6062.hs b/testsuite/tests/quotes/T6062.hs
index 342850e853..efce7b2752 100644
--- a/testsuite/tests/quotes/T6062.hs
+++ b/testsuite/tests/quotes/T6062.hs
@@ -1,2 +1,3 @@
+{-# LANGUAGE NoMonomorphismRestriction #-}
module T6062 where
x = [| False True |]
diff --git a/testsuite/tests/quotes/T8455.hs b/testsuite/tests/quotes/T8455.hs
index 69d1271b40..c55c5272f9 100644
--- a/testsuite/tests/quotes/T8455.hs
+++ b/testsuite/tests/quotes/T8455.hs
@@ -1,4 +1,5 @@
{-# LANGUAGE DataKinds #-}
+{-# LANGUAGE NoMonomorphismRestriction #-}
module T8455 where
diff --git a/testsuite/tests/quotes/T8759a.hs b/testsuite/tests/quotes/T8759a.hs
index 37b65d6fcc..c56a363e7a 100644
--- a/testsuite/tests/quotes/T8759a.hs
+++ b/testsuite/tests/quotes/T8759a.hs
@@ -1,4 +1,5 @@
{-# LANGUAGE PatternSynonyms #-}
+{-# LANGUAGE NoMonomorphismRestriction #-}
module T8759a where
diff --git a/testsuite/tests/quotes/T9824.hs b/testsuite/tests/quotes/T9824.hs
index 9a2d6fdfef..d8e2098c07 100644
--- a/testsuite/tests/quotes/T9824.hs
+++ b/testsuite/tests/quotes/T9824.hs
@@ -1,4 +1,5 @@
{-# OPTIONS_GHC -fwarn-unused-matches #-}
+{-# LANGUAGE NoMonomorphismRestriction #-}
module T9824 where
diff --git a/testsuite/tests/quotes/TH_bracket1.hs b/testsuite/tests/quotes/TH_bracket1.hs
index 7dee21ba01..bc0126a91d 100644
--- a/testsuite/tests/quotes/TH_bracket1.hs
+++ b/testsuite/tests/quotes/TH_bracket1.hs
@@ -1,6 +1,6 @@
-- Check that declarations in a bracket shadow the top-level
-- declarations, rather than clashing with them.
-
+{-# LANGUAGE NoMonomorphismRestriction #-}
module TH_bracket1 where
foo = 1
diff --git a/testsuite/tests/quotes/TH_bracket2.hs b/testsuite/tests/quotes/TH_bracket2.hs
index 2b06b9eecb..e903b673db 100644
--- a/testsuite/tests/quotes/TH_bracket2.hs
+++ b/testsuite/tests/quotes/TH_bracket2.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoMonomorphismRestriction #-}
module TH_bracket2 where
d_show = [d| data A = A
diff --git a/testsuite/tests/quotes/TH_bracket3.hs b/testsuite/tests/quotes/TH_bracket3.hs
index c746d61cd3..281b8cb081 100644
--- a/testsuite/tests/quotes/TH_bracket3.hs
+++ b/testsuite/tests/quotes/TH_bracket3.hs
@@ -1,4 +1,5 @@
{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE NoMonomorphismRestriction #-}
module TH_bracket3 where
diff --git a/testsuite/tests/quotes/TH_localname.stderr b/testsuite/tests/quotes/TH_localname.stderr
index d872a622b3..6d0ccc91ec 100644
--- a/testsuite/tests/quotes/TH_localname.stderr
+++ b/testsuite/tests/quotes/TH_localname.stderr
@@ -1,21 +1,23 @@
TH_localname.hs:3:11: error:
- • Ambiguous type variable ‘t0’ arising from a use of ‘Language.Haskell.TH.Syntax.lift’
- prevents the constraint ‘(Language.Haskell.TH.Syntax.Lift
- t0)’ from being solved.
+ • Ambiguous type variable ‘m0’ arising from a quotation bracket
+ prevents the constraint ‘(Language.Haskell.TH.Syntax.Quote
+ m0)’ from being solved.
Relevant bindings include
- y :: t0 (bound at TH_localname.hs:3:6)
- x :: t0 -> Language.Haskell.TH.Lib.Internal.ExpQ
+ x :: t0 -> m0 Language.Haskell.TH.Syntax.Exp
(bound at TH_localname.hs:3:1)
- Probable fix: use a type annotation to specify what ‘t0’ should be.
- These potential instances exist:
- 29 instances involving out-of-scope types
+ Probable fix: use a type annotation to specify what ‘m0’ should be.
+ These potential instance exist:
+ one instance involving out-of-scope types
(use -fprint-potential-instances to see them all)
- • In the expression: Language.Haskell.TH.Syntax.lift y
- In the expression:
+ • In the expression:
[| y |]
pending(rn) [<y, Language.Haskell.TH.Syntax.lift y>]
In the expression:
\ y
-> [| y |]
pending(rn) [<y, Language.Haskell.TH.Syntax.lift y>]
+ In an equation for ‘x’:
+ x = \ y
+ -> [| y |]
+ pending(rn) [<y, Language.Haskell.TH.Syntax.lift y>]
diff --git a/testsuite/tests/quotes/TH_typed_csp.hs b/testsuite/tests/quotes/TH_typed_csp.hs
new file mode 100644
index 0000000000..4660fffd7f
--- /dev/null
+++ b/testsuite/tests/quotes/TH_typed_csp.hs
@@ -0,0 +1,6 @@
+-- Check that CSP works for typed quotations.. there was no test for this
+-- before apart from the deriving tests.
+{-# LANGUAGE NoMonomorphismRestriction #-}
+module TH_typed_csp where
+
+bar = (\x -> [|| x ||]) ()
diff --git a/testsuite/tests/quotes/all.T b/testsuite/tests/quotes/all.T
index feefc41433..a10da1046f 100644
--- a/testsuite/tests/quotes/all.T
+++ b/testsuite/tests/quotes/all.T
@@ -29,3 +29,4 @@ test('TH_repE1', normal, compile, [''])
test('TH_repE3', normal, compile, [''])
test('TH_abstractFamily', normal, compile_fail, [''])
test('TH_localname', normal, compile_fail, [''])
+test('TH_typed_csp', normal, compile, [''])