[commit: ghc] wip/impredicativity: Fix flavoring of variables when checking RULES (579e9f2)

git at git.haskell.org git at git.haskell.org
Fri Jul 10 14:24:48 UTC 2015


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

On branch  : wip/impredicativity
Link       : http://ghc.haskell.org/trac/ghc/changeset/579e9f27b3eb474565dc19003651f588231e51eb/ghc

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

commit 579e9f27b3eb474565dc19003651f588231e51eb
Author: Alejandro Serrano <trupill at gmail.com>
Date:   Fri Jul 10 16:25:35 2015 +0200

    Fix flavoring of variables when checking RULES


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

579e9f27b3eb474565dc19003651f588231e51eb
 compiler/typecheck/TcRules.hs | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/compiler/typecheck/TcRules.hs b/compiler/typecheck/TcRules.hs
index 680b5c1..2217cee 100644
--- a/compiler/typecheck/TcRules.hs
+++ b/compiler/typecheck/TcRules.hs
@@ -69,7 +69,7 @@ tcRule (HsRule name act hs_bndrs lhs fv_lhs rhs fv_rhs)
               -- the RULE.  c.f. Trac #10072
 
        ; let (id_bndrs, tv_bndrs) = partition isId vars
-             id_bndrs' = [(id_bndr, TcIdUnrestricted) | id_bndr <- id_bndrs]
+             id_bndrs' = [(id_bndr, choose_tc_id_flavor id_bndr) | id_bndr <- id_bndrs]
        ; (lhs', lhs_wanted, rhs', rhs_wanted, rule_ty)
             <- tcExtendTyVarEnv tv_bndrs  $
                tcExtendIdEnv    id_bndrs' $
@@ -143,6 +143,11 @@ tcRule (HsRule name act hs_bndrs lhs fv_lhs rhs fv_rhs)
                     (mkHsDictLet (TcEvBinds lhs_binds_var) lhs') fv_lhs
                     (mkHsDictLet (TcEvBinds rhs_binds_var) rhs') fv_rhs) }
 
+choose_tc_id_flavor :: Id -> TcIdFlavor
+choose_tc_id_flavor v
+  | Just _ <- tcGetTyVar_maybe (idType v) = TcIdMonomorphic
+  | otherwise = TcIdUnrestricted
+
 tcRuleBndrs :: [LRuleBndr Name] -> TcM [Var]
 tcRuleBndrs []
   = return []



More information about the ghc-commits mailing list