diff options
author | Ryan Scott <ryan.gl.scott@gmail.com> | 2017-09-02 15:33:25 -0400 |
---|---|---|
committer | Ryan Scott <ryan.gl.scott@gmail.com> | 2017-09-02 15:33:26 -0400 |
commit | 8e4229ab3dc3e1717ad557ef00f3518da6b5c523 (patch) | |
tree | 64a50dd06118a0d3709d37b258faa11eb4d1a218 /testsuite | |
parent | 5dd6b13c6e2942976aa3b5f4906ff7d0f959272d (diff) | |
download | haskell-8e4229ab3dc3e1717ad557ef00f3518da6b5c523.tar.gz |
Fix #14167 by using isGadtSyntaxTyCon in more places
Summary:
Two places in GHC effectively attempt to //guess// whether a data type
was declared using GADT syntax:
1. When reifying a data type in Template Haskell
2. When pretty-printing a data type (e.g., via `:info` in GHCi)
But there's no need for heuristics here, since we have a 100% accurate way to
determine whether a data type was declared using GADT syntax: the
`isGadtSyntaxTyCon` function! By simply using that as the metric, we obtain
far more accurate TH reification and pretty-printing results.
This is technically a breaking change, since Template Haskell reification will
now reify some data type constructors as `(Rec)GadtC` that it didn't before,
and some data type constructors that were previously reified as `(Rec)GadtC`
will no longer be reified as such. But it's a very understandable breaking
change, since the previous behavior was simply incorrect.
Test Plan: ./validate
Reviewers: simonpj, goldfire, austin, bgamari
Reviewed By: simonpj
Subscribers: rwbarton, thomie
GHC Trac Issues: #14167
Differential Revision: https://phabricator.haskell.org/D3901
Diffstat (limited to 'testsuite')
-rw-r--r-- | testsuite/tests/ghci/scripts/T7730.stdout | 3 | ||||
-rw-r--r-- | testsuite/tests/ghci/scripts/T7873.stdout | 4 | ||||
-rw-r--r-- | testsuite/tests/ghci/scripts/T9181.stdout | 30 | ||||
-rw-r--r-- | testsuite/tests/ghci/scripts/ghci030.stdout | 8 | ||||
-rw-r--r-- | testsuite/tests/rename/should_fail/rnfail055.stderr | 6 | ||||
-rw-r--r-- | testsuite/tests/th/T4188.stderr | 11 | ||||
-rw-r--r-- | testsuite/tests/typecheck/should_fail/T3468.stderr | 3 |
7 files changed, 31 insertions, 34 deletions
diff --git a/testsuite/tests/ghci/scripts/T7730.stdout b/testsuite/tests/ghci/scripts/T7730.stdout index e96e909413..bf9c1d025b 100644 --- a/testsuite/tests/ghci/scripts/T7730.stdout +++ b/testsuite/tests/ghci/scripts/T7730.stdout @@ -3,6 +3,5 @@ data A (x :: k) (y :: k1) -- Defined at <interactive>:2:1 A :: k1 -> k2 -> * type role T phantom -data T (a :: k) where - MkT :: forall k (a :: k) a1. a1 -> T a +data T (a :: k) = forall a1. MkT a1 -- Defined at <interactive>:6:1 diff --git a/testsuite/tests/ghci/scripts/T7873.stdout b/testsuite/tests/ghci/scripts/T7873.stdout index 2c79056da4..bcdebe71e1 100644 --- a/testsuite/tests/ghci/scripts/T7873.stdout +++ b/testsuite/tests/ghci/scripts/T7873.stdout @@ -1,5 +1,5 @@ -data D2 where - MkD2 :: (forall (p :: k -> *) (a :: k). p a -> Int) -> D2 +data D2 + = forall k. MkD2 (forall (p :: k -> *) (a :: k). p a -> Int) -- Defined at <interactive>:3:1 data D3 = MkD3 (forall k (p :: k -> *) (a :: k). p a -> Int) -- Defined at <interactive>:4:1 diff --git a/testsuite/tests/ghci/scripts/T9181.stdout b/testsuite/tests/ghci/scripts/T9181.stdout index d51b345d5c..1ae9bd54d0 100644 --- a/testsuite/tests/ghci/scripts/T9181.stdout +++ b/testsuite/tests/ghci/scripts/T9181.stdout @@ -4,19 +4,22 @@ type family GHC.TypeLits.AppendSymbol (a :: GHC.Types.Symbol) type family GHC.TypeLits.CmpSymbol (a :: GHC.Types.Symbol) (b :: GHC.Types.Symbol) :: Ordering -data GHC.TypeLits.ErrorMessage where - GHC.TypeLits.Text :: GHC.Types.Symbol -> GHC.TypeLits.ErrorMessage - GHC.TypeLits.ShowType :: t -> GHC.TypeLits.ErrorMessage - (GHC.TypeLits.:<>:) :: GHC.TypeLits.ErrorMessage - -> GHC.TypeLits.ErrorMessage -> GHC.TypeLits.ErrorMessage - (GHC.TypeLits.:$$:) :: GHC.TypeLits.ErrorMessage - -> GHC.TypeLits.ErrorMessage -> GHC.TypeLits.ErrorMessage +data GHC.TypeLits.ErrorMessage + = GHC.TypeLits.Text GHC.Types.Symbol + | forall t. GHC.TypeLits.ShowType t + | GHC.TypeLits.ErrorMessage + GHC.TypeLits.:<>: + GHC.TypeLits.ErrorMessage + | GHC.TypeLits.ErrorMessage + GHC.TypeLits.:$$: + GHC.TypeLits.ErrorMessage class GHC.TypeLits.KnownSymbol (n :: GHC.Types.Symbol) where GHC.TypeLits.symbolSing :: GHC.TypeLits.SSymbol n {-# MINIMAL symbolSing #-} -data GHC.TypeLits.SomeSymbol where - GHC.TypeLits.SomeSymbol :: GHC.TypeLits.KnownSymbol n => - (Data.Proxy.Proxy n) -> GHC.TypeLits.SomeSymbol +data GHC.TypeLits.SomeSymbol + = forall (n :: GHC.Types.Symbol). + GHC.TypeLits.KnownSymbol n => + GHC.TypeLits.SomeSymbol (Data.Proxy.Proxy n) type family GHC.TypeLits.TypeError (a :: GHC.TypeLits.ErrorMessage) :: b GHC.TypeLits.natVal :: @@ -54,9 +57,10 @@ class GHC.TypeNats.KnownNat (n :: GHC.Types.Nat) where GHC.TypeNats.natSing :: GHC.TypeNats.SNat n {-# MINIMAL natSing #-} data GHC.Types.Nat -data GHC.TypeNats.SomeNat where - GHC.TypeNats.SomeNat :: GHC.TypeNats.KnownNat n => - (Data.Proxy.Proxy n) -> GHC.TypeNats.SomeNat +data GHC.TypeNats.SomeNat + = forall (n :: GHC.Types.Nat). + GHC.TypeNats.KnownNat n => + GHC.TypeNats.SomeNat (Data.Proxy.Proxy n) data GHC.Types.Symbol type family (GHC.TypeNats.^) (a :: GHC.Types.Nat) (b :: GHC.Types.Nat) diff --git a/testsuite/tests/ghci/scripts/ghci030.stdout b/testsuite/tests/ghci/scripts/ghci030.stdout index 9344bc39bd..49ce606456 100644 --- a/testsuite/tests/ghci/scripts/ghci030.stdout +++ b/testsuite/tests/ghci/scripts/ghci030.stdout @@ -1,6 +1,2 @@ -data D where - C :: (Int -> a) -> Char -> D - -- Defined at ghci030.hs:8:1 -data D where - C :: (Int -> a) -> Char -> D - -- Defined at ghci030.hs:8:10 +data D = forall a. C (Int -> a) Char -- Defined at ghci030.hs:8:1 +data D = forall a. C (Int -> a) Char -- Defined at ghci030.hs:8:10 diff --git a/testsuite/tests/rename/should_fail/rnfail055.stderr b/testsuite/tests/rename/should_fail/rnfail055.stderr index 7fc5d80bad..b9ba174519 100644 --- a/testsuite/tests/rename/should_fail/rnfail055.stderr +++ b/testsuite/tests/rename/should_fail/rnfail055.stderr @@ -71,10 +71,8 @@ RnFail055.hs-boot:25:1: error: Type constructor ‘T7’ has conflicting definitions in the module and its hs-boot file Main module: type role T7 phantom - data T7 a where - T7 :: a1 -> T7 a - Boot file: data T7 a where - T7 :: a -> T7 a + data T7 a = forall a1. T7 a1 + Boot file: data T7 a = forall b. T7 a The roles do not match. Roles on abstract types default to ‘representational’ in boot files. The constructors do not match: The types for ‘T7’ differ diff --git a/testsuite/tests/th/T4188.stderr b/testsuite/tests/th/T4188.stderr index 2e4155fd8b..38a22cf172 100644 --- a/testsuite/tests/th/T4188.stderr +++ b/testsuite/tests/th/T4188.stderr @@ -1,8 +1,9 @@ -data T4188.T1 (a_0 :: *) = forall (b_1 :: *) . T4188.MkT1 a_0 b_1 -data T4188.T2 (a_0 :: *) - = forall (b_1 :: *) . (T4188.C a_0, T4188.C b_1) => T4188.MkT2 a_0 - b_1 +data T4188.T1 (a_0 :: *) where + T4188.MkT1 :: forall (a_1 :: *) (b_2 :: *) . a_1 -> + b_2 -> T4188.T1 a_1 +data T4188.T2 (a_0 :: *) where + T4188.MkT2 :: forall (a_1 :: *) (b_2 :: *) . (T4188.C a_1, + T4188.C b_2) => a_1 -> b_2 -> T4188.T2 a_1 data T4188.T3 (x_0 :: *) where T4188.MkT3 :: forall (x_1 :: *) (y_2 :: *) . (T4188.C x_1, T4188.C y_2) => x_1 -> y_2 -> T4188.T3 (x_1, y_2) - diff --git a/testsuite/tests/typecheck/should_fail/T3468.stderr b/testsuite/tests/typecheck/should_fail/T3468.stderr index 1f8bdcb11b..0a0fec223b 100644 --- a/testsuite/tests/typecheck/should_fail/T3468.stderr +++ b/testsuite/tests/typecheck/should_fail/T3468.stderr @@ -3,7 +3,6 @@ T3468.hs-boot:3:1: error: Type constructor ‘Tool’ has conflicting definitions in the module and its hs-boot file Main module: type role Tool phantom - data Tool d where - F :: a -> Tool d + data Tool d = forall a r. F a Boot file: data Tool The types have different kinds |