diff options
author | Richard Eisenberg <eir@cis.upenn.edu> | 2016-02-23 09:51:50 -0500 |
---|---|---|
committer | Richard Eisenberg <eir@cis.upenn.edu> | 2016-03-14 21:44:17 -0400 |
commit | 972730cc42a419b8cd148abaa927e03415da3a68 (patch) | |
tree | bcafe558128635cf05f679caf6270e9918dbe74d /compiler/hsSyn/HsUtils.hs | |
parent | 35d37ff8a0bb9f64f347c8e4b6a24d49fd08c9dc (diff) | |
download | haskell-972730cc42a419b8cd148abaa927e03415da3a68.tar.gz |
Refactor visible type application.
This replaces the old HsType and HsTypeOut constructors
with HsAppType and HsAppTypeOut, leading to some simplification.
(This refactoring addresses #11329.)
This also fixes #11456, which stumbled over HsType (which is
not an expression).
test case: ghci/scripts/T11456
[skip ci]
Diffstat (limited to 'compiler/hsSyn/HsUtils.hs')
-rw-r--r-- | compiler/hsSyn/HsUtils.hs | 26 |
1 files changed, 8 insertions, 18 deletions
diff --git a/compiler/hsSyn/HsUtils.hs b/compiler/hsSyn/HsUtils.hs index cb2da5c0ee..8ac7e24f8d 100644 --- a/compiler/hsSyn/HsUtils.hs +++ b/compiler/hsSyn/HsUtils.hs @@ -20,13 +20,13 @@ which deal with the instantiated versions are located elsewhere: module HsUtils( -- Terms - mkHsPar, mkHsApp, mkHsConApp, mkSimpleHsAlt, + mkHsPar, mkHsApp, mkHsAppType, mkHsAppTypeOut, mkHsConApp, mkSimpleHsAlt, mkSimpleMatch, unguardedGRHSs, unguardedRHS, mkMatchGroup, mkMatchGroupName, mkMatch, mkHsLam, mkHsIf, mkHsWrap, mkLHsWrap, mkHsWrapCo, mkHsWrapCoR, mkLHsWrapCo, mkHsDictLet, mkHsLams, mkHsOpApp, mkHsDo, mkHsComp, mkHsWrapPat, mkHsWrapPatCo, - mkLHsPar, mkHsCmdWrap, mkLHsCmdWrap, isLHsTypeExpr_maybe, isLHsTypeExpr, + mkLHsPar, mkHsCmdWrap, mkLHsCmdWrap, nlHsTyApp, nlHsTyApps, nlHsVar, nlHsLit, nlHsApp, nlHsApps, nlHsSyntaxApps, nlHsIntLit, nlHsVarApps, @@ -169,6 +169,12 @@ mkMatchGroupName origin matches = MG { mg_alts = mkLocatedList matches mkHsApp :: LHsExpr name -> LHsExpr name -> LHsExpr name mkHsApp e1 e2 = addCLoc e1 e2 (HsApp e1 e2) +mkHsAppType :: LHsExpr name -> LHsWcType name -> LHsExpr name +mkHsAppType e t = addCLoc e (hswc_body t) (HsAppType e t) + +mkHsAppTypeOut :: LHsExpr Id -> LHsWcType Name -> LHsExpr Id +mkHsAppTypeOut e t = addCLoc e (hswc_body t) (HsAppTypeOut e t) + mkHsLam :: [LPat RdrName] -> LHsExpr RdrName -> LHsExpr RdrName mkHsLam pats body = mkHsPar (L (getLoc body) (HsLam matches)) where @@ -458,21 +464,6 @@ nlHsFunTy a b = noLoc (HsFunTy a b) nlHsTyConApp :: name -> [LHsType name] -> LHsType name nlHsTyConApp tycon tys = foldl nlHsAppTy (nlHsTyVar tycon) tys --- | Extract a type argument from an HsExpr, with the list of wildcards in --- the type -isLHsTypeExpr_maybe :: LHsExpr name -> Maybe (LHsWcType name) -isLHsTypeExpr_maybe (L _ (HsPar e)) = isLHsTypeExpr_maybe e -isLHsTypeExpr_maybe (L _ (HsType ty)) = Just ty - -- the HsTypeOut case is ill-typed. We never need it here anyway. -isLHsTypeExpr_maybe _ = Nothing - --- | Is an expression a visible type application? -isLHsTypeExpr :: LHsExpr name -> Bool -isLHsTypeExpr (L _ (HsPar e)) = isLHsTypeExpr e -isLHsTypeExpr (L _ (HsType _)) = True -isLHsTypeExpr (L _ (HsTypeOut _)) = True -isLHsTypeExpr _ = False - {- Tuples. All these functions are *pre-typechecker* because they lack types on the tuple. @@ -1132,4 +1123,3 @@ lPatImplicits = hs_lpat (unLoc fld) pat_explicit = maybe True (i<) (rec_dotdot fs)] details (InfixCon p1 p2) = hs_lpat p1 `unionNameSet` hs_lpat p2 - |