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

git at git.haskell.org git at git.haskell.org
Thu Jul 14 13:52:50 UTC 2016


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

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

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

commit 8289ba79d95fca70113bc3343122f7b84a934d9d
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.


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

8289ba79d95fca70113bc3343122f7b84a934d9d
 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 8289ba79d95fca70113bc3343122f7b84a934d9d


More information about the ghc-commits mailing list