diff options
author | Richard Eisenberg <rae@richarde.dev> | 2019-10-15 15:33:27 +0100 |
---|---|---|
committer | Richard Eisenberg <rae@richarde.dev> | 2019-10-16 10:05:16 +0100 |
commit | a18be4c81b8abb59874e4e04c1cec265fa072c86 (patch) | |
tree | b32b7b2229277b2891b362b8145db6f6400fa745 /compiler/parser | |
parent | be8d71d07b39f503ba9a7fc66b6735cb1da605c9 (diff) | |
download | haskell-wip/rae/remove-tc-dep.tar.gz |
Break dependency from HsSyn on the typechecker.wip/rae/remove-tc-dep
There are three reasons that HsSyn has depended
on the type-checker.
1. The AST contains HsWrappers in a variety of places -- notably,
in expressions. HsWrappers are part of type-checker evidence,
and they are declared in TcEvidence.
2. In a few places (notably, AbsBinds), the AST contains a TcEvBinds.
TcEvBinds is also declared in TcEvidence.
3. Expressions can contain *delayed splices*. See Note [Running typed
splices in the zonker] in Hs.Expr. A DelayedSplice structure needs
a reference to a TcLclEnv, declared in TcRnTypes and rather
intimately tied to the type-checker.
The third of these is the most pernicious, because it requires
a dependency on a central module within the type-checker. TcEvidence,
on the other hand, might conceivably be moved out from the type-checker.
This patch removes all three dependencies. The magic is all
in Note [Abstract data] in Hs.Extension. In order to support this
change, this patch also introduces some new constraints in Hs.Extension.
Specifically, we now have IsGhcPass, which allows functions to
do a runtiem (of GHC) check to see what phase we're in, in order
to do custom processing in one phase or another.
Somewhat separately, this patch also moves HsWrap and HsCmdWrap
into an extension field. CoPat should get the same treatment, but
is not included in this patch. And, of course, there are many other
places that constructors should be moved to extension fields (like
ConPatOut). This change is actually orthogonal to the
dependency-dropping, but it seemed convenient to do them all together.
This patch subsumes !1721 (sorry @chreekat).
Diffstat (limited to 'compiler/parser')
-rw-r--r-- | compiler/parser/Parser.y | 4 | ||||
-rw-r--r-- | compiler/parser/RdrHsSyn.hs | 2 |
2 files changed, 2 insertions, 4 deletions
diff --git a/compiler/parser/Parser.y b/compiler/parser/Parser.y index 997f497510..4841145f03 100644 --- a/compiler/parser/Parser.y +++ b/compiler/parser/Parser.y @@ -2422,7 +2422,7 @@ decl_no_th :: { LHsDecl GhcPs } -- a FunBind or PatBind back from checkValDef. See Note -- [FunBind vs PatBind] case r of { - (FunBind _ n _ _ _) -> + (FunBind _ n _ _) -> amsL l [mj AnnFunId n] >> return () ; (PatBind _ (dL->L l _) _rhs _) -> amsL l [] >> return () } ; @@ -2437,7 +2437,7 @@ decl_no_th :: { LHsDecl GhcPs } -- a FunBind or PatBind back from checkValDef. See Note -- [FunBind vs PatBind] case r of { - (FunBind _ n _ _ _) -> + (FunBind _ n _ _) -> amsL l (mj AnnFunId n:(fst $2)) >> return () ; (PatBind _ (dL->L lh _lhs) _rhs _) -> amsL lh (fst $2) >> return () } ; diff --git a/compiler/parser/RdrHsSyn.hs b/compiler/parser/RdrHsSyn.hs index 0686f669d3..d8195bb7e7 100644 --- a/compiler/parser/RdrHsSyn.hs +++ b/compiler/parser/RdrHsSyn.hs @@ -112,7 +112,6 @@ import CoAxiom ( Role, fsFromRole ) import RdrName import Name import BasicTypes -import TcEvidence ( idHsWrapper ) import Lexer import Lexeme ( isLexCon ) import Type ( TyThing(..), funTyCon ) @@ -1218,7 +1217,6 @@ makeFunBind fn ms = FunBind { fun_ext = noExtField, fun_id = fn, fun_matches = mkMatchGroup FromSource ms, - fun_co_fn = idHsWrapper, fun_tick = [] } checkPatBind :: LPat GhcPs |