diff options
author | Austin Seipp <austin@well-typed.com> | 2015-05-06 10:20:26 -0500 |
---|---|---|
committer | Austin Seipp <austin@well-typed.com> | 2015-05-06 10:20:26 -0500 |
commit | 97d320f56b5848d6ba2c723c6e7f04f98e349a86 (patch) | |
tree | 0470a73a6b5934ddbd24593262f55b5bc36c34a5 /compiler/hsSyn/HsUtils.hs | |
parent | f34c072820f617f09c3d1c4e539c41fb2ab645b1 (diff) | |
download | haskell-97d320f56b5848d6ba2c723c6e7f04f98e349a86.tar.gz |
Revert "API Annotations : add Locations in hsSyn were layout occurs"
This reverts commit fb54b2c11cc7f2cfbafa35b6a1819d7443aa5494.
As Alan pointed out, this will make cherry picking a lot harder until
7.10.2, so lets back it out until after the release.
Diffstat (limited to 'compiler/hsSyn/HsUtils.hs')
-rw-r--r-- | compiler/hsSyn/HsUtils.hs | 47 |
1 files changed, 19 insertions, 28 deletions
diff --git a/compiler/hsSyn/HsUtils.hs b/compiler/hsSyn/HsUtils.hs index df18317f8b..b1c8036bc1 100644 --- a/compiler/hsSyn/HsUtils.hs +++ b/compiler/hsSyn/HsUtils.hs @@ -129,27 +129,20 @@ mkSimpleMatch pats rhs (pat:_) -> combineSrcSpans (getLoc pat) (getLoc rhs) unguardedGRHSs :: Located (body id) -> GRHSs id (Located (body id)) -unguardedGRHSs rhs@(L loc _) - = GRHSs (unguardedRHS loc rhs) (noLoc emptyLocalBinds) +unguardedGRHSs rhs@(L loc _) = GRHSs (unguardedRHS loc rhs) emptyLocalBinds unguardedRHS :: SrcSpan -> Located (body id) -> [LGRHS id (Located (body id))] unguardedRHS loc rhs = [L loc (GRHS [] rhs)] mkMatchGroup :: Origin -> [LMatch RdrName (Located (body RdrName))] -> MatchGroup RdrName (Located (body RdrName)) -mkMatchGroup origin matches = MG { mg_alts = mkLocatedList matches - , mg_arg_tys = [] +mkMatchGroup origin matches = MG { mg_alts = matches, mg_arg_tys = [] , mg_res_ty = placeHolderType , mg_origin = origin } -mkLocatedList :: [Located a] -> Located [Located a] -mkLocatedList [] = noLoc [] -mkLocatedList ms = L (combineLocs (head ms) (last ms)) ms - mkMatchGroupName :: Origin -> [LMatch Name (Located (body Name))] -> MatchGroup Name (Located (body Name)) -mkMatchGroupName origin matches = MG { mg_alts = mkLocatedList matches - , mg_arg_tys = [] +mkMatchGroupName origin matches = MG { mg_alts = matches, mg_arg_tys = [] , mg_res_ty = placeHolderType , mg_origin = origin } @@ -230,7 +223,7 @@ mkHsIsString src s = OverLit (HsIsString src s) noRebindableInfo noSyntaxExpr noRebindableInfo :: PlaceHolder noRebindableInfo = PlaceHolder -- Just another placeholder; -mkHsDo ctxt stmts = HsDo ctxt (mkLocatedList stmts) placeHolderType +mkHsDo ctxt stmts = HsDo ctxt stmts placeHolderType mkHsComp ctxt stmts expr = mkHsDo ctxt (stmts ++ [last_stmt]) where last_stmt = L (getLoc expr) $ mkLastStmt expr @@ -567,14 +560,13 @@ mkPatSynBind name details lpat dir = PatSynBind psb mk_easy_FunBind :: SrcSpan -> RdrName -> [LPat RdrName] -> LHsExpr RdrName -> LHsBind RdrName mk_easy_FunBind loc fun pats expr - = L loc $ mkFunBind (L loc fun) [mkMatch pats expr (noLoc emptyLocalBinds)] + = L loc $ mkFunBind (L loc fun) [mkMatch pats expr emptyLocalBinds] ------------ -mkMatch :: [LPat id] -> LHsExpr id -> Located (HsLocalBinds id) - -> LMatch id (LHsExpr id) -mkMatch pats expr lbinds +mkMatch :: [LPat id] -> LHsExpr id -> HsLocalBinds id -> LMatch id (LHsExpr id) +mkMatch pats expr binds = noLoc (Match Nothing (map paren pats) Nothing - (GRHSs (unguardedRHS noSrcSpan expr) lbinds)) + (GRHSs (unguardedRHS noSrcSpan expr) binds)) where paren lp@(L l p) | hsPatNeedsParens p = L l (ParPat lp) | otherwise = lp @@ -669,12 +661,12 @@ collectLStmtBinders = collectStmtBinders . unLoc collectStmtBinders :: StmtLR idL idR body -> [idL] -- Id Binders for a Stmt... [but what about pattern-sig type vars]? -collectStmtBinders (BindStmt pat _ _ _) = collectPatBinders pat -collectStmtBinders (LetStmt (L _ binds)) = collectLocalBinders binds -collectStmtBinders (BodyStmt {}) = [] -collectStmtBinders (LastStmt {}) = [] -collectStmtBinders (ParStmt xs _ _) = collectLStmtsBinders - $ [s | ParStmtBlock ss _ _ <- xs, s <- ss] +collectStmtBinders (BindStmt pat _ _ _) = collectPatBinders pat +collectStmtBinders (LetStmt binds) = collectLocalBinders binds +collectStmtBinders (BodyStmt {}) = [] +collectStmtBinders (LastStmt {}) = [] +collectStmtBinders (ParStmt xs _ _) = collectLStmtsBinders + $ [s | ParStmtBlock ss _ _ <- xs, s <- ss] collectStmtBinders (TransStmt { trS_stmts = stmts }) = collectLStmtsBinders stmts collectStmtBinders (RecStmt { recS_stmts = ss }) = collectLStmtsBinders ss @@ -883,12 +875,11 @@ lStmtsImplicits = hs_lstmts hs_lstmts :: [LStmtLR Name idR (Located (body idR))] -> NameSet hs_lstmts = foldr (\stmt rest -> unionNameSet (hs_stmt (unLoc stmt)) rest) emptyNameSet - hs_stmt (BindStmt pat _ _ _) = lPatImplicits pat - hs_stmt (LetStmt (L _ binds)) = hs_local_binds binds - hs_stmt (BodyStmt {}) = emptyNameSet - hs_stmt (LastStmt {}) = emptyNameSet - hs_stmt (ParStmt xs _ _) - = hs_lstmts [s | ParStmtBlock ss _ _ <- xs, s <- ss] + hs_stmt (BindStmt pat _ _ _) = lPatImplicits pat + hs_stmt (LetStmt binds) = hs_local_binds binds + hs_stmt (BodyStmt {}) = emptyNameSet + hs_stmt (LastStmt {}) = emptyNameSet + hs_stmt (ParStmt xs _ _) = hs_lstmts [s | ParStmtBlock ss _ _ <- xs, s <- ss] hs_stmt (TransStmt { trS_stmts = stmts }) = hs_lstmts stmts hs_stmt (RecStmt { recS_stmts = ss }) = hs_lstmts ss |