summaryrefslogtreecommitdiff
path: root/testsuite/tests
diff options
context:
space:
mode:
authorRyan Scott <ryan.gl.scott@gmail.com>2018-11-26 12:59:09 -0500
committerRyan Scott <ryan.gl.scott@gmail.com>2018-11-26 12:59:11 -0500
commitf932b1aa42f45625658c8abaf862cc570507c5ca (patch)
tree0755ee1ce530f0afee8a6b5ec44f22e53eee3cc5 /testsuite/tests
parentdf570d920fa66db631f936fa377e598fe92bd2a1 (diff)
downloadhaskell-f932b1aa42f45625658c8abaf862cc570507c5ca.tar.gz
Print explicit foralls in type family eqns when appropriate
Summary: When `-fprint-explicit-foralls` is enabled, type family equations are either printed without an explict `forall` entirely, or with a bizarre square bracket syntax (in the case of closed type families). I find neither satisfying, so in this patch, I introduce support for printing explicit `forall`s in open type-family, closed type-family, and data-family equations when appropriate. (By "when appropriate", I refer to the conditions laid out in `Note [When to print foralls]` in `IfaceType`.) One tricky point in the implementation is that I had to pick a visibility for each type variable in a `CoAxiom`/`FamInst` in order to be able to pass it to `pprUserIfaceForAll` //et al.// Because the type variables in a type family instance equation can't be instantiated by the programmer anyway, the choice only really matters for pretty-printing purposes, so I simply went with good ol' trustworthy `Specified`. (This design choice is documented in `Note [Printing foralls in type family instances]` in `IfaceType`.) Test Plan: make test TEST=T15827 Reviewers: goldfire, bgamari, simonpj Reviewed By: simonpj Subscribers: simonpj, rwbarton, carter GHC Trac Issues: #15827 Differential Revision: https://phabricator.haskell.org/D5282
Diffstat (limited to 'testsuite/tests')
-rw-r--r--testsuite/tests/ghci/scripts/T13420.stdout9
-rw-r--r--testsuite/tests/ghci/scripts/T15341.stdout8
-rw-r--r--testsuite/tests/ghci/scripts/T15827.hs16
-rw-r--r--testsuite/tests/ghci/scripts/T15827.script4
-rw-r--r--testsuite/tests/ghci/scripts/T15827.stdout9
-rw-r--r--testsuite/tests/ghci/scripts/T4175.stdout7
-rw-r--r--testsuite/tests/ghci/scripts/T7939.stdout22
-rw-r--r--testsuite/tests/ghci/scripts/T8674.stdout3
-rw-r--r--testsuite/tests/ghci/scripts/T9181.stdout2
-rwxr-xr-xtestsuite/tests/ghci/scripts/all.T1
10 files changed, 54 insertions, 27 deletions
diff --git a/testsuite/tests/ghci/scripts/T13420.stdout b/testsuite/tests/ghci/scripts/T13420.stdout
index e6b81adc41..c6dbaf2755 100644
--- a/testsuite/tests/ghci/scripts/T13420.stdout
+++ b/testsuite/tests/ghci/scripts/T13420.stdout
@@ -1,6 +1,5 @@
-type family F a :: *
- where
- F [Int] = Bool
- F [a] = Double
- F (a b) = Char
+type family F a :: * where
+ F [Int] = Bool
+ F [a] = Double
+ F (a b) = Char
-- Defined at T13420.hs:4:1
diff --git a/testsuite/tests/ghci/scripts/T15341.stdout b/testsuite/tests/ghci/scripts/T15341.stdout
index 0633ae5b39..e2555f9ac9 100644
--- a/testsuite/tests/ghci/scripts/T15341.stdout
+++ b/testsuite/tests/ghci/scripts/T15341.stdout
@@ -1,6 +1,6 @@
-type family Foo (a :: k) :: k
- where Foo a = a
+type family Foo (a :: k) :: k where
+ forall k (a :: k). Foo a = a
-- Defined at T15341.hs:5:1
-type family Foo @k (a :: k) :: k
- where Foo @k a = a
+type family Foo @k (a :: k) :: k where
+ forall k (a :: k). Foo @k a = a
-- Defined at T15341.hs:5:1
diff --git a/testsuite/tests/ghci/scripts/T15827.hs b/testsuite/tests/ghci/scripts/T15827.hs
new file mode 100644
index 0000000000..ba67534e62
--- /dev/null
+++ b/testsuite/tests/ghci/scripts/T15827.hs
@@ -0,0 +1,16 @@
+{-# LANGUAGE PolyKinds #-}
+{-# LANGUAGE ScopedTypeVariables #-}
+{-# LANGUAGE TypeFamilies #-}
+module T15827 where
+
+import Data.Kind
+import Data.Proxy
+
+type family F1 (a :: k)
+type instance forall k (a :: k). F1 a = Proxy a
+
+type family F2 (a :: k) :: Type where
+ forall k (a :: k). F2 a = Proxy a
+
+data family D (a :: k)
+data instance forall k (a :: k). D a = MkD (Proxy a)
diff --git a/testsuite/tests/ghci/scripts/T15827.script b/testsuite/tests/ghci/scripts/T15827.script
new file mode 100644
index 0000000000..a05fcd8a2d
--- /dev/null
+++ b/testsuite/tests/ghci/scripts/T15827.script
@@ -0,0 +1,4 @@
+:load T15827
+:info F1
+:info F2
+:info D
diff --git a/testsuite/tests/ghci/scripts/T15827.stdout b/testsuite/tests/ghci/scripts/T15827.stdout
new file mode 100644
index 0000000000..50df504e58
--- /dev/null
+++ b/testsuite/tests/ghci/scripts/T15827.stdout
@@ -0,0 +1,9 @@
+type family F1 (a :: k) :: * -- Defined at T15827.hs:9:1
+type instance forall k (a :: k). F1 a = Proxy a
+ -- Defined at T15827.hs:10:34
+type family F2 (a :: k) :: * where
+ forall k (a :: k). F2 a = Proxy a
+ -- Defined at T15827.hs:12:1
+data family D (a :: k) -- Defined at T15827.hs:15:1
+data instance forall k (a :: k). D a = MkD (Proxy a)
+ -- Defined at T15827.hs:16:34
diff --git a/testsuite/tests/ghci/scripts/T4175.stdout b/testsuite/tests/ghci/scripts/T4175.stdout
index e95d9c76af..de4e28c46f 100644
--- a/testsuite/tests/ghci/scripts/T4175.stdout
+++ b/testsuite/tests/ghci/scripts/T4175.stdout
@@ -11,10 +11,9 @@ class C a where
-- Defined at T4175.hs:16:5
type instance D () () = Bool -- Defined at T4175.hs:22:10
type instance D Int () = String -- Defined at T4175.hs:19:10
-type family E a :: *
- where
- E () = Bool
- E Int = String
+type family E a :: * where
+ E () = Bool
+ E Int = String
-- Defined at T4175.hs:24:1
data () = () -- Defined in ‘GHC.Tuple’
instance [safe] C () -- Defined at T4175.hs:21:10
diff --git a/testsuite/tests/ghci/scripts/T7939.stdout b/testsuite/tests/ghci/scripts/T7939.stdout
index 82a8658906..4c2a602f4f 100644
--- a/testsuite/tests/ghci/scripts/T7939.stdout
+++ b/testsuite/tests/ghci/scripts/T7939.stdout
@@ -5,23 +5,21 @@ Bar :: k -> * -> *
type family F a :: * -- Defined at T7939.hs:8:1
type instance F Int = Bool -- Defined at T7939.hs:9:15
F :: * -> *
-type family G a :: *
- where G Int = Bool
+type family G a :: * where
+ G Int = Bool
-- Defined at T7939.hs:11:1
G :: * -> *
-type family H (a :: Bool) :: Bool
- where H 'False = 'True
+type family H (a :: Bool) :: Bool where
+ H 'False = 'True
-- Defined at T7939.hs:14:1
H :: Bool -> Bool
-type family J (a :: [k]) :: Bool
- where
- J '[] = 'False
- J (h : t) = 'True
+type family J (a :: [k]) :: Bool where
+ J '[] = 'False
+ forall k (h :: k) (t :: [k]). J (h : t) = 'True
-- Defined at T7939.hs:17:1
J :: [k] -> Bool
-type family K (a1 :: [a]) :: Maybe a
- where
- K '[] = 'Nothing
- K (h : t) = 'Just h
+type family K (a1 :: [a]) :: Maybe a where
+ K '[] = 'Nothing
+ forall a (h :: a) (t :: [a]). K (h : t) = 'Just h
-- Defined at T7939.hs:21:1
K :: [a] -> Maybe a
diff --git a/testsuite/tests/ghci/scripts/T8674.stdout b/testsuite/tests/ghci/scripts/T8674.stdout
index 45d4f0af0e..d938f95692 100644
--- a/testsuite/tests/ghci/scripts/T8674.stdout
+++ b/testsuite/tests/ghci/scripts/T8674.stdout
@@ -1,3 +1,4 @@
data family Sing (a :: k) -- Defined at T8674.hs:4:1
data instance Sing Bool = SBool -- Defined at T8674.hs:6:15
-data instance Sing a = SNil -- Defined at T8674.hs:5:15
+data instance forall k (a :: [k]). Sing a = SNil
+ -- Defined at T8674.hs:5:15
diff --git a/testsuite/tests/ghci/scripts/T9181.stdout b/testsuite/tests/ghci/scripts/T9181.stdout
index 5e520fb0a2..a30879c316 100644
--- a/testsuite/tests/ghci/scripts/T9181.stdout
+++ b/testsuite/tests/ghci/scripts/T9181.stdout
@@ -21,7 +21,7 @@ data GHC.TypeLits.SomeSymbol
GHC.TypeLits.KnownSymbol n =>
GHC.TypeLits.SomeSymbol (Data.Proxy.Proxy n)
type family GHC.TypeLits.TypeError (a :: GHC.TypeLits.ErrorMessage)
- :: b
+ :: b where
GHC.TypeLits.natVal ::
GHC.TypeNats.KnownNat n => proxy n -> Integer
GHC.TypeLits.natVal' ::
diff --git a/testsuite/tests/ghci/scripts/all.T b/testsuite/tests/ghci/scripts/all.T
index 493daa4412..82197072c7 100755
--- a/testsuite/tests/ghci/scripts/all.T
+++ b/testsuite/tests/ghci/scripts/all.T
@@ -288,4 +288,5 @@ test('T15568', normal, ghci_script, ['T15568.script'])
test('T15325', normal, ghci_script, ['T15325.script'])
test('T15591', normal, ghci_script, ['T15591.script'])
test('T15743b', normal, ghci_script, ['T15743b.script'])
+test('T15827', normal, ghci_script, ['T15827.script'])
test('T15898', normal, ghci_script, ['T15898.script'])