[commit: ghc] wip/ghc-8.0-det: Refactor free tyvars on LHS of rules (be341c8)

git at git.haskell.org git at git.haskell.org
Mon Jul 18 17:58:14 UTC 2016


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

On branch  : wip/ghc-8.0-det
Link       : http://ghc.haskell.org/trac/ghc/changeset/be341c87b6e61e4f08e05a695a4df9db565c273e/ghc

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

commit be341c87b6e61e4f08e05a695a4df9db565c273e
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.


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

be341c87b6e61e4f08e05a695a4df9db565c273e
 compiler/deSugar/DsBinds.hs   |  99 +++++++++++++++++++------------
 compiler/typecheck/TcHsSyn.hs | 134 ++++++++++++++++++------------------------
 2 files changed, 121 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 be341c87b6e61e4f08e05a695a4df9db565c273e


More information about the ghc-commits mailing list