[commit: ghc] wip/impredicativity: Add lazy instantiation for type classes (d58e17d)
git at git.haskell.org
git at git.haskell.org
Wed Jul 1 11:45:41 UTC 2015
Repository : ssh://git@git.haskell.org/ghc
On branch : wip/impredicativity
Link : http://ghc.haskell.org/trac/ghc/changeset/d58e17d2fbae2d424ae5af918fc43c1dafd4cce6/ghc
>---------------------------------------------------------------
commit d58e17d2fbae2d424ae5af918fc43c1dafd4cce6
Author: Alejandro Serrano <trupill at gmail.com>
Date: Wed Jul 1 13:40:43 2015 +0200
Add lazy instantiation for type classes
This commit implements the instantiation of type variables when
they appear in both in an InstanceOf constraint and as an argument
of a type class constraint that must be inspected to know whether
an instance applies.
For example, given Eq alpha and InstanceOf (forall b. [b]) alpha, the
solver will now instantiate alpha to [beta], for a new beta variabe.
The core of the changes are found in two places:
- compiler/types/Unify.hs, where the matching procedure is enhanced to
take some extra "lazy equations". These are equations of the form
type variable ~ type which are available to be used if we do not
know yet whether a match is successful over that type variable.
At the end, the matching process returns which of the lazy equations
were used, from which we can extract information to add the extra
instantiations to the set of constraints.
- compiler/typecheck/TcInteract.hs generates lazy equations from the
InstanceOf constraints in the inert set, and passes them to the
matching procedure.
The rest of files had to be changed mostly to accomodate the new
interface of the matching functions.
>---------------------------------------------------------------
d58e17d2fbae2d424ae5af918fc43c1dafd4cce6
compiler/specialise/Rules.hs | 11 ++-
compiler/typecheck/FamInst.hs | 8 +-
compiler/typecheck/Inst.hs | 4 +-
compiler/typecheck/TcBinds.hs | 13 ++-
compiler/typecheck/TcErrors.hs | 10 +--
compiler/typecheck/TcInteract.hs | 89 ++++++++++++++-------
compiler/typecheck/TcSMonad.hs | 44 ++++++----
compiler/typecheck/TcSimplify.hs | 8 +-
compiler/typecheck/TcTyClsDecls.hs | 13 +--
compiler/typecheck/TcValidity.hs | 6 +-
compiler/types/Coercion.hs | 10 ++-
compiler/types/FamInstEnv.hs | 105 +++++++++++++-----------
compiler/types/InstEnv.hs | 58 ++++++++------
compiler/types/Unify.hs | 111 ++++++++++++++++++--------
compiler/vectorise/Vectorise/Monad/InstEnv.hs | 4 +-
compiler/vectorise/Vectorise/Utils/Base.hs | 2 +-
16 files changed, 308 insertions(+), 188 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 d58e17d2fbae2d424ae5af918fc43c1dafd4cce6
More information about the ghc-commits
mailing list