[commit: ghc] ghc-7.10: Normalise type families in the type of an expression (768f848)

git at git.haskell.org git at git.haskell.org
Mon May 11 10:07:20 UTC 2015


Repository : ssh://git@git.haskell.org/ghc

On branch  : ghc-7.10
Link       : http://ghc.haskell.org/trac/ghc/changeset/768f848a50899bbccb53a253388a847879f9792b/ghc

>---------------------------------------------------------------

commit 768f848a50899bbccb53a253388a847879f9792b
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
    
    (cherry picked from commit f7daf5afe2ba4f60f60245fa82306b89a272ffa8)


>---------------------------------------------------------------

768f848a50899bbccb53a253388a847879f9792b
 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 b6e2973..ed88c2d 100644
--- a/compiler/typecheck/TcRnDriver.hs
+++ b/compiler/typecheck/TcRnDriver.hs
@@ -1770,7 +1770,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 3d2fd67..270e3ae 100755
--- a/testsuite/tests/ghci/scripts/all.T
+++ b/testsuite/tests/ghci/scripts/all.T
@@ -207,4 +207,4 @@ test('T9878b',
       extra_clean(['T9878.hi','T9878.o'])],
     ghci_script, ['T9878b.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