[GHC] #12442: Pure unifier usually doesn't need to unify kinds
GHC
ghc-devs at haskell.org
Thu Feb 22 15:49:20 UTC 2018
#12442: Pure unifier usually doesn't need to unify kinds
-------------------------------------+-------------------------------------
Reporter: goldfire | Owner: goldfire
Type: bug | Status: closed
Priority: normal | Milestone:
Component: Compiler | Version: 8.0.1
Resolution: fixed | Keywords: TypeInType
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
| dependent/should_compile/T12442
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D2433
Wiki Page: |
-------------------------------------+-------------------------------------
Changes (by goldfire):
* status: new => closed
* resolution: => fixed
Comment:
Here's the Note:
{{{
Note [tcMatchTy vs tcMatchTyKi]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This module offers two variants of matching: with kinds and without.
The TyKi variant takes two types, of potentially different kinds,
and matches them. Along the way, it necessarily also matches their
kinds. The Ty variant instead assumes that the kinds are already
eqType and so skips matching up the kinds.
How do you choose between them?
1. If you know that the kinds of the two types are eqType, use
the Ty variant. It is more efficient, as it does less work.
2. If the kinds of variables in the template type might mention type
families,
use the Ty variant (and do other work to make sure the kinds
work out). These pure unification functions do a straightforward
syntactic unification and do no complex reasoning about type
families. Note that the types of the variables in instances can indeed
mention type families, so instance lookup must use the Ty variant.
(Nothing goes terribly wrong -- no panics -- if there might be type
families in kinds in the TyKi variant. You just might get match
failure even though a reducing a type family would lead to success.)
3. Otherwise, if you're sure that the variable kinds to not mention
type families and you're not already sure that the kind of the template
equals the kind of the target, then use the TyKi version.
}}}
This is referenced from the various matcher functions. Sorry for letting
this slip!
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12442#comment:9>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list