diff options
author | Ben Gamari <ben@smart-cactus.org> | 2015-08-26 18:24:34 +0200 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2015-10-29 16:14:51 +0100 |
commit | bef2f03e4d56d88a7e9752a7afd6a0a35616da6c (patch) | |
tree | 9ae33978cf43d8268a6c5afa42e7a6c8a7e227a1 /testsuite/tests/ghci.debugger/scripts | |
parent | 40e6214c06bc197dbdfcf9f7345dad1ad271922b (diff) | |
download | haskell-bef2f03e4d56d88a7e9752a7afd6a0a35616da6c.tar.gz |
Generate Typeable info at definition sites
This patch implements the idea floated in Trac #9858, namely that we
should generate type-representation information at the data type
declaration site, rather than when solving a Typeable constraint.
However, this turned out quite a bit harder than I expected. I still
think it's the right thing to do, and it's done now, but it was quite
a struggle.
See particularly
* Note [Grand plan for Typeable] in TcTypeable (which is a new module)
* Note [The overall promotion story] in DataCon (clarifies existing stuff)
The most painful bit was that to generate Typeable instances (ie
TyConRepName bindings) for every TyCon is tricky for types in ghc-prim
etc:
* We need to have enough data types around to *define* a TyCon
* Many of these types are wired-in
Also, to minimise the code generated for each data type, I wanted to
generate pure data, not CAFs with unpackCString# stuff floating about.
Performance
~~~~~~~~~~~
Three perf/compiler tests start to allocate quite a bit more. This isn't
surprising, because they all allocate zillions of data types, with
practically no other code, esp. T1969
* T3294: GHC allocates 110% more (filed #11030 to track this)
* T1969: GHC allocates 30% more
* T4801: GHC allocates 14% more
* T5321FD: GHC allocates 13% more
* T783: GHC allocates 12% more
* T9675: GHC allocates 12% more
* T5642: GHC allocates 10% more
* T9961: GHC allocates 6% more
* T9203: Program allocates 54% less
I'm treating this as acceptable. The payoff comes in Typeable-heavy
code.
Remaining to do
~~~~~~~~~~~~~~~
* I think that "TyCon" and "Module" are over-generic names to use for
the runtime type representations used in GHC.Typeable. Better might be
"TrTyCon" and "TrModule". But I have not yet done this
* Add more info the the "TyCon" e.g. source location where it was
defined
* Use the new "Module" type to help with Trac Trac #10068
* It would be possible to generate TyConRepName (ie Typeable
instances) selectively rather than all the time. We'd need to persist
the information in interface files. Lacking a motivating reason I have
not done this, but it would not be difficult.
Refactoring
~~~~~~~~~~~
As is so often the case, I ended up refactoring more than I intended.
In particular
* In TyCon, a type *family* (whether type or data) is repesented by a
FamilyTyCon
* a algebraic data type (including data/newtype instances) is
represented by AlgTyCon This wasn't true before; a data family
was represented as an AlgTyCon. There are some corresponding
changes in IfaceSyn.
* Also get rid of the (unhelpfully named) tyConParent.
* In TyCon define 'Promoted', isomorphic to Maybe, used when things are
optionally promoted; and use it elsewhere in GHC.
* Cleanup handling of knownKeyNames
* Each TyCon, including promoted TyCons, contains its TyConRepName, if
it has one. This is, in effect, the name of its Typeable instance.
Requires update of the haddock submodule.
Differential Revision: https://phabricator.haskell.org/D757
Diffstat (limited to 'testsuite/tests/ghci.debugger/scripts')
12 files changed, 31 insertions, 31 deletions
diff --git a/testsuite/tests/ghci.debugger/scripts/T2740.stdout b/testsuite/tests/ghci.debugger/scripts/T2740.stdout index c6733bca9d..1f3e6d9ac5 100644 --- a/testsuite/tests/ghci.debugger/scripts/T2740.stdout +++ b/testsuite/tests/ghci.debugger/scripts/T2740.stdout @@ -1,5 +1,5 @@ Stopped at T2740.hs:(3,1)-(4,25) -_result :: a = _ +_result :: a2 = _ Stopped at T2740.hs:3:11-13 _result :: Bool = _ x :: Integer = 1 diff --git a/testsuite/tests/ghci.debugger/scripts/break006.stderr b/testsuite/tests/ghci.debugger/scripts/break006.stderr index b6e3cc9b12..56f40f2b21 100644 --- a/testsuite/tests/ghci.debugger/scripts/break006.stderr +++ b/testsuite/tests/ghci.debugger/scripts/break006.stderr @@ -12,7 +12,7 @@ Show (f a) => Show (Alt f a) -- Defined in ‘Data.Monoid’ - ...plus 33 others + ...plus 36 others (use -fprint-potential-instances to see them all) In a stmt of an interactive GHCi command: print it @@ -29,6 +29,6 @@ Show (f a) => Show (Alt f a) -- Defined in ‘Data.Monoid’ - ...plus 33 others + ...plus 36 others (use -fprint-potential-instances to see them all) In a stmt of an interactive GHCi command: print it diff --git a/testsuite/tests/ghci.debugger/scripts/break009.stdout b/testsuite/tests/ghci.debugger/scripts/break009.stdout index b926ed2474..14543668a1 100644 --- a/testsuite/tests/ghci.debugger/scripts/break009.stdout +++ b/testsuite/tests/ghci.debugger/scripts/break009.stdout @@ -1,6 +1,6 @@ Breakpoint 0 activated at ../Test6.hs:5:8-11 Stopped at ../Test6.hs:5:8-11 -_result :: a = _ +_result :: a2 = _ *** Exception: Prelude.head: empty list CallStack: - error, called at libraries/base/GHC/List.hs:1009:3 in base:GHC.List + error, called at libraries/base/GHC/List.hs:999:3 in base:GHC.List diff --git a/testsuite/tests/ghci.debugger/scripts/break010.stdout b/testsuite/tests/ghci.debugger/scripts/break010.stdout index 2751b6d160..682f4c3c1c 100644 --- a/testsuite/tests/ghci.debugger/scripts/break010.stdout +++ b/testsuite/tests/ghci.debugger/scripts/break010.stdout @@ -1,5 +1,5 @@ Breakpoint 0 activated at ../Test6.hs:5:8-11 Stopped at ../Test6.hs:5:8-11 -_result :: a = _ +_result :: a2 = _ Stopped at ../Test6.hs:5:8-11 -_result :: a = _ +_result :: a2 = _ diff --git a/testsuite/tests/ghci.debugger/scripts/break011.stdout b/testsuite/tests/ghci.debugger/scripts/break011.stdout index dafc1fc397..67bbec7ce1 100644 --- a/testsuite/tests/ghci.debugger/scripts/break011.stdout +++ b/testsuite/tests/ghci.debugger/scripts/break011.stdout @@ -9,12 +9,12 @@ _exception :: e = _ -2 : main (../Test7.hs:2:8-29) <end of history> Logged breakpoint at ../Test7.hs:2:18-28 -_result :: a12 +_result :: a14 Logged breakpoint at ../Test7.hs:2:8-29 -_result :: IO a12 +_result :: IO a14 no more logged breakpoints Logged breakpoint at ../Test7.hs:2:18-28 -_result :: a12 +_result :: a14 Stopped at <exception thrown> _exception :: e already at the beginning of the history @@ -23,7 +23,7 @@ _exception = SomeException "foo" "CallStack: error, called at ../Test7.hs:2:18 in main:Main") -_result :: a12 = _ +_result :: a14 = _ _exception :: SomeException = SomeException (ErrorCallWithLocation "foo" diff --git a/testsuite/tests/ghci.debugger/scripts/break012.stdout b/testsuite/tests/ghci.debugger/scripts/break012.stdout index 70fa0f37b9..88e8b3ee71 100644 --- a/testsuite/tests/ghci.debugger/scripts/break012.stdout +++ b/testsuite/tests/ghci.debugger/scripts/break012.stdout @@ -1,16 +1,16 @@ Stopped at break012.hs:(1,1)-(5,18) -_result :: (t, a1 -> a1, (), a -> a -> a) = _ +_result :: (t, a3 -> a3, (), a2 -> a2 -> a2) = _ Stopped at break012.hs:5:10-18 -_result :: (t, a1 -> a1, (), a -> a -> a) = _ +_result :: (t, a3 -> a3, (), a2 -> a2 -> a2) = _ a :: t = _ -b :: a2 -> a2 = _ +b :: a4 -> a4 = _ c :: () = _ -d :: a -> a -> a = _ +d :: a2 -> a2 -> a2 = _ a :: t -b :: a2 -> a2 +b :: a4 -> a4 c :: () -d :: a -> a -> a +d :: a2 -> a2 -> a2 a = (_t1::t) -b = (_t2::a2 -> a2) +b = (_t2::a4 -> a4) c = (_t3::()) -d = (_t4::a -> a -> a) +d = (_t4::a2 -> a2 -> a2) diff --git a/testsuite/tests/ghci.debugger/scripts/break018.stdout b/testsuite/tests/ghci.debugger/scripts/break018.stdout index a12e119a42..11ef5476b5 100644 --- a/testsuite/tests/ghci.debugger/scripts/break018.stdout +++ b/testsuite/tests/ghci.debugger/scripts/break018.stdout @@ -1,5 +1,5 @@ Stopped at ../mdo.hs:(30,1)-(32,27) -_result :: IO (N a) = _ +_result :: IO (N a6) = _ Stopped at ../mdo.hs:(30,16)-(32,27) _result :: IO (N Char) = _ x :: Char = 'h' @@ -10,4 +10,4 @@ f :: N Char = _ l :: N Char = _ x :: Char = 'h' Stopped at ../mdo.hs:(8,1)-(9,42) -_result :: IO (N a) = _ +_result :: IO (N a6) = _ diff --git a/testsuite/tests/ghci.debugger/scripts/break022/break022.stdout b/testsuite/tests/ghci.debugger/scripts/break022/break022.stdout index 99ac58dec2..a87ffce942 100644 --- a/testsuite/tests/ghci.debugger/scripts/break022/break022.stdout +++ b/testsuite/tests/ghci.debugger/scripts/break022/break022.stdout @@ -1,6 +1,6 @@ Breakpoint 0 activated at A.hs:4:1-9 Stopped at A.hs:4:1-9 -_result :: a1 = _ +_result :: a3 = _ Stopped at A.hs:4:7-9 _result :: () = _ x :: () = () diff --git a/testsuite/tests/ghci.debugger/scripts/break028.stdout b/testsuite/tests/ghci.debugger/scripts/break028.stdout index 2438d73a14..896a2416ef 100644 --- a/testsuite/tests/ghci.debugger/scripts/break028.stdout +++ b/testsuite/tests/ghci.debugger/scripts/break028.stdout @@ -1,5 +1,5 @@ Stopped at break028.hs:15:1-24 -_result :: Id a = _ +_result :: Id a3 = _ Stopped at break028.hs:15:23-24 -_result :: Id a = _ -x' :: Id a = _ +_result :: Id a3 = _ +x' :: Id a3 = _ diff --git a/testsuite/tests/ghci.debugger/scripts/print018.stdout b/testsuite/tests/ghci.debugger/scripts/print018.stdout index d5b7d4603c..a00d5374dd 100644 --- a/testsuite/tests/ghci.debugger/scripts/print018.stdout +++ b/testsuite/tests/ghci.debugger/scripts/print018.stdout @@ -3,9 +3,9 @@ Stopped at ../Test.hs:40:1-17 _result :: () = _ Stopped at ../Test.hs:40:10-17 _result :: () = _ -x :: a17 = _ -x = (_t1::a17) -x :: a17 +x :: a36 = _ +x = (_t1::a36) +x :: a36 () x = Unary x :: Unary diff --git a/testsuite/tests/ghci.debugger/scripts/print019.stderr b/testsuite/tests/ghci.debugger/scripts/print019.stderr index 894c553805..3c0edbde5a 100644 --- a/testsuite/tests/ghci.debugger/scripts/print019.stderr +++ b/testsuite/tests/ghci.debugger/scripts/print019.stderr @@ -5,9 +5,9 @@ Use :print or :force to determine these types Relevant bindings include it :: a1 (bound at <interactive>:10:1) These potential instances exist: - instance Show TyCon -- Defined in ‘Data.Typeable.Internal’ instance Show TypeRep -- Defined in ‘Data.Typeable.Internal’ + instance Show Module -- Defined in ‘GHC.Show’ instance Show Ordering -- Defined in ‘GHC.Show’ - ...plus 30 others + ...plus 32 others (use -fprint-potential-instances to see them all) In a stmt of an interactive GHCi command: print it diff --git a/testsuite/tests/ghci.debugger/scripts/print031.stdout b/testsuite/tests/ghci.debugger/scripts/print031.stdout index 529b6987b5..da3e14238d 100644 --- a/testsuite/tests/ghci.debugger/scripts/print031.stdout +++ b/testsuite/tests/ghci.debugger/scripts/print031.stdout @@ -4,5 +4,5 @@ Stopped at print031.hs:7:1-19 _result :: Bool = _ Stopped at print031.hs:7:7-19 _result :: Bool = _ -x :: t (Phantom a) = [Just (Phantom 1)] +x :: t (Phantom a5) = [Just (Phantom 1)] x = [Just (Phantom 1)] |