[commit: ghc] master: Refactor free tyvars on LHS of rules (6ad2b42)

git at git.haskell.org git at git.haskell.org
Fri Apr 22 10:30:17 UTC 2016


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

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/6ad2b42f866fa718855cc5c850e3549bc1428b3c/ghc

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

commit 6ad2b42f866fa718855cc5c850e3549bc1428b3c
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date:   Fri Apr 22 10:47:14 2016 +0100

    Refactor free tyvars on LHS of rules
    
    A RULE can have unbound meta-tyvars on the LHS.  Consider
      data T a = C
    
      foo :: T a -> Int
      foo C = 1
    
      {-# RULES "myrule"  foo C = 1 #-}
    
    After type checking the LHS becomes (foo alpha (C alpah)) and we do
    not want to zap the unbound meta-tyvar 'alpha' to Any, because that
    limits the applicability of the rule.  Instead, we want to quantify
    over it!
    
    Previously there was a rather clunky implementation of this
    quantification, buried in the zonker in TcHsSyn (zonkTvCollecting).
    
    This patch refactors it so that the zonker just turns the meta-tyvar
    into a skolem, and the desugarer adds the quantification.  See DsBinds
    Note [Free tyvars on rule LHS]. As it happened, the desugarer was
    already doing something similar for dictionaries. See DsBinds
    Note [Free dictionaries on rule LHS]
    
    No change in functionality, but less cruft.


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

6ad2b42f866fa718855cc5c850e3549bc1428b3c
 compiler/deSugar/DsBinds.hs   |  99 +++++++++++++++++++------------
 compiler/typecheck/TcHsSyn.hs | 132 ++++++++++++++++++------------------------
 2 files changed, 119 insertions(+), 112 deletions(-)

Diff suppressed because of size. To see it, use:

    git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 6ad2b42f866fa718855cc5c850e3549bc1428b3c


More information about the ghc-commits mailing list