Refactor coercion rule
authorningning <xnningxie@gmail.com>
Tue, 10 Jul 2018 00:02:03 +0000 (20:02 -0400)
committerRichard Eisenberg <rae@cs.brynmawr.edu>
Tue, 10 Jul 2018 01:35:31 +0000 (21:35 -0400)
commit55a3f8552c9dc9b84e204ec6623c698912795347
tree3433832e7bc586c46cccd6204ce92748bc9b4a01
parent6595bee749ddb49d9058ed47ab7c1b6e7558ae17
Refactor coercion rule

Summary:
The patch is an attempt on #15192.

It defines a new coercion rule

```
 | GRefl Role Type MCoercion
```

which correspondes to the typing rule

```
     t1 : k1
  ------------------------------------
  GRefl r t1 MRefl: t1 ~r t1

     t1 : k1       co :: k1 ~ k2
  ------------------------------------
  GRefl r t1 (MCo co) : t1 ~r t1 |> co
```

MCoercion wraps a coercion, which might be reflexive (MRefl)
or not (MCo co). To know more about MCoercion see #14975.

We keep Refl ty as a special case for nominal reflexive coercions,
naemly, Refl ty :: ty ~n ty.

This commit is meant to be a general performance improvement,
but there are a few regressions. See #15192, comment:13 for
more information.

Test Plan: ./validate

Reviewers: bgamari, goldfire, simonpj

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #15192

Differential Revision: https://phabricator.haskell.org/D4747
24 files changed:
compiler/backpack/RnModIface.hs
compiler/coreSyn/CoreFVs.hs
compiler/coreSyn/CoreLint.hs
compiler/coreSyn/CoreOpt.hs
compiler/iface/IfaceSyn.hs
compiler/iface/IfaceType.hs
compiler/iface/TcIface.hs
compiler/iface/ToIface.hs
compiler/typecheck/TcCanonical.hs
compiler/typecheck/TcEvidence.hs
compiler/typecheck/TcFlatten.hs
compiler/typecheck/TcTyDecls.hs
compiler/typecheck/TcType.hs
compiler/typecheck/TcUnify.hs
compiler/typecheck/TcValidity.hs
compiler/types/Coercion.hs
compiler/types/Coercion.hs-boot
compiler/types/FamInstEnv.hs
compiler/types/OptCoercion.hs
compiler/types/TyCoRep.hs
compiler/types/TyCoRep.hs-boot
compiler/types/Type.hs
compiler/types/Unify.hs
testsuite/tests/perf/compiler/all.T