[commit: ghc] master: Normalise type families in the type of an expression (f7daf5a)
git at git.haskell.org
git at git.haskell.org
Wed May 6 12:52:47 UTC 2015
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/f7daf5afe2ba4f60f60245fa82306b89a272ffa8/ghc
>---------------------------------------------------------------
commit f7daf5afe2ba4f60f60245fa82306b89a272ffa8
Author: Christiaan Baaij <christiaan.baaij at gmail.com>
Date: Wed May 6 07:46:00 2015 -0500
Normalise type families in the type of an expression
Before, the type of an expression, and the type of a variable
binding that expression used to be different in GHCi. The
reason being that types of bound variables were already normalised.
Now, both are normalised.
This implements the suggestions as given in Trac #10321
Also adds an expected output for test T10321
Reviewed By: goldfire, simonpj
Differential Revision: https://phabricator.haskell.org/D870
GHC Trac Issues: #10321
>---------------------------------------------------------------
f7daf5afe2ba4f60f60245fa82306b89a272ffa8
compiler/typecheck/TcRnDriver.hs | 10 +++++++++-
testsuite/tests/ghci/scripts/T10321.stdout | 1 +
testsuite/tests/ghci/scripts/all.T | 2 +-
3 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/compiler/typecheck/TcRnDriver.hs b/compiler/typecheck/TcRnDriver.hs
index 311f7c8..30cd8fd 100644
--- a/compiler/typecheck/TcRnDriver.hs
+++ b/compiler/typecheck/TcRnDriver.hs
@@ -1777,7 +1777,15 @@ tcRnExpr hsc_env rdr_expr
_ <- simplifyInteractive (andWC stWC lie_top) ;
let { all_expr_ty = mkForAllTys qtvs (mkPiTypes dicts res_ty) } ;
- zonkTcType all_expr_ty
+ ty <- zonkTcType all_expr_ty ;
+
+ -- We normalise type families, so that the type of an expression is the
+ -- same as of a bound expression (TcBinds.mkInferredPolyId). See Trac
+ -- #10321 for further discussion.
+ fam_envs <- tcGetFamInstEnvs ;
+ -- normaliseType returns a coercion which we discard, so the Role is
+ -- irrelevant
+ return (snd (normaliseType fam_envs Nominal ty))
}
--------------------------
diff --git a/testsuite/tests/ghci/scripts/T10321.stdout b/testsuite/tests/ghci/scripts/T10321.stdout
new file mode 100644
index 0000000..d74ca95
--- /dev/null
+++ b/testsuite/tests/ghci/scripts/T10321.stdout
@@ -0,0 +1 @@
+3 :> 4 :> 5 :> Nil :: Num a => Vec 3 a
diff --git a/testsuite/tests/ghci/scripts/all.T b/testsuite/tests/ghci/scripts/all.T
index c562903..e25c7ec 100755
--- a/testsuite/tests/ghci/scripts/all.T
+++ b/testsuite/tests/ghci/scripts/all.T
@@ -210,4 +210,4 @@ test('T10122', normal, ghci_script, ['T10122.script'])
test('T10322', when(opsys('darwin'), expect_broken(10322)),
ghci_script, ['T10322.script'])
-test('T10321', expect_broken(10321), ghci_script, ['T10321.script'])
+test('T10321', normal, ghci_script, ['T10321.script'])
More information about the ghc-commits
mailing list