diff options
author | Iavor S. Diatchki <diatchki@galois.com> | 2015-03-07 10:37:31 -0600 |
---|---|---|
committer | Austin Seipp <austin@well-typed.com> | 2015-03-07 10:38:30 -0600 |
commit | b359c886cd7578ed083bcedcea05d315ecaeeb54 (patch) | |
tree | bb1959149dde78d29614966131841a77fa38bbab /testsuite | |
parent | 479523f3c37894d63352f1718e06696f3ed63143 (diff) | |
download | haskell-b359c886cd7578ed083bcedcea05d315ecaeeb54.tar.gz |
Custom `Typeable` solver, that keeps track of kinds.
Summary:
This implements the new `Typeable` solver: when GHC sees `Typeable` constraints
it solves them on the spot.
The current implementation creates `TyCon` representations on the spot.
Pro: No overhead at all in code that does not use `Typeable`
Cons: Code that uses `Typeable` may create multipe `TyCon` represntations.
We have discussed an implementation where representations of `TyCons` are
computed once, in the module, where a datatype is declared. This would
lead to more code being generated: for a promotable datatype we need to
generate `2 + number_of_data_cons` type-constructro representations,
and we have to do that for all programs, even ones that do not intend to
use typeable.
I added code to emit warning whenevar `deriving Typeable` is encountered---
the idea being that this is not needed anymore, and shold be fixed.
Also, we allow `instance Typeable T` in .hs-boot files, but they result
in a warning, and are ignored. This last one was to avoid breaking exisitng
code, and should become an error, eventually.
Test Plan:
1. GHC can compile itself.
2. I compiled a number of large libraries, including `lens`.
- I had to make some small changes:
`unordered-containers` uses internals of `TypeReps`, so I had to do a 1 line fix
- `lens` needed one instance changed, due to a poly-kinded `Typeble` instance
3. I also run some code that uses `syb` to traverse a largish datastrucutre.
I didn't notice any signifiant performance difference between the 7.8.3 version,
and this implementation.
Reviewers: simonpj, simonmar, austin, hvr
Reviewed By: austin, hvr
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D652
GHC Trac Issues: #9858
Diffstat (limited to 'testsuite')
17 files changed, 27 insertions, 107 deletions
diff --git a/testsuite/tests/annotations/should_fail/annfail10.stderr b/testsuite/tests/annotations/should_fail/annfail10.stderr index 262677b7f8..5b42bd3c9b 100644 --- a/testsuite/tests/annotations/should_fail/annfail10.stderr +++ b/testsuite/tests/annotations/should_fail/annfail10.stderr @@ -7,9 +7,8 @@ annfail10.hs:9:1: Data.Data.Data (Either a b) -- Defined in ‘Data.Data’ instance Data.Data.Data Data.Monoid.All -- Defined in ‘Data.Data’ - instance forall (k :: BOX) (f :: k -> *) (a :: k). - (Data.Data.Data (f a), Data.Typeable.Internal.Typeable f, - Data.Typeable.Internal.Typeable a) => + instance (Data.Data.Data (f a), Data.Data.Data a, + Data.Typeable.Internal.Typeable f) => Data.Data.Data (Data.Monoid.Alt f a) -- Defined in ‘Data.Data’ ...plus 39 others diff --git a/testsuite/tests/deriving/should_compile/all.T b/testsuite/tests/deriving/should_compile/all.T index 8d9023646c..b56baed668 100644 --- a/testsuite/tests/deriving/should_compile/all.T +++ b/testsuite/tests/deriving/should_compile/all.T @@ -46,7 +46,7 @@ test('T8758', extra_clean(['T8758a.o', 'T8758a.hi']), multimod_compile, ['T8758a test('T8678', normal, compile, ['']) test('T8865', normal, compile, ['']) test('T8893', normal, compile, ['']) -test('T8950', expect_broken(8950), compile, ['']) +test('T8950', normal, compile, ['']) test('T8963', normal, compile, ['']) test('T7269', normal, compile, ['']) test('T9069', normal, compile, ['']) diff --git a/testsuite/tests/deriving/should_fail/T2604.hs b/testsuite/tests/deriving/should_fail/T2604.hs deleted file mode 100644 index 0f830d992b..0000000000 --- a/testsuite/tests/deriving/should_fail/T2604.hs +++ /dev/null @@ -1,9 +0,0 @@ -{-# LANGUAGE GeneralizedNewtypeDeriving #-} - -module Test where - -import Data.Typeable - -data DList a = DList [a] deriving(Typeable) - -newtype NList a = NList [a] deriving(Typeable) diff --git a/testsuite/tests/deriving/should_fail/T2604.stderr b/testsuite/tests/deriving/should_fail/T2604.stderr deleted file mode 100644 index 3000b5002f..0000000000 --- a/testsuite/tests/deriving/should_fail/T2604.stderr +++ /dev/null @@ -1,10 +0,0 @@ - -T2604.hs:7:35: - Can't make a Typeable instance of ‘DList’ - You need DeriveDataTypeable to derive Typeable instances - In the data declaration for ‘DList’ - -T2604.hs:9:38: - Can't make a Typeable instance of ‘NList’ - You need DeriveDataTypeable to derive Typeable instances - In the newtype declaration for ‘NList’ diff --git a/testsuite/tests/deriving/should_fail/T5863a.hs b/testsuite/tests/deriving/should_fail/T5863a.hs deleted file mode 100644 index 3506dcc04a..0000000000 --- a/testsuite/tests/deriving/should_fail/T5863a.hs +++ /dev/null @@ -1,12 +0,0 @@ -{-# LANGUAGE DeriveDataTypeable, TypeFamilies #-}
-
-import Data.Typeable
-
-class C a where
- data T a :: *
-
-instance C Int where
- data T Int = A1 deriving (Typeable)
-
-instance C Bool where
- data T Bool = A2 deriving (Typeable)
diff --git a/testsuite/tests/deriving/should_fail/T5863a.stderr b/testsuite/tests/deriving/should_fail/T5863a.stderr deleted file mode 100644 index d64f1b20ce..0000000000 --- a/testsuite/tests/deriving/should_fail/T5863a.stderr +++ /dev/null @@ -1,10 +0,0 @@ - -T5863a.hs:9:31: - Deriving Typeable is not allowed for family instances; - derive Typeable for ‘T’ alone - In the data instance declaration for ‘T’ - -T5863a.hs:12:32: - Deriving Typeable is not allowed for family instances; - derive Typeable for ‘T’ alone - In the data instance declaration for ‘T’ diff --git a/testsuite/tests/deriving/should_fail/T7800.hs b/testsuite/tests/deriving/should_fail/T7800.hs deleted file mode 100644 index 9f190cfa51..0000000000 --- a/testsuite/tests/deriving/should_fail/T7800.hs +++ /dev/null @@ -1,7 +0,0 @@ -{-# LANGUAGE StandaloneDeriving, DeriveDataTypeable #-} -module T7800 where - -import T7800a -import Data.Typeable - -deriving instance Typeable A diff --git a/testsuite/tests/deriving/should_fail/T7800.stderr b/testsuite/tests/deriving/should_fail/T7800.stderr deleted file mode 100644 index 8cd8533968..0000000000 --- a/testsuite/tests/deriving/should_fail/T7800.stderr +++ /dev/null @@ -1,6 +0,0 @@ -[1 of 2] Compiling T7800a ( T7800a.hs, T7800a.o ) -[2 of 2] Compiling T7800 ( T7800.hs, T7800.o ) - -T7800.hs:7:1: - To make a Typeable instance of poly-kinded ‘A’, use XPolyKinds - In the stand-alone deriving instance for ‘Typeable A’ diff --git a/testsuite/tests/deriving/should_fail/T7800a.hs b/testsuite/tests/deriving/should_fail/T7800a.hs deleted file mode 100644 index 22f1305d2e..0000000000 --- a/testsuite/tests/deriving/should_fail/T7800a.hs +++ /dev/null @@ -1,4 +0,0 @@ -{-# LANGUAGE PolyKinds #-} -module T7800a where - -data A a
\ No newline at end of file diff --git a/testsuite/tests/deriving/should_fail/T9687.stderr b/testsuite/tests/deriving/should_fail/T9687.stderr index 10619a6575..ad95393db7 100644 --- a/testsuite/tests/deriving/should_fail/T9687.stderr +++ b/testsuite/tests/deriving/should_fail/T9687.stderr @@ -1,5 +1,3 @@ T9687.hs:4:10: - Typeable instances can only be derived - Try ‘deriving instance Typeable (,,,,,,,)’ - (requires StandaloneDeriving) + Class `Typeable` does not support user-specified instances. diff --git a/testsuite/tests/deriving/should_fail/all.T b/testsuite/tests/deriving/should_fail/all.T index df7957d9b0..60a4b7b45c 100644 --- a/testsuite/tests/deriving/should_fail/all.T +++ b/testsuite/tests/deriving/should_fail/all.T @@ -17,7 +17,7 @@ test('drvfail016', run_command, ['$MAKE --no-print-directory -s drvfail016']) test('T2394', normal, compile_fail, ['']) -test('T2604', normal, compile_fail, ['']) +# T2604 was removed as it was out of date re: fixing #9858 test('T2701', normal, compile_fail, ['']) test('T2851', normal, compile_fail, ['']) test('T2721', normal, compile_fail, ['']) @@ -38,14 +38,14 @@ test('T1133A', extra_clean(['T1133A.o-boot', 'T1133A.hi-boot']), run_command, ['$MAKE --no-print-directory -s T1133A']) -test('T5863a', normal, compile_fail, ['']) +# 5863a was removed as it was out of date re: fixing #9858 test('T7959', normal, compile_fail, ['']) test('T1496', normal, compile_fail, ['']) test('T4846', normal, compile_fail, ['']) test('T7148', normal, compile_fail, ['']) test('T7148a', normal, compile_fail, ['']) -test('T7800', normal, multimod_compile_fail, ['T7800','']) +# T7800 was removed as it was out of date re: fixing #9858 test('T5498', normal, compile_fail, ['']) test('T6147', normal, compile_fail, ['']) test('T8851', normal, compile_fail, ['']) diff --git a/testsuite/tests/ghci.debugger/scripts/print019.stderr b/testsuite/tests/ghci.debugger/scripts/print019.stderr index 139ce8d111..0c92dba4e4 100644 --- a/testsuite/tests/ghci.debugger/scripts/print019.stderr +++ b/testsuite/tests/ghci.debugger/scripts/print019.stderr @@ -5,12 +5,8 @@ Use :print or :force to determine these types Relevant bindings include it :: a1 (bound at <interactive>:11:1) Note: there are several potential instances: - instance forall (k :: BOX) (s :: k). Show (Proxy s) - -- Defined in ‘Data.Proxy’ - instance forall (k :: BOX) (a :: k) (b :: k). - Show (Data.Type.Coercion.Coercion a b) - -- Defined in ‘Data.Type.Coercion’ - instance forall (k :: BOX) (a :: k) (b :: k). Show (a :~: b) - -- Defined in ‘Data.Type.Equality’ - ...plus 47 others + instance Show TyCon -- Defined in ‘Data.Typeable.Internal’ + instance Show TypeRep -- Defined in ‘Data.Typeable.Internal’ + instance Show a => Show (Maybe a) -- Defined in ‘GHC.Show’ + ...plus 30 others In a stmt of an interactive GHCi command: print it diff --git a/testsuite/tests/polykinds/T8132.stderr b/testsuite/tests/polykinds/T8132.stderr index 6c567de60a..e4c46591c3 100644 --- a/testsuite/tests/polykinds/T8132.stderr +++ b/testsuite/tests/polykinds/T8132.stderr @@ -1,5 +1,3 @@ T8132.hs:6:10: - Typeable instances can only be derived - Try ‘deriving instance Typeable K’ - (requires StandaloneDeriving) + Class `Typeable` does not support user-specified instances. diff --git a/testsuite/tests/typecheck/should_compile/T9999.hs b/testsuite/tests/typecheck/should_compile/T9999.hs deleted file mode 100644 index 656e913043..0000000000 --- a/testsuite/tests/typecheck/should_compile/T9999.hs +++ /dev/null @@ -1,13 +0,0 @@ -{-# LANGUAGE AutoDeriveTypeable, PolyKinds, TypeFamilies, StandaloneDeriving #-} - -module T9999 where - -import Data.Typeable - -data family F a - -class C a where - data F1 a - type F2 a - -main = typeRep (Proxy :: Proxy F) == typeRep (Proxy :: Proxy F1) diff --git a/testsuite/tests/typecheck/should_compile/all.T b/testsuite/tests/typecheck/should_compile/all.T index c1ed5790b4..7b3fb9f981 100644 --- a/testsuite/tests/typecheck/should_compile/all.T +++ b/testsuite/tests/typecheck/should_compile/all.T @@ -440,7 +440,6 @@ test('T9892', normal, compile, ['']) test('T9939', normal, compile, ['']) test('T9973', normal, compile, ['']) test('T9971', normal, compile, ['']) -test('T9999', normal, compile, ['']) test('T10031', normal, compile, ['']) test('T10072', normal, compile_fail, ['']) test('T10100', normal, compile, ['']) diff --git a/testsuite/tests/typecheck/should_fail/TcStaticPointersFail02.stderr b/testsuite/tests/typecheck/should_fail/TcStaticPointersFail02.stderr index ead183c7a1..3989ea4936 100644 --- a/testsuite/tests/typecheck/should_fail/TcStaticPointersFail02.stderr +++ b/testsuite/tests/typecheck/should_fail/TcStaticPointersFail02.stderr @@ -1,14 +1,14 @@ -
-TcStaticPointersFail02.hs:9:6:
- No instance for (Data.Typeable.Internal.Typeable b)
- arising from a static form
- In the expression: static (undefined :: (forall a. a -> a) -> b)
- In an equation for ‘f1’:
- f1 = static (undefined :: (forall a. a -> a) -> b)
-
-TcStaticPointersFail02.hs:12:6:
- No instance for (Data.Typeable.Internal.Typeable Monad)
- (maybe you haven't applied a function to enough arguments?)
- arising from a static form
- In the expression: static return
- In an equation for ‘f2’: f2 = static return
+ +TcStaticPointersFail02.hs:9:6: + No instance for (Data.Typeable.Internal.Typeable b) + arising from a static form + In the expression: static (undefined :: (forall a. a -> a) -> b) + In an equation for ‘f1’: + f1 = static (undefined :: (forall a. a -> a) -> b) + +TcStaticPointersFail02.hs:12:6: + No instance for (Data.Typeable.Internal.Typeable m) + (maybe you haven't applied a function to enough arguments?) + arising from a static form + In the expression: static return + In an equation for ‘f2’: f2 = static return diff --git a/testsuite/tests/typecheck/should_fail/all.T b/testsuite/tests/typecheck/should_fail/all.T index 20eede0f96..1ebb0a718f 100644 --- a/testsuite/tests/typecheck/should_fail/all.T +++ b/testsuite/tests/typecheck/should_fail/all.T @@ -353,3 +353,4 @@ test('T9497d', normal, compile_fail, ['-fdefer-type-errors -fno-defer-typed-hole test('T8044', normal, compile_fail, ['']) test('T4921', normal, compile_fail, ['']) test('T9605', normal, compile_fail, ['']) +test('T9999', normal, compile_fail, ['']) |