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/tests/deriving | |
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/tests/deriving')
-rw-r--r-- | testsuite/tests/deriving/should_compile/all.T | 2 | ||||
-rw-r--r-- | testsuite/tests/deriving/should_fail/T2604.hs | 9 | ||||
-rw-r--r-- | testsuite/tests/deriving/should_fail/T2604.stderr | 10 | ||||
-rw-r--r-- | testsuite/tests/deriving/should_fail/T5863a.hs | 12 | ||||
-rw-r--r-- | testsuite/tests/deriving/should_fail/T5863a.stderr | 10 | ||||
-rw-r--r-- | testsuite/tests/deriving/should_fail/T7800.hs | 7 | ||||
-rw-r--r-- | testsuite/tests/deriving/should_fail/T7800.stderr | 6 | ||||
-rw-r--r-- | testsuite/tests/deriving/should_fail/T7800a.hs | 4 | ||||
-rw-r--r-- | testsuite/tests/deriving/should_fail/T9687.stderr | 4 | ||||
-rw-r--r-- | testsuite/tests/deriving/should_fail/all.T | 6 |
10 files changed, 5 insertions, 65 deletions
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, ['']) |