diff options
author | Ryan Scott <ryan.gl.scott@gmail.com> | 2018-11-08 10:26:48 -0500 |
---|---|---|
committer | Ryan Scott <ryan.gl.scott@gmail.com> | 2018-11-08 10:26:48 -0500 |
commit | 63a817074a8d49798bfd46a6545906fff143e924 (patch) | |
tree | a57848924bb854f5adf33957951cbed076c2bceb /testsuite/tests/th | |
parent | 932cd41d8c7984c767c1b3b58e05146f69cc5c15 (diff) | |
download | haskell-63a817074a8d49798bfd46a6545906fff143e924.tar.gz |
Fix #15845 by defining etaExpandFamInstLHS and using it
Summary:
Both #9692 and #14179 were caused by GHC being careless
about using eta-reduced data family instance axioms. Each of those
tickets were fixed by manually whipping up some code to eta-expand
the axioms. The same sort of issue has now caused #15845, so I
figured it was high time to factor out the code that each of these
fixes have in common.
This patch introduces the `etaExpandFamInstLHS` function, which takes
a family instance's type variables, LHS types, and RHS type, and
returns type variables and LHS types that have been eta-expanded if
necessary, in the case of a data family instance. (If it's a type
family instance, `etaExpandFamInstLHS` just returns the supplied type
variables and LHS types unchanged).
Along the way, I noticed that many references to
`Note [Eta reduction for data families]` (in `FamInstEnv`) had
slightly bitrotted (they either referred to a somewhat different
name, or claimed that the Note lived in a different module), so
I took the liberty of cleaning those up.
Test Plan: make test TEST="T9692 T15845"
Reviewers: goldfire, bgamari
Reviewed By: goldfire
Subscribers: rwbarton, carter
GHC Trac Issues: #15845
Differential Revision: https://phabricator.haskell.org/D5294
Diffstat (limited to 'testsuite/tests/th')
-rw-r--r-- | testsuite/tests/th/T15845.hs | 17 | ||||
-rw-r--r-- | testsuite/tests/th/T15845.stderr | 5 | ||||
-rw-r--r-- | testsuite/tests/th/T9692.stderr | 3 | ||||
-rw-r--r-- | testsuite/tests/th/all.T | 1 |
4 files changed, 25 insertions, 1 deletions
diff --git a/testsuite/tests/th/T15845.hs b/testsuite/tests/th/T15845.hs new file mode 100644 index 0000000000..b44808f25a --- /dev/null +++ b/testsuite/tests/th/T15845.hs @@ -0,0 +1,17 @@ +{-# LANGUAGE TemplateHaskell #-} +{-# LANGUAGE TypeFamilies #-} +module T15845 where + +import Language.Haskell.TH +import System.IO + +data family F1 a b +data instance F1 [a] b = MkF1 + +data family F2 a +data instance F2 a = MkF2 + +$(do i1 <- reify ''F1 + i2 <- reify ''F2 + runIO $ mapM_ (hPutStrLn stderr . pprint) [i1, i2] + pure []) diff --git a/testsuite/tests/th/T15845.stderr b/testsuite/tests/th/T15845.stderr new file mode 100644 index 0000000000..2b6a37e453 --- /dev/null +++ b/testsuite/tests/th/T15845.stderr @@ -0,0 +1,5 @@ +data family T15845.F1 (a_0 :: *) (b_1 :: *) :: * +data instance forall (a_2 :: *) (b_3 :: *). T15845.F1 ([a_2]) b_3 + = T15845.MkF1 +data family T15845.F2 (a_0 :: *) :: * +data instance forall (a_1 :: *). T15845.F2 a_1 = T15845.MkF2 diff --git a/testsuite/tests/th/T9692.stderr b/testsuite/tests/th/T9692.stderr index ffa55365d4..070e4d3005 100644 --- a/testsuite/tests/th/T9692.stderr +++ b/testsuite/tests/th/T9692.stderr @@ -1,2 +1,3 @@ data family T9692.F (a_0 :: k_1) (b_2 :: k_3) :: * -data instance T9692.F GHC.Types.Int (x_4 :: *) = T9692.FInt x_4 +data instance forall (x_4 :: *). T9692.F GHC.Types.Int (x_4 :: *) + = T9692.FInt x_4 diff --git a/testsuite/tests/th/all.T b/testsuite/tests/th/all.T index 2481a2ab12..adf897081b 100644 --- a/testsuite/tests/th/all.T +++ b/testsuite/tests/th/all.T @@ -448,3 +448,4 @@ test('T15783', normal, multimod_compile, test('T15792', normal, compile, ['-v0 -dsuppress-uniques']) test('T15815', normal, multimod_compile, ['T15815B', '-v0 ' + config.ghc_th_way_flags]) +test('T15845', normal, compile, ['-v0 -dsuppress-uniques']) |