[commit: testsuite] overlapping-tyfams: Updated Template Haskell tests to reflect change to TySynInstD. (d64423c)

Richard Eisenberg <[email protected]>
Newsgroups gmane.comp.lang.haskell.cvs.ghc
Message-ID <[email protected]>
Repository : ssh://darcs.haskell.org//srv/darcs/testsuite

On branch  : overlapping-tyfams

http://hackage.haskell.org/trac/ghc/changeset/d64423c86131ac4008e81ffc762c5427a31b604f

>---------------------------------------------------------------

commit d64423c86131ac4008e81ffc762c5427a31b604f
Author: Richard Eisenberg <[email protected]>
Date:   Tue Dec 4 08:56:39 2012 -0500

    Updated Template Haskell tests to reflect change to TySynInstD.

>---------------------------------------------------------------

 tests/th/TH_TyInstWhere1.hs     |   17 +++++++++++++++++
 tests/th/TH_TyInstWhere1.stderr |    9 +++++++++
 tests/th/TH_TyInstWhere2.hs     |   15 +++++++++++++++
 tests/th/TH_TyInstWhere2.stderr |    5 +++++
 tests/th/TH_TyInstWhere3.hs     |   18 ++++++++++++++++++
 tests/th/TH_TyInstWhere3.stderr |    3 +++
 tests/th/TH_TyInstWhere4.hs     |   20 ++++++++++++++++++++
 tests/th/TH_TyInstWhere4.stderr |   16 ++++++++++++++++
 8 files changed, 103 insertions(+), 0 deletions(-)

diff --git a/tests/th/TH_TyInstWhere1.hs b/tests/th/TH_TyInstWhere1.hs
new file mode 100644
index 0000000..8352d4b
--- /dev/null
+++ b/tests/th/TH_TyInstWhere1.hs
@@ -0,0 +1,17 @@
+{-# LANGUAGE PolyKinds, DataKinds, TemplateHaskell, TypeFamilies #-}
+
+module TH_TyInstWhere1 where
+
+type family F (a :: k) (b :: k) :: Bool
+
+$([d| type instance where
+        F a a = True
+        F a b = False |])
+
+data Proxy a = P
+
+f :: Proxy True -> Proxy (F Int Int)
+f x = x
+
+g :: Proxy False -> Proxy (F Int Bool)
+g x = x 
\ No newline at end of file
diff --git a/tests/th/TH_TyInstWhere1.stderr b/tests/th/TH_TyInstWhere1.stderr
new file mode 100644
index 0000000..480e5bf
--- /dev/null
+++ b/tests/th/TH_TyInstWhere1.stderr
@@ -0,0 +1,9 @@
+TH_TyInstWhere1.hs:1:1: Splicing declarations
+    [d| type instance where
+          F a a = True
+          F a b = False |]
+  ======>
+    TH_TyInstWhere1.hs:(7,3)-(9,24)
+    type instance where
+      F a a = True
+      F a b = False
diff --git a/tests/th/TH_TyInstWhere2.hs b/tests/th/TH_TyInstWhere2.hs
new file mode 100644
index 0000000..ec27ced
--- /dev/null
+++ b/tests/th/TH_TyInstWhere2.hs
@@ -0,0 +1,15 @@
+{-# LANGUAGE PolyKinds, DataKinds, TemplateHaskell, TypeFamilies #-}
+
+module TH_TyInstWhere2 where
+
+import Language.Haskell.TH
+
+type family F (a :: k) (b :: k) :: Bool
+
+$( do { decs <- [d| type instance where
+                      F a a = True
+                      F a b = False |]
+      ; reportWarning (pprint decs)
+      ; return [] })
+
+
diff --git a/tests/th/TH_TyInstWhere2.stderr b/tests/th/TH_TyInstWhere2.stderr
new file mode 100644
index 0000000..4ed490e
--- /dev/null
+++ b/tests/th/TH_TyInstWhere2.stderr
@@ -0,0 +1,5 @@
+
+TH_TyInstWhere2.hs:9:4: Warning:
+    type instance where
+    TH_TyInstWhere2.F a_0 a_0 = 'GHC.Types.True
+    TH_TyInstWhere2.F a_1 b_2 = 'GHC.Types.False
diff --git a/tests/th/TH_TyInstWhere3.hs b/tests/th/TH_TyInstWhere3.hs
new file mode 100644
index 0000000..54d76f5
--- /dev/null
+++ b/tests/th/TH_TyInstWhere3.hs
@@ -0,0 +1,18 @@
+{-# LANGUAGE PolyKinds, DataKinds, TemplateHaskell, TypeFamilies #-}
+
+module TH_TyInstWhere3 where
+
+import Language.Haskell.TH
+
+type family F a
+
+$( do { decs <- [d| type instance where
+                      F Int = Int |]
+      ; reportWarning (pprint decs)
+      ; return decs })
+
+type instance F a = a 
+
+-- When this test was written, TH considered all singleton type family instance
+-- as unbranched. Thus, even though the two instances above would not play nicely
+-- without TH, they should be fine with TH.
diff --git a/tests/th/TH_TyInstWhere3.stderr b/tests/th/TH_TyInstWhere3.stderr
new file mode 100644
index 0000000..eaebfec
--- /dev/null
+++ b/tests/th/TH_TyInstWhere3.stderr
@@ -0,0 +1,3 @@
+
+TH_TyInstWhere3.hs:9:4: Warning:
+    type instance TH_TyInstWhere3.F GHC.Types.Int = GHC.Types.Int
diff --git a/tests/th/TH_TyInstWhere4.hs b/tests/th/TH_TyInstWhere4.hs
new file mode 100644
index 0000000..86415ff
--- /dev/null
+++ b/tests/th/TH_TyInstWhere4.hs
@@ -0,0 +1,20 @@
+{-# LANGUAGE PolyKinds, DataKinds, TemplateHaskell, TypeFamilies #-}
+
+module TH_TyInstWhere4 where
+
+import Language.Haskell.TH
+
+type family F a b :: Bool
+type instance where
+  F a a = True
+  F a b = False
+
+$( do { info1 <- reify ''F
+      ; reportWarning (pprint info1)
+      ; info2 <- reifyInstances ''F [ConT ''Int, ConT ''Int]
+      ; reportWarning (pprint info2)
+      ; info3 <- reifyInstances ''F [ConT ''Int, ConT ''Bool]
+      ; reportWarning (pprint info3)
+      ; return [] })
+
+
diff --git a/tests/th/TH_TyInstWhere4.stderr b/tests/th/TH_TyInstWhere4.stderr
new file mode 100644
index 0000000..70dfe85
--- /dev/null
+++ b/tests/th/TH_TyInstWhere4.stderr
@@ -0,0 +1,16 @@
+
+TH_TyInstWhere4.hs:12:4: Warning:
+    type family TH_TyInstWhere4.F a_0 b_1 :: * -> * -> GHC.Types.Bool
+type instance where
+    TH_TyInstWhere4.F a_2 a_2 = GHC.Types.True
+    TH_TyInstWhere4.F a_3 b_4 = GHC.Types.False
+
+TH_TyInstWhere4.hs:12:4: Warning:
+    type instance where
+    TH_TyInstWhere4.F a_0 a_0 = GHC.Types.True
+    TH_TyInstWhere4.F a_1 b_2 = GHC.Types.False
+
+TH_TyInstWhere4.hs:12:4: Warning:
+    type instance where
+    TH_TyInstWhere4.F a_0 a_0 = GHC.Types.True
+    TH_TyInstWhere4.F a_1 b_2 = GHC.Types.False
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.