diff options
author | Alan Zimmerman <alan.zimm@gmail.com> | 2021-10-11 23:05:08 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-10-14 14:34:07 -0400 |
commit | 8b7f5424c67b5ec005e061db87d30e124cf7234d (patch) | |
tree | 49b7c66079e415d6151d7edd2c180169a26e991a | |
parent | f450e9481eafa3a00c648c81154a9a8be2da7650 (diff) | |
download | haskell-8b7f5424c67b5ec005e061db87d30e124cf7234d.tar.gz |
EPA: Preserve semicolon order in annotations
Ensure the AddSemiAnn items appear in increasing order, so that if
they are converted to delta format they are still in the correct
order.
Prior to this the exact printer sorted by Span, which is meaningless
for EpaDelta locations.
-rw-r--r-- | compiler/GHC/Parser.y | 40 | ||||
-rw-r--r-- | compiler/GHC/Parser/Annotation.hs | 36 | ||||
-rw-r--r-- | compiler/GHC/Parser/Lexer.x | 7 | ||||
-rw-r--r-- | compiler/GHC/Parser/PostProcess.hs | 98 | ||||
-rw-r--r-- | testsuite/tests/parser/should_compile/DumpSemis.hs | 45 | ||||
-rw-r--r-- | testsuite/tests/parser/should_compile/DumpSemis.stderr | 2072 | ||||
-rw-r--r-- | testsuite/tests/parser/should_compile/T20452.stderr | 8 | ||||
-rw-r--r-- | testsuite/tests/parser/should_compile/all.T | 2 | ||||
-rw-r--r-- | utils/check-exact/Main.hs | 3 |
9 files changed, 2236 insertions, 75 deletions
diff --git a/compiler/GHC/Parser.y b/compiler/GHC/Parser.y index 0cc1bc732a..b0b6a89e52 100644 --- a/compiler/GHC/Parser.y +++ b/compiler/GHC/Parser.y @@ -936,7 +936,7 @@ body2 :: { (AnnList top :: { ([TrailingAnn] ,([LImportDecl GhcPs], [LHsDecl GhcPs])) } - : semis top1 { ($1, $2) } + : semis top1 { (reverse $1, $2) } top1 :: { ([LImportDecl GhcPs], [LHsDecl GhcPs]) } : importdecls_semi topdecls_cs_semi { (reverse $1, cvTopDecls $2) } @@ -1085,7 +1085,7 @@ importdecls importdecls_semi :: { [LImportDecl GhcPs] } importdecls_semi : importdecls_semi importdecl semis1 - {% do { i <- amsAl $2 (comb2 (reLoc $2) $3) (unLoc $3) + {% do { i <- amsAl $2 (comb2 (reLoc $2) $3) (reverse $ unLoc $3) ; return (i : $1)} } | {- empty -} { [] } @@ -1187,7 +1187,7 @@ topdecls :: { OrdList (LHsDecl GhcPs) } -- May have trailing semicolons, can be empty topdecls_semi :: { OrdList (LHsDecl GhcPs) } - : topdecls_semi topdecl semis1 {% do { t <- amsAl $2 (comb2 (reLoc $2) $3) (unLoc $3) + : topdecls_semi topdecl semis1 {% do { t <- amsAl $2 (comb2 (reLoc $2) $3) (reverse $ unLoc $3) ; return ($1 `snocOL` t) }} | {- empty -} { nilOL } @@ -1200,7 +1200,7 @@ topdecls_cs :: { OrdList (LHsDecl GhcPs) } -- May have trailing semicolons, can be empty topdecls_cs_semi :: { OrdList (LHsDecl GhcPs) } - : topdecls_cs_semi topdecl_cs semis1 {% do { t <- amsAl $2 (comb2 (reLoc $2) $3) (unLoc $3) + : topdecls_cs_semi topdecl_cs semis1 {% do { t <- amsAl $2 (comb2 (reLoc $2) $3) (reverse $ unLoc $3) ; return ($1 `snocOL` t) }} | {- empty -} { nilOL } @@ -1680,7 +1680,7 @@ decl_cls : at_decl_cls { $1 } decls_cls :: { Located ([AddEpAnn],OrdList (LHsDecl GhcPs)) } -- Reversed : decls_cls ';' decl_cls {% if isNilOL (snd $ unLoc $1) - then return (sLLlA $1 $> ((mz AnnSemi $2) ++ (fst $ unLoc $1) + then return (sLLlA $1 $> ((fst $ unLoc $1) ++ (mz AnnSemi $2) , unitOL $3)) else case (snd $ unLoc $1) of SnocOL hs t -> do @@ -1688,7 +1688,7 @@ decls_cls :: { Located ([AddEpAnn],OrdList (LHsDecl GhcPs)) } -- Reversed return (sLLlA $1 $> (fst $ unLoc $1 , snocOL hs t' `appOL` unitOL $3)) } | decls_cls ';' {% if isNilOL (snd $ unLoc $1) - then return (sLL $1 $> ((mz AnnSemi $2) ++ (fst $ unLoc $1) + then return (sLL $1 $> ( (fst $ unLoc $1) ++ (mz AnnSemi $2) ,snd $ unLoc $1)) else case (snd $ unLoc $1) of SnocOL hs t -> do @@ -1726,7 +1726,7 @@ decl_inst : at_decl_inst { sL1A $1 (unitOL (sL1 $1 (InstD noExtFi decls_inst :: { Located ([AddEpAnn],OrdList (LHsDecl GhcPs)) } -- Reversed : decls_inst ';' decl_inst {% if isNilOL (snd $ unLoc $1) - then return (sLL $1 $> ((mz AnnSemi $2) ++ (fst $ unLoc $1) + then return (sLL $1 $> ((fst $ unLoc $1) ++ (mz AnnSemi $2) , unLoc $3)) else case (snd $ unLoc $1) of SnocOL hs t -> do @@ -1734,7 +1734,7 @@ decls_inst :: { Located ([AddEpAnn],OrdList (LHsDecl GhcPs)) } -- Reversed return (sLL $1 $> (fst $ unLoc $1 , snocOL hs t' `appOL` unLoc $3)) } | decls_inst ';' {% if isNilOL (snd $ unLoc $1) - then return (sLL $1 $> ((mz AnnSemi $2) ++ (fst $ unLoc $1) + then return (sLL $1 $> ((fst $ unLoc $1) ++ (mz AnnSemi $2) ,snd $ unLoc $1)) else case (snd $ unLoc $1) of SnocOL hs t -> do @@ -1764,7 +1764,7 @@ where_inst :: { Located ([AddEpAnn] -- decls :: { Located ([TrailingAnn], OrdList (LHsDecl GhcPs)) } : decls ';' decl {% if isNilOL (snd $ unLoc $1) - then return (sLLlA $1 $> ((msemi $2) ++ (fst $ unLoc $1) + then return (sLLlA $1 $> ((fst $ unLoc $1) ++ (msemi $2) , unitOL $3)) else case (snd $ unLoc $1) of SnocOL hs t -> do @@ -1775,7 +1775,7 @@ decls :: { Located ([TrailingAnn], OrdList (LHsDecl GhcPs)) } return (rest `seq` this `seq` these `seq` (sLLlA $1 $> (fst $ unLoc $1, these))) } | decls ';' {% if isNilOL (snd $ unLoc $1) - then return (sLL $1 $> (((msemi $2) ++ (fst $ unLoc $1) + then return (sLL $1 $> (((fst $ unLoc $1) ++ (msemi $2) ,snd $ unLoc $1))) else case (snd $ unLoc $1) of SnocOL hs t -> do @@ -3217,21 +3217,21 @@ alts :: { forall b. DisambECP b => PV (Located ([AddEpAnn],[LMatch GhcPs (Loc : alts1 { $1 >>= \ $1 -> return $ sL1 $1 (fst $ unLoc $1,snd $ unLoc $1) } | ';' alts { $2 >>= \ $2 -> return $ - sLL $1 $> (((mz AnnSemi $1) ++ (fst $ unLoc $2)) + sLL $1 $> (((mz AnnSemi $1) ++ (fst $ unLoc $2) ) ,snd $ unLoc $2) } alts1 :: { forall b. DisambECP b => PV (Located ([AddEpAnn],[LMatch GhcPs (LocatedA b)])) } : alts1 ';' alt { $1 >>= \ $1 -> $3 >>= \ $3 -> case snd $ unLoc $1 of - [] -> return (sLL $1 (reLoc $>) ((mz AnnSemi $2) ++(fst $ unLoc $1) + [] -> return (sLL $1 (reLoc $>) ((fst $ unLoc $1) ++ (mz AnnSemi $2) ,[$3])) (h:t) -> do h' <- addTrailingSemiA h (gl $2) return (sLL $1 (reLoc $>) (fst $ unLoc $1,$3 : h' : t)) } | alts1 ';' { $1 >>= \ $1 -> case snd $ unLoc $1 of - [] -> return (sLL $1 $> ((mz AnnSemi $2) ++(fst $ unLoc $1) + [] -> return (sLL $1 $> ((fst $ unLoc $1) ++ (mz AnnSemi $2) ,[])) (h:t) -> do h' <- addTrailingSemiA h (gl $2) @@ -3301,9 +3301,9 @@ apats :: { [LPat GhcPs] } stmtlist :: { forall b. DisambECP b => PV (LocatedL [LocatedA (Stmt GhcPs (LocatedA b))]) } : '{' stmts '}' { $2 >>= \ $2 -> amsrl - (sLL $1 $> (reverse $ snd $ unLoc $2)) (AnnList (Just $ glR $2) (Just $ moc $1) (Just $ mcc $3) (fst $ unLoc $2) []) } -- AZ:performance of reverse? + (sLL $1 $> (reverse $ snd $ unLoc $2)) (AnnList (Just $ glR $2) (Just $ moc $1) (Just $ mcc $3) (fromOL $ fst $ unLoc $2) []) } | vocurly stmts close { $2 >>= \ $2 -> amsrl - (L (gl $2) (reverse $ snd $ unLoc $2)) (AnnList (Just $ glR $2) Nothing Nothing (fst $ unLoc $2) []) } + (L (gl $2) (reverse $ snd $ unLoc $2)) (AnnList (Just $ glR $2) Nothing Nothing (fromOL $ fst $ unLoc $2) []) } -- do { ;; s ; s ; ; s ;; } -- The last Stmt should be an expression, but that's hard to enforce @@ -3311,11 +3311,11 @@ stmtlist :: { forall b. DisambECP b => PV (LocatedL [LocatedA (Stmt GhcPs (Locat -- So we use BodyStmts throughout, and switch the last one over -- in ParseUtils.checkDo instead -stmts :: { forall b. DisambECP b => PV (Located ([AddEpAnn],[LStmt GhcPs (LocatedA b)])) } +stmts :: { forall b. DisambECP b => PV (Located (OrdList AddEpAnn,[LStmt GhcPs (LocatedA b)])) } : stmts ';' stmt { $1 >>= \ $1 -> $3 >>= \ ($3 :: LStmt GhcPs (LocatedA b)) -> case (snd $ unLoc $1) of - [] -> return (sLL $1 (reLoc $>) ((mj AnnSemi $2) : (fst $ unLoc $1) + [] -> return (sLL $1 (reLoc $>) ((fst $ unLoc $1) `snocOL` (mj AnnSemi $2) ,$3 : (snd $ unLoc $1))) (h:t) -> do { h' <- addTrailingSemiA h (gl $2) @@ -3323,13 +3323,13 @@ stmts :: { forall b. DisambECP b => PV (Located ([AddEpAnn],[LStmt GhcPs (Locate | stmts ';' { $1 >>= \ $1 -> case (snd $ unLoc $1) of - [] -> return (sLL $1 $> ((mj AnnSemi $2) : (fst $ unLoc $1),snd $ unLoc $1)) + [] -> return (sLL $1 $> ((fst $ unLoc $1) `snocOL` (mj AnnSemi $2),snd $ unLoc $1)) (h:t) -> do { h' <- addTrailingSemiA h (gl $2) ; return $ sL1 $1 (fst $ unLoc $1,h':t) }} | stmt { $1 >>= \ $1 -> - return $ sL1A $1 ([],[$1]) } - | {- empty -} { return $ noLoc ([],[]) } + return $ sL1A $1 (nilOL,[$1]) } + | {- empty -} { return $ noLoc (nilOL,[]) } -- For typing stmts at the GHCi prompt, where diff --git a/compiler/GHC/Parser/Annotation.hs b/compiler/GHC/Parser/Annotation.hs index 1692d394b5..9555291530 100644 --- a/compiler/GHC/Parser/Annotation.hs +++ b/compiler/GHC/Parser/Annotation.hs @@ -100,7 +100,7 @@ import qualified GHC.Data.Strict as Strict {- Note [exact print annotations] -~~~~~~~~~~~~~~~~~~~~~~ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given a parse tree of a Haskell module, how can we reconstruct the original Haskell source code, retaining all whitespace and source code comments? We need to track the locations of all @@ -394,7 +394,7 @@ instance Outputable EpaComment where -- The usual way an 'AddEpAnn' is created is using the 'mj' ("make -- jump") function, and then it can be inserted into the appropriate -- annotation. -data AddEpAnn = AddEpAnn AnnKeywordId EpaLocation deriving (Data,Eq,Ord) +data AddEpAnn = AddEpAnn AnnKeywordId EpaLocation deriving (Data,Eq) -- | The anchor for an @'AnnKeywordId'@. The Parser inserts the -- @'EpaSpan'@ variant, giving the exact location of the original item @@ -460,6 +460,9 @@ instance Outputable EpaLocation where instance Outputable AddEpAnn where ppr (AddEpAnn kw ss) = text "AddEpAnn" <+> ppr kw <+> ppr ss +instance Ord AddEpAnn where + compare (AddEpAnn kw1 loc1) (AddEpAnn kw2 loc2) = compare (loc1, kw1) (loc2,kw2) + -- --------------------------------------------------------------------- -- | The exact print annotations (EPAs) are kept in the HsSyn AST for @@ -802,7 +805,8 @@ addTrailingAnnToL s t cs EpAnnNotUsed addTrailingAnnToL _ t cs n = n { anns = addTrailing (anns n) , comments = comments n <> cs } where - addTrailing n = n { al_trailing = t : al_trailing n } + -- See Note [list append in addTrailing*] + addTrailing n = n { al_trailing = al_trailing n ++ [t]} -- | Helper function used in the parser to add a 'TrailingAnn' items -- to an existing annotation. @@ -813,7 +817,8 @@ addTrailingAnnToA s t cs EpAnnNotUsed addTrailingAnnToA _ t cs n = n { anns = addTrailing (anns n) , comments = comments n <> cs } where - addTrailing n = n { lann_trailing = t : lann_trailing n } + -- See Note [list append in addTrailing*] + addTrailing n = n { lann_trailing = lann_trailing n ++ [t] } -- | Helper function used in the parser to add a comma location to an -- existing annotation. @@ -822,8 +827,29 @@ addTrailingCommaToN s EpAnnNotUsed l = EpAnn (spanAsAnchor s) (NameAnnTrailing [AddCommaAnn l]) emptyComments addTrailingCommaToN _ n l = n { anns = addTrailing (anns n) l } where + -- See Note [list append in addTrailing*] addTrailing :: NameAnn -> EpaLocation -> NameAnn - addTrailing n l = n { nann_trailing = AddCommaAnn l : nann_trailing n } + addTrailing n l = n { nann_trailing = nann_trailing n ++ [AddCommaAnn l]} + +{- +Note [list append in addTrailing*] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The addTrailingAnnToL, addTrailingAnnToA and addTrailingCommaToN +functions are used to add a separator for an item when it occurs in a +list. So they are used to capture a comma, vbar, semicolon and similar. + +In general, a given element will have zero or one of these. In +extreme (test) cases, there may be multiple semicolons. + +In exact printing we sometimes convert the EpaLocation variant for an +trailing annotation to the EpaDelta variant, which cannot be sorted. + +Hence it is critical that these annotations are captured in the order +they appear in the original source file. + +And so we use the less efficient list append to preserve the order, +knowing that in most cases the original list is empty. +-} -- --------------------------------------------------------------------- diff --git a/compiler/GHC/Parser/Lexer.x b/compiler/GHC/Parser/Lexer.x index 10568814d7..d74d17be8f 100644 --- a/compiler/GHC/Parser/Lexer.x +++ b/compiler/GHC/Parser/Lexer.x @@ -3490,12 +3490,11 @@ clean_pragma prag = canon_ws (map toLower (unprefix prag)) -} --- |Given a 'SrcSpan' that surrounds a 'HsPar' or 'HsParTy', generate +-- |Given a 'RealSrcSpan' that surrounds a 'HsPar' or 'HsParTy', generate -- 'AddEpAnn' values for the opening and closing bordering on the start -- and end of the span -mkParensEpAnn :: SrcSpan -> [AddEpAnn] -mkParensEpAnn (UnhelpfulSpan _) = [] -mkParensEpAnn (RealSrcSpan ss _) = [AddEpAnn AnnOpenP (EpaSpan lo),AddEpAnn AnnCloseP (EpaSpan lc)] +mkParensEpAnn :: RealSrcSpan -> (AddEpAnn, AddEpAnn) +mkParensEpAnn ss = (AddEpAnn AnnOpenP (EpaSpan lo),AddEpAnn AnnCloseP (EpaSpan lc)) where f = srcSpanFile ss sl = srcSpanStartLine ss diff --git a/compiler/GHC/Parser/PostProcess.hs b/compiler/GHC/Parser/PostProcess.hs index ae19e7b7b3..b5511334ec 100644 --- a/compiler/GHC/Parser/PostProcess.hs +++ b/compiler/GHC/Parser/PostProcess.hs @@ -852,26 +852,36 @@ checkTyVars pp_what equals_or_where tc tparms where check (HsTypeArg _ ki@(L loc _)) = addFatalError $ mkPlainErrorMsgEnvelope (locA loc) $ (PsErrUnexpectedTypeAppInDecl ki pp_what (unLoc tc)) - check (HsValArg ty) = chkParens [] emptyComments ty + check (HsValArg ty) = chkParens [] [] emptyComments ty check (HsArgPar sp) = addFatalError $ mkPlainErrorMsgEnvelope sp $ (PsErrMalformedDecl pp_what (unLoc tc)) -- Keep around an action for adjusting the annotations of extra parens - chkParens :: [AddEpAnn] -> EpAnnComments -> LHsType GhcPs + chkParens :: [AddEpAnn] -> [AddEpAnn] -> EpAnnComments -> LHsType GhcPs -> P (LHsTyVarBndr () GhcPs) - chkParens acc cs (L l (HsParTy an ty)) - = chkParens (mkParensEpAnn (locA l) ++ acc) (cs Semi.<> epAnnComments an) ty - chkParens acc cs ty = chk acc cs ty + chkParens ops cps cs (L l (HsParTy an ty)) + = let + (o,c) = mkParensEpAnn (realSrcSpan $ locA l) + in + chkParens (o:ops) (c:cps) (cs Semi.<> epAnnComments an) ty + chkParens ops cps cs ty = chk ops cps cs ty -- Check that the name space is correct! - chk :: [AddEpAnn] -> EpAnnComments -> LHsType GhcPs -> P (LHsTyVarBndr () GhcPs) - chk an cs (L l (HsKindSig annk (L annt (HsTyVar ann _ (L lv tv))) k)) + chk :: [AddEpAnn] -> [AddEpAnn] -> EpAnnComments -> LHsType GhcPs -> P (LHsTyVarBndr () GhcPs) + chk ops cps cs (L l (HsKindSig annk (L annt (HsTyVar ann _ (L lv tv))) k)) | isRdrTyVar tv - = return (L (widenLocatedAn (l Semi.<> annt) an) - (KindedTyVar (addAnns (annk Semi.<> ann) an cs) () (L lv tv) k)) - chk an cs (L l (HsTyVar ann _ (L ltv tv))) - | isRdrTyVar tv = return (L (widenLocatedAn l an) + = let + an = (reverse ops) ++ cps + in + return (L (widenLocatedAn (l Semi.<> annt) an) + (KindedTyVar (addAnns (annk Semi.<> ann) an cs) () (L lv tv) k)) + chk ops cps cs (L l (HsTyVar ann _ (L ltv tv))) + | isRdrTyVar tv + = let + an = (reverse ops) ++ cps + in + return (L (widenLocatedAn l an) (UserTyVar (addAnns ann an cs) () (L ltv tv))) - chk _ _ t@(L loc _) + chk _ _ _ t@(L loc _) = addFatalError $ mkPlainErrorMsgEnvelope (locA loc) $ (PsErrUnexpectedTypeInDecl t pp_what (unLoc tc) tparms equals_or_where) @@ -951,34 +961,36 @@ checkTyClHdr :: Bool -- True <=> class header -- Int :*: Bool into (:*:, [Int, Bool]) -- returning the pieces checkTyClHdr is_cls ty - = goL ty [] [] Prefix + = goL ty [] [] [] Prefix where - goL (L l ty) acc ann fix = go (locA l) ty acc ann fix + goL (L l ty) acc ops cps fix = go (locA l) ty acc ops cps fix -- workaround to define '*' despite StarIsType - go _ (HsParTy an (L l (HsStarTy _ isUni))) acc ann' fix + go _ (HsParTy an (L l (HsStarTy _ isUni))) acc ops' cps' fix = do { addPsMessage (locA l) PsWarnStarBinder ; let name = mkOccName tcClsName (starSym isUni) ; let a' = newAnns l an ; return (L a' (Unqual name), acc, fix - , ann') } - - go _ (HsTyVar _ _ ltc@(L _ tc)) acc ann fix - | isRdrTc tc = return (ltc, acc, fix, ann) - go _ (HsOpTy _ t1 ltc@(L _ tc) t2) acc ann _fix - | isRdrTc tc = return (ltc, HsValArg t1:HsValArg t2:acc, Infix, ann) - go l (HsParTy _ ty) acc ann fix = goL ty acc (ann ++mkParensEpAnn l) fix - go _ (HsAppTy _ t1 t2) acc ann fix = goL t1 (HsValArg t2:acc) ann fix - go _ (HsAppKindTy l ty ki) acc ann fix = goL ty (HsTypeArg l ki:acc) ann fix - go l (HsTupleTy _ HsBoxedOrConstraintTuple ts) [] ann fix + , (reverse ops') ++ cps') } + + go _ (HsTyVar _ _ ltc@(L _ tc)) acc ops cps fix + | isRdrTc tc = return (ltc, acc, fix, (reverse ops) ++ cps) + go _ (HsOpTy _ t1 ltc@(L _ tc) t2) acc ops cps _fix + | isRdrTc tc = return (ltc, HsValArg t1:HsValArg t2:acc, Infix, (reverse ops) ++ cps) + go l (HsParTy _ ty) acc ops cps fix = goL ty acc (o:ops) (c:cps) fix + where + (o,c) = mkParensEpAnn (realSrcSpan l) + go _ (HsAppTy _ t1 t2) acc ops cps fix = goL t1 (HsValArg t2:acc) ops cps fix + go _ (HsAppKindTy l ty ki) acc ops cps fix = goL ty (HsTypeArg l ki:acc) ops cps fix + go l (HsTupleTy _ HsBoxedOrConstraintTuple ts) [] ops cps fix = return (L (noAnnSrcSpan l) (nameRdrName tup_name) - , map HsValArg ts, fix, ann) + , map HsValArg ts, fix, (reverse ops)++cps) where arity = length ts tup_name | is_cls = cTupleTyConName arity | otherwise = getName (tupleTyCon Boxed arity) -- See Note [Unit tuples] in GHC.Hs.Type (TODO: is this still relevant?) - go l _ _ _ _ + go l _ _ _ _ _ = addFatalError $ mkPlainErrorMsgEnvelope l $ (PsErrMalformedTyOrClDecl ty) @@ -1054,7 +1066,8 @@ checkContext orig_t@(L (SrcSpanAnn _ l) _orig_t) = EpAnnNotUsed -> ([],[],emptyComments) EpAnn _ (AnnParen _ o c) cs -> ([o],[c],cs) return (L (SrcSpanAnn (EpAnn (spanAsAnchor l) - (AnnContext Nothing (op Semi.<> oparens) (cp Semi.<> cparens)) (cs Semi.<> cs')) l) ts) + -- Append parens so that the original order in the source is maintained + (AnnContext Nothing (oparens ++ op) (cp ++ cparens)) (cs Semi.<> cs')) l) ts) check (opi,cpi,csi) (L _lp1 (HsParTy ann' ty)) -- to be sure HsParTy doesn't get into the way @@ -1311,26 +1324,29 @@ isFunLhs :: LocatedA (PatBuilder GhcPs) [LocatedA (PatBuilder GhcPs)],[AddEpAnn])) -- A variable binding is parsed as a FunBind. -- Just (fun, is_infix, arg_pats) if e is a function LHS -isFunLhs e = go e [] [] +isFunLhs e = go e [] [] [] where - go (L _ (PatBuilderVar (L loc f))) es ann - | not (isRdrDataCon f) = return (Just (L loc f, Prefix, es, ann)) - go (L _ (PatBuilderApp f e)) es ann = go f (e:es) ann - go (L l (PatBuilderPar _ e _)) es@(_:_) ann - = go e es (ann ++ mkParensEpAnn (locA l)) - go (L loc (PatBuilderOpApp l (L loc' op) r (EpAnn loca anns cs))) es ann + go (L _ (PatBuilderVar (L loc f))) es ops cps + | not (isRdrDataCon f) = return (Just (L loc f, Prefix, es, (reverse ops) ++ cps)) + go (L _ (PatBuilderApp f e)) es ops cps = go f (e:es) ops cps + go (L l (PatBuilderPar _ e _)) es@(_:_) ops cps + = let + (o,c) = mkParensEpAnn (realSrcSpan $ locA l) + in + go e es (o:ops) (c:cps) + go (L loc (PatBuilderOpApp l (L loc' op) r (EpAnn loca anns cs))) es ops cps | not (isRdrDataCon op) -- We have found the function! - = return (Just (L loc' op, Infix, (l:r:es), (anns ++ ann))) + = return (Just (L loc' op, Infix, (l:r:es), (anns ++ reverse ops ++ cps))) | otherwise -- Infix data con; keep going - = do { mb_l <- go l es ann + = do { mb_l <- go l es ops cps ; case mb_l of - Just (op', Infix, j : k : es', ann') - -> return (Just (op', Infix, j : op_app : es', ann')) + Just (op', Infix, j : k : es', anns') + -> return (Just (op', Infix, j : op_app : es', anns')) where op_app = L loc (PatBuilderOpApp k - (L loc' op) r (EpAnn loca anns cs)) + (L loc' op) r (EpAnn loca (reverse ops++cps) cs)) _ -> return Nothing } - go _ _ _ = return Nothing + go _ _ _ _ = return Nothing mkBangTy :: EpAnn [AddEpAnn] -> SrcStrictness -> LHsType GhcPs -> HsType GhcPs mkBangTy anns strictness = diff --git a/testsuite/tests/parser/should_compile/DumpSemis.hs b/testsuite/tests/parser/should_compile/DumpSemis.hs new file mode 100644 index 0000000000..9f2f9629d8 --- /dev/null +++ b/testsuite/tests/parser/should_compile/DumpSemis.hs @@ -0,0 +1,45 @@ +module DumpSemis where + +-- Make sure we get all the semicolons in statements +;;;; ;; +import Data.List +; ; ; +import Data.Kind + ; ;; +foo :: IO () +foo = do + do { ;;;; a } + a +; ;; +bar :: IO () +bar = do + { ; ; + a ;; + b + } + ; ;; ; +baz :: IO () +baz = do { ;; s ; s ; ; s ;; } +; +a = undefined +b = undefined +s = undefined +; +class LiftingMonad2 ((trans :: Type)) where + proof :: trans -> Int +; +f :: ((Eq a, Ord a)) => a -> a +f x = x +; + ;;x=let{;;;;;y=2;;z=3;;;;}in y; +; +fot x = + case x of + { ;;; -- leading + 0 -> 'a'; -- case 0 + 1 -> 'b' -- case 1 + ; 2 -> 'c' ; -- case 2 + ; 3 -> 'd' -- case 3 + ;;; -- case 4 + } +; diff --git a/testsuite/tests/parser/should_compile/DumpSemis.stderr b/testsuite/tests/parser/should_compile/DumpSemis.stderr new file mode 100644 index 0000000000..05465b8a75 --- /dev/null +++ b/testsuite/tests/parser/should_compile/DumpSemis.stderr @@ -0,0 +1,2072 @@ + +==================== Parser AST ==================== + +(L + { DumpSemis.hs:1:1 } + (HsModule + (EpAnn + (Anchor + { DumpSemis.hs:1:1 } + (UnchangedAnchor)) + (AnnsModule + [(AddEpAnn AnnModule (EpaSpan { DumpSemis.hs:1:1-6 })) + ,(AddEpAnn AnnWhere (EpaSpan { DumpSemis.hs:1:18-22 }))] + (AnnList + (Nothing) + (Nothing) + (Nothing) + [] + [(AddSemiAnn + (EpaSpan { DumpSemis.hs:4:1 })) + ,(AddSemiAnn + (EpaSpan { DumpSemis.hs:4:2 })) + ,(AddSemiAnn + (EpaSpan { DumpSemis.hs:4:3 })) + ,(AddSemiAnn + (EpaSpan { DumpSemis.hs:4:4 })) + ,(AddSemiAnn + (EpaSpan { DumpSemis.hs:4:7 })) + ,(AddSemiAnn + (EpaSpan { DumpSemis.hs:4:8 }))])) + (EpaCommentsBalanced + [] + [(L + (Anchor + { DumpSemis.hs:46:1 } + (UnchangedAnchor)) + (EpaComment + (EpaEofComment) + { DumpSemis.hs:46:1 }))])) + (VirtualBraces + (1)) + (Just + (L + { DumpSemis.hs:1:8-16 } + {ModuleName: DumpSemis})) + (Nothing) + [(L + (SrcSpanAnn (EpAnn + (Anchor + { DumpSemis.hs:5:1-16 } + (UnchangedAnchor)) + (AnnListItem + [(AddSemiAnn + (EpaSpan { DumpSemis.hs:6:1 })) + ,(AddSemiAnn + (EpaSpan { DumpSemis.hs:6:3 })) + ,(AddSemiAnn + (EpaSpan { DumpSemis.hs:6:5 }))]) + (EpaComments + [])) { DumpSemis.hs:5:1-16 }) + (ImportDecl + (EpAnn + (Anchor + { DumpSemis.hs:5:1-6 } + (UnchangedAnchor)) + (EpAnnImportDecl + (EpaSpan { DumpSemis.hs:5:1-6 }) + (Nothing) + (Nothing) + (Nothing) + (Nothing) + (Nothing)) + (EpaComments + [])) + (NoSourceText) + (L + { DumpSemis.hs:5:8-16 } + {ModuleName: Data.List}) + (Nothing) + (NotBoot) + (False) + (NotQualified) + (False) + (Nothing) + (Nothing))) + ,(L + (SrcSpanAnn (EpAnn + (Anchor + { DumpSemis.hs:7:1-16 } + (UnchangedAnchor)) + (AnnListItem + [(AddSemiAnn + (EpaSpan { DumpSemis.hs:8:4 })) + ,(AddSemiAnn + (EpaSpan { DumpSemis.hs:8:6 })) + ,(AddSemiAnn + (EpaSpan { DumpSemis.hs:8:7 }))]) + (EpaComments + [])) { DumpSemis.hs:7:1-16 }) + (ImportDecl + (EpAnn + (Anchor + { DumpSemis.hs:7:1-6 } + (UnchangedAnchor)) + (EpAnnImportDecl + (EpaSpan { DumpSemis.hs:7:1-6 }) + (Nothing) + (Nothing) + (Nothing) + (Nothing) + (Nothing)) + (EpaComments + [])) + (NoSourceText) + (L + { DumpSemis.hs:7:8-16 } + {ModuleName: Data.Kind}) + (Nothing) + (NotBoot) + (False) + (NotQualified) + (False) + (Nothing) + (Nothing)))] + [(L + (SrcSpanAnn (EpAnn + (Anchor + { DumpSemis.hs:9:1-12 } + (UnchangedAnchor)) + (AnnListItem + []) + (EpaComments + [])) { DumpSemis.hs:9:1-12 }) + (SigD + (NoExtField) + (TypeSig + (EpAnn + (Anchor + { DumpSemis.hs:9:1-3 } + (UnchangedAnchor)) + (AnnSig + (AddEpAnn AnnDcolon (EpaSpan { DumpSemis.hs:9:5-6 })) + []) + (EpaComments + [])) + [(L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:9:1-3 }) + (Unqual + {OccName: foo}))] + (HsWC + (NoExtField) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:9:8-12 }) + (HsSig + (NoExtField) + (HsOuterImplicit + (NoExtField)) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:9:8-12 }) + (HsAppTy + (NoExtField) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:9:8-9 }) + (HsTyVar + (EpAnn + (Anchor + { DumpSemis.hs:9:8-9 } + (UnchangedAnchor)) + [] + (EpaComments + [])) + (NotPromoted) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:9:8-9 }) + (Unqual + {OccName: IO})))) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:9:11-12 }) + (HsTupleTy + (EpAnn + (Anchor + { DumpSemis.hs:9:11 } + (UnchangedAnchor)) + (AnnParen + (AnnParens) + (EpaSpan { DumpSemis.hs:9:11 }) + (EpaSpan { DumpSemis.hs:9:12 })) + (EpaComments + [])) + (HsBoxedOrConstraintTuple) + [])))))))))) + ,(L + (SrcSpanAnn (EpAnn + (Anchor + { DumpSemis.hs:(10,1)-(12,3) } + (UnchangedAnchor)) + (AnnListItem + [(AddSemiAnn + (EpaSpan { DumpSemis.hs:13:1 })) + ,(AddSemiAnn + (EpaSpan { DumpSemis.hs:13:3 })) + ,(AddSemiAnn + (EpaSpan { DumpSemis.hs:13:4 }))]) + (EpaComments + [])) { DumpSemis.hs:(10,1)-(12,3) }) + (ValD + (NoExtField) + (FunBind + (NoExtField) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:10:1-3 }) + (Unqual + {OccName: foo})) + (MG + (NoExtField) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:(10,1)-(12,3) }) + [(L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:(10,1)-(12,3) }) + (Match + (EpAnn + (Anchor + { DumpSemis.hs:(10,1)-(12,3) } + (UnchangedAnchor)) + [] + (EpaComments + [])) + (FunRhs + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:10:1-3 }) + (Unqual + {OccName: foo})) + (Prefix) + (NoSrcStrict)) + [] + (GRHSs + (EpaComments + []) + [(L + { DumpSemis.hs:(10,5)-(12,3) } + (GRHS + (EpAnn + (Anchor + { DumpSemis.hs:(10,5)-(12,3) } + (UnchangedAnchor)) + (GrhsAnn + (Nothing) + (AddEpAnn AnnEqual (EpaSpan { DumpSemis.hs:10:5 }))) + (EpaComments + [])) + [] + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:(10,7)-(12,3) }) + (HsDo + (EpAnn + (Anchor + { DumpSemis.hs:(10,7)-(12,3) } + (UnchangedAnchor)) + (AnnList + (Just + (Anchor + { DumpSemis.hs:(11,3)-(12,3) } + (UnchangedAnchor))) + (Nothing) + (Nothing) + [(AddEpAnn AnnDo (EpaSpan { DumpSemis.hs:10:7-8 }))] + []) + (EpaComments + [])) + (DoExpr + (Nothing)) + (L + (SrcSpanAnn (EpAnn + (Anchor + { DumpSemis.hs:(11,3)-(12,3) } + (UnchangedAnchor)) + (AnnList + (Just + (Anchor + { DumpSemis.hs:(11,3)-(12,3) } + (UnchangedAnchor))) + (Nothing) + (Nothing) + [] + []) + (EpaComments + [])) { DumpSemis.hs:(11,3)-(12,3) }) + [(L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:11:3-15 }) + (BodyStmt + (NoExtField) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:11:3-15 }) + (HsDo + (EpAnn + (Anchor + { DumpSemis.hs:11:3-15 } + (UnchangedAnchor)) + (AnnList + (Just + (Anchor + { DumpSemis.hs:11:6-15 } + (UnchangedAnchor))) + (Nothing) + (Nothing) + [(AddEpAnn AnnDo (EpaSpan { DumpSemis.hs:11:3-4 }))] + []) + (EpaComments + [])) + (DoExpr + (Nothing)) + (L + (SrcSpanAnn (EpAnn + (Anchor + { DumpSemis.hs:11:6-15 } + (UnchangedAnchor)) + (AnnList + (Just + (Anchor + { DumpSemis.hs:11:8-13 } + (UnchangedAnchor))) + (Just + (AddEpAnn AnnOpenC (EpaSpan { DumpSemis.hs:11:6 }))) + (Just + (AddEpAnn AnnCloseC (EpaSpan { DumpSemis.hs:11:15 }))) + [(AddEpAnn AnnSemi (EpaSpan { DumpSemis.hs:11:8 })) + ,(AddEpAnn AnnSemi (EpaSpan { DumpSemis.hs:11:9 })) + ,(AddEpAnn AnnSemi (EpaSpan { DumpSemis.hs:11:10 })) + ,(AddEpAnn AnnSemi (EpaSpan { DumpSemis.hs:11:11 }))] + []) + (EpaComments + [])) { DumpSemis.hs:11:6-15 }) + [(L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:11:13 }) + (BodyStmt + (NoExtField) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:11:13 }) + (HsVar + (NoExtField) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:11:13 }) + (Unqual + {OccName: a})))) + (NoExtField) + (NoExtField)))]))) + (NoExtField) + (NoExtField))) + ,(L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:12:3 }) + (BodyStmt + (NoExtField) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:12:3 }) + (HsVar + (NoExtField) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:12:3 }) + (Unqual + {OccName: a})))) + (NoExtField) + (NoExtField)))])))))] + (EmptyLocalBinds + (NoExtField)))))]) + (FromSource)) + []))) + ,(L + (SrcSpanAnn (EpAnn + (Anchor + { DumpSemis.hs:14:1-12 } + (UnchangedAnchor)) + (AnnListItem + []) + (EpaComments + [])) { DumpSemis.hs:14:1-12 }) + (SigD + (NoExtField) + (TypeSig + (EpAnn + (Anchor + { DumpSemis.hs:14:1-3 } + (UnchangedAnchor)) + (AnnSig + (AddEpAnn AnnDcolon (EpaSpan { DumpSemis.hs:14:5-6 })) + []) + (EpaComments + [])) + [(L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:14:1-3 }) + (Unqual + {OccName: bar}))] + (HsWC + (NoExtField) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:14:8-12 }) + (HsSig + (NoExtField) + (HsOuterImplicit + (NoExtField)) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:14:8-12 }) + (HsAppTy + (NoExtField) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:14:8-9 }) + (HsTyVar + (EpAnn + (Anchor + { DumpSemis.hs:14:8-9 } + (UnchangedAnchor)) + [] + (EpaComments + [])) + (NotPromoted) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:14:8-9 }) + (Unqual + {OccName: IO})))) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:14:11-12 }) + (HsTupleTy + (EpAnn + (Anchor + { DumpSemis.hs:14:11 } + (UnchangedAnchor)) + (AnnParen + (AnnParens) + (EpaSpan { DumpSemis.hs:14:11 }) + (EpaSpan { DumpSemis.hs:14:12 })) + (EpaComments + [])) + (HsBoxedOrConstraintTuple) + [])))))))))) + ,(L + (SrcSpanAnn (EpAnn + (Anchor + { DumpSemis.hs:(15,1)-(19,3) } + (UnchangedAnchor)) + (AnnListItem + [(AddSemiAnn + (EpaSpan { DumpSemis.hs:20:2 })) + ,(AddSemiAnn + (EpaSpan { DumpSemis.hs:20:4 })) + ,(AddSemiAnn + (EpaSpan { DumpSemis.hs:20:5 })) + ,(AddSemiAnn + (EpaSpan { DumpSemis.hs:20:8 }))]) + (EpaComments + [])) { DumpSemis.hs:(15,1)-(19,3) }) + (ValD + (NoExtField) + (FunBind + (NoExtField) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:15:1-3 }) + (Unqual + {OccName: bar})) + (MG + (NoExtField) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:(15,1)-(19,3) }) + [(L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:(15,1)-(19,3) }) + (Match + (EpAnn + (Anchor + { DumpSemis.hs:(15,1)-(19,3) } + (UnchangedAnchor)) + [] + (EpaComments + [])) + (FunRhs + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:15:1-3 }) + (Unqual + {OccName: bar})) + (Prefix) + (NoSrcStrict)) + [] + (GRHSs + (EpaComments + []) + [(L + { DumpSemis.hs:(15,5)-(19,3) } + (GRHS + (EpAnn + (Anchor + { DumpSemis.hs:(15,5)-(19,3) } + (UnchangedAnchor)) + (GrhsAnn + (Nothing) + (AddEpAnn AnnEqual (EpaSpan { DumpSemis.hs:15:5 }))) + (EpaComments + [])) + [] + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:(15,7)-(19,3) }) + (HsDo + (EpAnn + (Anchor + { DumpSemis.hs:(15,7)-(19,3) } + (UnchangedAnchor)) + (AnnList + (Just + (Anchor + { DumpSemis.hs:(16,3)-(19,3) } + (UnchangedAnchor))) + (Nothing) + (Nothing) + [(AddEpAnn AnnDo (EpaSpan { DumpSemis.hs:15:7-8 }))] + []) + (EpaComments + [])) + (DoExpr + (Nothing)) + (L + (SrcSpanAnn (EpAnn + (Anchor + { DumpSemis.hs:(16,3)-(19,3) } + (UnchangedAnchor)) + (AnnList + (Just + (Anchor + { DumpSemis.hs:(16,5)-(18,5) } + (UnchangedAnchor))) + (Just + (AddEpAnn AnnOpenC (EpaSpan { DumpSemis.hs:16:3 }))) + (Just + (AddEpAnn AnnCloseC (EpaSpan { DumpSemis.hs:19:3 }))) + [(AddEpAnn AnnSemi (EpaSpan { DumpSemis.hs:16:5 })) + ,(AddEpAnn AnnSemi (EpaSpan { DumpSemis.hs:16:8 }))] + []) + (EpaComments + [])) { DumpSemis.hs:(16,3)-(19,3) }) + [(L + (SrcSpanAnn (EpAnn + (Anchor + { DumpSemis.hs:17:5 } + (UnchangedAnchor)) + (AnnListItem + [(AddSemiAnn + (EpaSpan { DumpSemis.hs:17:7 })) + ,(AddSemiAnn + (EpaSpan { DumpSemis.hs:17:8 }))]) + (EpaComments + [])) { DumpSemis.hs:17:5 }) + (BodyStmt + (NoExtField) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:17:5 }) + (HsVar + (NoExtField) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:17:5 }) + (Unqual + {OccName: a})))) + (NoExtField) + (NoExtField))) + ,(L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:18:5 }) + (BodyStmt + (NoExtField) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:18:5 }) + (HsVar + (NoExtField) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:18:5 }) + (Unqual + {OccName: b})))) + (NoExtField) + (NoExtField)))])))))] + (EmptyLocalBinds + (NoExtField)))))]) + (FromSource)) + []))) + ,(L + (SrcSpanAnn (EpAnn + (Anchor + { DumpSemis.hs:21:1-12 } + (UnchangedAnchor)) + (AnnListItem + []) + (EpaComments + [])) { DumpSemis.hs:21:1-12 }) + (SigD + (NoExtField) + (TypeSig + (EpAnn + (Anchor + { DumpSemis.hs:21:1-3 } + (UnchangedAnchor)) + (AnnSig + (AddEpAnn AnnDcolon (EpaSpan { DumpSemis.hs:21:5-6 })) + []) + (EpaComments + [])) + [(L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:21:1-3 }) + (Unqual + {OccName: baz}))] + (HsWC + (NoExtField) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:21:8-12 }) + (HsSig + (NoExtField) + (HsOuterImplicit + (NoExtField)) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:21:8-12 }) + (HsAppTy + (NoExtField) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:21:8-9 }) + (HsTyVar + (EpAnn + (Anchor + { DumpSemis.hs:21:8-9 } + (UnchangedAnchor)) + [] + (EpaComments + [])) + (NotPromoted) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:21:8-9 }) + (Unqual + {OccName: IO})))) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:21:11-12 }) + (HsTupleTy + (EpAnn + (Anchor + { DumpSemis.hs:21:11 } + (UnchangedAnchor)) + (AnnParen + (AnnParens) + (EpaSpan { DumpSemis.hs:21:11 }) + (EpaSpan { DumpSemis.hs:21:12 })) + (EpaComments + [])) + (HsBoxedOrConstraintTuple) + [])))))))))) + ,(L + (SrcSpanAnn (EpAnn + (Anchor + { DumpSemis.hs:22:1-30 } + (UnchangedAnchor)) + (AnnListItem + [(AddSemiAnn + (EpaSpan { DumpSemis.hs:23:1 }))]) + (EpaComments + [])) { DumpSemis.hs:22:1-30 }) + (ValD + (NoExtField) + (FunBind + (NoExtField) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:22:1-3 }) + (Unqual + {OccName: baz})) + (MG + (NoExtField) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:22:1-30 }) + [(L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:22:1-30 }) + (Match + (EpAnn + (Anchor + { DumpSemis.hs:22:1-30 } + (UnchangedAnchor)) + [] + (EpaComments + [])) + (FunRhs + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:22:1-3 }) + (Unqual + {OccName: baz})) + (Prefix) + (NoSrcStrict)) + [] + (GRHSs + (EpaComments + []) + [(L + { DumpSemis.hs:22:5-30 } + (GRHS + (EpAnn + (Anchor + { DumpSemis.hs:22:5-30 } + (UnchangedAnchor)) + (GrhsAnn + (Nothing) + (AddEpAnn AnnEqual (EpaSpan { DumpSemis.hs:22:5 }))) + (EpaComments + [])) + [] + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:22:7-30 }) + (HsDo + (EpAnn + (Anchor + { DumpSemis.hs:22:7-30 } + (UnchangedAnchor)) + (AnnList + (Just + (Anchor + { DumpSemis.hs:22:10-30 } + (UnchangedAnchor))) + (Nothing) + (Nothing) + [(AddEpAnn AnnDo (EpaSpan { DumpSemis.hs:22:7-8 }))] + []) + (EpaComments + [])) + (DoExpr + (Nothing)) + (L + (SrcSpanAnn (EpAnn + (Anchor + { DumpSemis.hs:22:10-30 } + (UnchangedAnchor)) + (AnnList + (Just + (Anchor + { DumpSemis.hs:22:12-25 } + (UnchangedAnchor))) + (Just + (AddEpAnn AnnOpenC (EpaSpan { DumpSemis.hs:22:10 }))) + (Just + (AddEpAnn AnnCloseC (EpaSpan { DumpSemis.hs:22:30 }))) + [(AddEpAnn AnnSemi (EpaSpan { DumpSemis.hs:22:12 })) + ,(AddEpAnn AnnSemi (EpaSpan { DumpSemis.hs:22:13 }))] + []) + (EpaComments + [])) { DumpSemis.hs:22:10-30 }) + [(L + (SrcSpanAnn (EpAnn + (Anchor + { DumpSemis.hs:22:15 } + (UnchangedAnchor)) + (AnnListItem + [(AddSemiAnn + (EpaSpan { DumpSemis.hs:22:17 }))]) + (EpaComments + [])) { DumpSemis.hs:22:15 }) + (BodyStmt + (NoExtField) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:22:15 }) + (HsVar + (NoExtField) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:22:15 }) + (Unqual + {OccName: s})))) + (NoExtField) + (NoExtField))) + ,(L + (SrcSpanAnn (EpAnn + (Anchor + { DumpSemis.hs:22:19 } + (UnchangedAnchor)) + (AnnListItem + [(AddSemiAnn + (EpaSpan { DumpSemis.hs:22:21 })) + ,(AddSemiAnn + (EpaSpan { DumpSemis.hs:22:23 }))]) + (EpaComments + [])) { DumpSemis.hs:22:19 }) + (BodyStmt + (NoExtField) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:22:19 }) + (HsVar + (NoExtField) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:22:19 }) + (Unqual + {OccName: s})))) + (NoExtField) + (NoExtField))) + ,(L + (SrcSpanAnn (EpAnn + (Anchor + { DumpSemis.hs:22:25 } + (UnchangedAnchor)) + (AnnListItem + [(AddSemiAnn + (EpaSpan { DumpSemis.hs:22:27 })) + ,(AddSemiAnn + (EpaSpan { DumpSemis.hs:22:28 }))]) + (EpaComments + [])) { DumpSemis.hs:22:25 }) + (BodyStmt + (NoExtField) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:22:25 }) + (HsVar + (NoExtField) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:22:25 }) + (Unqual + {OccName: s})))) + (NoExtField) + (NoExtField)))])))))] + (EmptyLocalBinds + (NoExtField)))))]) + (FromSource)) + []))) + ,(L + (SrcSpanAnn (EpAnn + (Anchor + { DumpSemis.hs:24:1-13 } + (UnchangedAnchor)) + (AnnListItem + []) + (EpaComments + [])) { DumpSemis.hs:24:1-13 }) + (ValD + (NoExtField) + (FunBind + (NoExtField) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:24:1 }) + (Unqual + {OccName: a})) + (MG + (NoExtField) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:24:1-13 }) + [(L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:24:1-13 }) + (Match + (EpAnn + (Anchor + { DumpSemis.hs:24:1-13 } + (UnchangedAnchor)) + [] + (EpaComments + [])) + (FunRhs + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:24:1 }) + (Unqual + {OccName: a})) + (Prefix) + (NoSrcStrict)) + [] + (GRHSs + (EpaComments + []) + [(L + { DumpSemis.hs:24:3-13 } + (GRHS + (EpAnn + (Anchor + { DumpSemis.hs:24:3-13 } + (UnchangedAnchor)) + (GrhsAnn + (Nothing) + (AddEpAnn AnnEqual (EpaSpan { DumpSemis.hs:24:3 }))) + (EpaComments + [])) + [] + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:24:5-13 }) + (HsVar + (NoExtField) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:24:5-13 }) + (Unqual + {OccName: undefined}))))))] + (EmptyLocalBinds + (NoExtField)))))]) + (FromSource)) + []))) + ,(L + (SrcSpanAnn (EpAnn + (Anchor + { DumpSemis.hs:25:1-13 } + (UnchangedAnchor)) + (AnnListItem + []) + (EpaComments + [])) { DumpSemis.hs:25:1-13 }) + (ValD + (NoExtField) + (FunBind + (NoExtField) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:25:1 }) + (Unqual + {OccName: b})) + (MG + (NoExtField) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:25:1-13 }) + [(L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:25:1-13 }) + (Match + (EpAnn + (Anchor + { DumpSemis.hs:25:1-13 } + (UnchangedAnchor)) + [] + (EpaComments + [])) + (FunRhs + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:25:1 }) + (Unqual + {OccName: b})) + (Prefix) + (NoSrcStrict)) + [] + (GRHSs + (EpaComments + []) + [(L + { DumpSemis.hs:25:3-13 } + (GRHS + (EpAnn + (Anchor + { DumpSemis.hs:25:3-13 } + (UnchangedAnchor)) + (GrhsAnn + (Nothing) + (AddEpAnn AnnEqual (EpaSpan { DumpSemis.hs:25:3 }))) + (EpaComments + [])) + [] + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:25:5-13 }) + (HsVar + (NoExtField) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:25:5-13 }) + (Unqual + {OccName: undefined}))))))] + (EmptyLocalBinds + (NoExtField)))))]) + (FromSource)) + []))) + ,(L + (SrcSpanAnn (EpAnn + (Anchor + { DumpSemis.hs:26:1-13 } + (UnchangedAnchor)) + (AnnListItem + [(AddSemiAnn + (EpaSpan { DumpSemis.hs:27:1 }))]) + (EpaComments + [])) { DumpSemis.hs:26:1-13 }) + (ValD + (NoExtField) + (FunBind + (NoExtField) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:26:1 }) + (Unqual + {OccName: s})) + (MG + (NoExtField) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:26:1-13 }) + [(L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:26:1-13 }) + (Match + (EpAnn + (Anchor + { DumpSemis.hs:26:1-13 } + (UnchangedAnchor)) + [] + (EpaComments + [])) + (FunRhs + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:26:1 }) + (Unqual + {OccName: s})) + (Prefix) + (NoSrcStrict)) + [] + (GRHSs + (EpaComments + []) + [(L + { DumpSemis.hs:26:3-13 } + (GRHS + (EpAnn + (Anchor + { DumpSemis.hs:26:3-13 } + (UnchangedAnchor)) + (GrhsAnn + (Nothing) + (AddEpAnn AnnEqual (EpaSpan { DumpSemis.hs:26:3 }))) + (EpaComments + [])) + [] + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:26:5-13 }) + (HsVar + (NoExtField) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:26:5-13 }) + (Unqual + {OccName: undefined}))))))] + (EmptyLocalBinds + (NoExtField)))))]) + (FromSource)) + []))) + ,(L + (SrcSpanAnn (EpAnn + (Anchor + { DumpSemis.hs:(28,1)-(29,23) } + (UnchangedAnchor)) + (AnnListItem + [(AddSemiAnn + (EpaSpan { DumpSemis.hs:30:1 }))]) + (EpaComments + [])) { DumpSemis.hs:(28,1)-(29,23) }) + (TyClD + (NoExtField) + (ClassDecl + ((,,) + (EpAnn + (Anchor + { DumpSemis.hs:(28,1)-(29,23) } + (UnchangedAnchor)) + [(AddEpAnn AnnClass (EpaSpan { DumpSemis.hs:28:1-5 })) + ,(AddEpAnn AnnWhere (EpaSpan { DumpSemis.hs:28:40-44 }))] + (EpaComments + [])) + (NoAnnSortKey) + (VirtualBraces + (3))) + (Nothing) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:28:7-19 }) + (Unqual + {OccName: LiftingMonad2})) + (HsQTvs + (NoExtField) + [(L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:28:22-38 }) + (KindedTyVar + (EpAnn + (Anchor + { DumpSemis.hs:28:22-38 } + (UnchangedAnchor)) + [(AddEpAnn AnnDcolon (EpaSpan { DumpSemis.hs:28:30-31 })) + ,(AddEpAnn AnnOpenP (EpaSpan { DumpSemis.hs:28:22 })) + ,(AddEpAnn AnnOpenP (EpaSpan { DumpSemis.hs:28:23 })) + ,(AddEpAnn AnnCloseP (EpaSpan { DumpSemis.hs:28:37 })) + ,(AddEpAnn AnnCloseP (EpaSpan { DumpSemis.hs:28:38 }))] + (EpaComments + [])) + (()) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:28:24-28 }) + (Unqual + {OccName: trans})) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:28:33-36 }) + (HsTyVar + (EpAnn + (Anchor + { DumpSemis.hs:28:33-36 } + (UnchangedAnchor)) + [] + (EpaComments + [])) + (NotPromoted) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:28:33-36 }) + (Unqual + {OccName: Type}))))))]) + (Prefix) + [] + [(L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:29:3-23 }) + (ClassOpSig + (EpAnn + (Anchor + { DumpSemis.hs:29:3-7 } + (UnchangedAnchor)) + (AnnSig + (AddEpAnn AnnDcolon (EpaSpan { DumpSemis.hs:29:9-10 })) + []) + (EpaComments + [])) + (False) + [(L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:29:3-7 }) + (Unqual + {OccName: proof}))] + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:29:12-23 }) + (HsSig + (NoExtField) + (HsOuterImplicit + (NoExtField)) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:29:12-23 }) + (HsFunTy + (EpAnn + (Anchor + { DumpSemis.hs:29:12-16 } + (UnchangedAnchor)) + (NoEpAnns) + (EpaComments + [])) + (HsUnrestrictedArrow + (L + (TokenLoc + (EpaSpan { DumpSemis.hs:29:18-19 })) + (HsNormalTok))) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:29:12-16 }) + (HsTyVar + (EpAnn + (Anchor + { DumpSemis.hs:29:12-16 } + (UnchangedAnchor)) + [] + (EpaComments + [])) + (NotPromoted) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:29:12-16 }) + (Unqual + {OccName: trans})))) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:29:21-23 }) + (HsTyVar + (EpAnn + (Anchor + { DumpSemis.hs:29:21-23 } + (UnchangedAnchor)) + [] + (EpaComments + [])) + (NotPromoted) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:29:21-23 }) + (Unqual + {OccName: Int}))))))))))] + {Bag(LocatedA (HsBind GhcPs)): + []} + [] + [] + []))) + ,(L + (SrcSpanAnn (EpAnn + (Anchor + { DumpSemis.hs:31:1-30 } + (UnchangedAnchor)) + (AnnListItem + []) + (EpaComments + [])) { DumpSemis.hs:31:1-30 }) + (SigD + (NoExtField) + (TypeSig + (EpAnn + (Anchor + { DumpSemis.hs:31:1 } + (UnchangedAnchor)) + (AnnSig + (AddEpAnn AnnDcolon (EpaSpan { DumpSemis.hs:31:3-4 })) + []) + (EpaComments + [])) + [(L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:31:1 }) + (Unqual + {OccName: f}))] + (HsWC + (NoExtField) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:31:6-30 }) + (HsSig + (NoExtField) + (HsOuterImplicit + (NoExtField)) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:31:6-30 }) + (HsQualTy + (NoExtField) + (L + (SrcSpanAnn (EpAnn + (Anchor + { DumpSemis.hs:31:6-20 } + (UnchangedAnchor)) + (AnnContext + (Just + ((,) + (NormalSyntax) + (EpaSpan { DumpSemis.hs:31:22-23 }))) + [(EpaSpan { DumpSemis.hs:31:6 }) + ,(EpaSpan { DumpSemis.hs:31:7 })] + [(EpaSpan { DumpSemis.hs:31:19 }) + ,(EpaSpan { DumpSemis.hs:31:20 })]) + (EpaComments + [])) { DumpSemis.hs:31:6-20 }) + [(L + (SrcSpanAnn (EpAnn + (Anchor + { DumpSemis.hs:31:8-11 } + (UnchangedAnchor)) + (AnnListItem + [(AddCommaAnn + (EpaSpan { DumpSemis.hs:31:12 }))]) + (EpaComments + [])) { DumpSemis.hs:31:8-11 }) + (HsAppTy + (NoExtField) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:31:8-9 }) + (HsTyVar + (EpAnn + (Anchor + { DumpSemis.hs:31:8-9 } + (UnchangedAnchor)) + [] + (EpaComments + [])) + (NotPromoted) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:31:8-9 }) + (Unqual + {OccName: Eq})))) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:31:11 }) + (HsTyVar + (EpAnn + (Anchor + { DumpSemis.hs:31:11 } + (UnchangedAnchor)) + [] + (EpaComments + [])) + (NotPromoted) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:31:11 }) + (Unqual + {OccName: a})))))) + ,(L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:31:14-18 }) + (HsAppTy + (NoExtField) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:31:14-16 }) + (HsTyVar + (EpAnn + (Anchor + { DumpSemis.hs:31:14-16 } + (UnchangedAnchor)) + [] + (EpaComments + [])) + (NotPromoted) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:31:14-16 }) + (Unqual + {OccName: Ord})))) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:31:18 }) + (HsTyVar + (EpAnn + (Anchor + { DumpSemis.hs:31:18 } + (UnchangedAnchor)) + [] + (EpaComments + [])) + (NotPromoted) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:31:18 }) + (Unqual + {OccName: a}))))))]) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:31:25-30 }) + (HsFunTy + (EpAnn + (Anchor + { DumpSemis.hs:31:25 } + (UnchangedAnchor)) + (NoEpAnns) + (EpaComments + [])) + (HsUnrestrictedArrow + (L + (TokenLoc + (EpaSpan { DumpSemis.hs:31:27-28 })) + (HsNormalTok))) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:31:25 }) + (HsTyVar + (EpAnn + (Anchor + { DumpSemis.hs:31:25 } + (UnchangedAnchor)) + [] + (EpaComments + [])) + (NotPromoted) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:31:25 }) + (Unqual + {OccName: a})))) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:31:30 }) + (HsTyVar + (EpAnn + (Anchor + { DumpSemis.hs:31:30 } + (UnchangedAnchor)) + [] + (EpaComments + [])) + (NotPromoted) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:31:30 }) + (Unqual + {OccName: a})))))))))))))) + ,(L + (SrcSpanAnn (EpAnn + (Anchor + { DumpSemis.hs:32:1-7 } + (UnchangedAnchor)) + (AnnListItem + []) + (EpaComments + [])) { DumpSemis.hs:32:1-7 }) + (ValD + (NoExtField) + (FunBind + (NoExtField) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:32:1 }) + (Unqual + {OccName: f})) + (MG + (NoExtField) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:32:1-7 }) + [(L + (SrcSpanAnn (EpAnn + (Anchor + { DumpSemis.hs:32:1-7 } + (UnchangedAnchor)) + (AnnListItem + [(AddSemiAnn + (EpaSpan { DumpSemis.hs:33:1 })) + ,(AddSemiAnn + (EpaSpan { DumpSemis.hs:34:6 })) + ,(AddSemiAnn + (EpaSpan { DumpSemis.hs:34:7 }))]) + (EpaComments + [])) { DumpSemis.hs:32:1-7 }) + (Match + (EpAnn + (Anchor + { DumpSemis.hs:32:1-7 } + (UnchangedAnchor)) + [] + (EpaComments + [])) + (FunRhs + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:32:1 }) + (Unqual + {OccName: f})) + (Prefix) + (NoSrcStrict)) + [(L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:32:3 }) + (VarPat + (NoExtField) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:32:3 }) + (Unqual + {OccName: x}))))] + (GRHSs + (EpaComments + []) + [(L + { DumpSemis.hs:32:5-7 } + (GRHS + (EpAnn + (Anchor + { DumpSemis.hs:32:5-7 } + (UnchangedAnchor)) + (GrhsAnn + (Nothing) + (AddEpAnn AnnEqual (EpaSpan { DumpSemis.hs:32:5 }))) + (EpaComments + [])) + [] + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:32:7 }) + (HsVar + (NoExtField) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:32:7 }) + (Unqual + {OccName: x}))))))] + (EmptyLocalBinds + (NoExtField)))))]) + (FromSource)) + []))) + ,(L + (SrcSpanAnn (EpAnn + (Anchor + { DumpSemis.hs:34:8-35 } + (UnchangedAnchor)) + (AnnListItem + [(AddSemiAnn + (EpaSpan { DumpSemis.hs:34:36 })) + ,(AddSemiAnn + (EpaSpan { DumpSemis.hs:35:1 }))]) + (EpaComments + [])) { DumpSemis.hs:34:8-35 }) + (ValD + (NoExtField) + (FunBind + (NoExtField) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:34:8 }) + (Unqual + {OccName: x})) + (MG + (NoExtField) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:34:8-35 }) + [(L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:34:8-35 }) + (Match + (EpAnn + (Anchor + { DumpSemis.hs:34:8-35 } + (UnchangedAnchor)) + [] + (EpaComments + [])) + (FunRhs + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:34:8 }) + (Unqual + {OccName: x})) + (Prefix) + (NoSrcStrict)) + [] + (GRHSs + (EpaComments + []) + [(L + { DumpSemis.hs:34:9-35 } + (GRHS + (EpAnn + (Anchor + { DumpSemis.hs:34:9-35 } + (UnchangedAnchor)) + (GrhsAnn + (Nothing) + (AddEpAnn AnnEqual (EpaSpan { DumpSemis.hs:34:9 }))) + (EpaComments + [])) + [] + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:34:10-35 }) + (HsLet + (EpAnn + (Anchor + { DumpSemis.hs:34:10-35 } + (UnchangedAnchor)) + (AnnsLet + (EpaSpan { DumpSemis.hs:34:10-12 }) + (EpaSpan { DumpSemis.hs:34:32-33 })) + (EpaComments + [])) + (HsValBinds + (EpAnn + (Anchor + { DumpSemis.hs:34:13-31 } + (UnchangedAnchor)) + (AnnList + (Just + (Anchor + { DumpSemis.hs:34:14-30 } + (UnchangedAnchor))) + (Just + (AddEpAnn AnnOpenC (EpaSpan { DumpSemis.hs:34:13 }))) + (Just + (AddEpAnn AnnCloseC (EpaSpan { DumpSemis.hs:34:31 }))) + [] + [(AddSemiAnn + (EpaSpan { DumpSemis.hs:34:14 })) + ,(AddSemiAnn + (EpaSpan { DumpSemis.hs:34:15 })) + ,(AddSemiAnn + (EpaSpan { DumpSemis.hs:34:16 })) + ,(AddSemiAnn + (EpaSpan { DumpSemis.hs:34:17 })) + ,(AddSemiAnn + (EpaSpan { DumpSemis.hs:34:18 }))]) + (EpaComments + [])) + (ValBinds + (NoAnnSortKey) + {Bag(LocatedA (HsBind GhcPs)): + [(L + (SrcSpanAnn (EpAnn + (Anchor + { DumpSemis.hs:34:19-21 } + (UnchangedAnchor)) + (AnnListItem + [(AddSemiAnn + (EpaSpan { DumpSemis.hs:34:22 })) + ,(AddSemiAnn + (EpaSpan { DumpSemis.hs:34:23 }))]) + (EpaComments + [])) { DumpSemis.hs:34:19-21 }) + (FunBind + (NoExtField) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:34:19 }) + (Unqual + {OccName: y})) + (MG + (NoExtField) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:34:19-21 }) + [(L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:34:19-21 }) + (Match + (EpAnn + (Anchor + { DumpSemis.hs:34:19-21 } + (UnchangedAnchor)) + [] + (EpaComments + [])) + (FunRhs + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:34:19 }) + (Unqual + {OccName: y})) + (Prefix) + (NoSrcStrict)) + [] + (GRHSs + (EpaComments + []) + [(L + { DumpSemis.hs:34:20-21 } + (GRHS + (EpAnn + (Anchor + { DumpSemis.hs:34:20-21 } + (UnchangedAnchor)) + (GrhsAnn + (Nothing) + (AddEpAnn AnnEqual (EpaSpan { DumpSemis.hs:34:20 }))) + (EpaComments + [])) + [] + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:34:21 }) + (HsOverLit + (EpAnn + (Anchor + { DumpSemis.hs:34:21 } + (UnchangedAnchor)) + (NoEpAnns) + (EpaComments + [])) + (OverLit + (NoExtField) + (HsIntegral + (IL + (SourceText 2) + (False) + (2))))))))] + (EmptyLocalBinds + (NoExtField)))))]) + (FromSource)) + [])) + ,(L + (SrcSpanAnn (EpAnn + (Anchor + { DumpSemis.hs:34:24-26 } + (UnchangedAnchor)) + (AnnListItem + [(AddSemiAnn + (EpaSpan { DumpSemis.hs:34:27 })) + ,(AddSemiAnn + (EpaSpan { DumpSemis.hs:34:28 })) + ,(AddSemiAnn + (EpaSpan { DumpSemis.hs:34:29 })) + ,(AddSemiAnn + (EpaSpan { DumpSemis.hs:34:30 }))]) + (EpaComments + [])) { DumpSemis.hs:34:24-26 }) + (FunBind + (NoExtField) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:34:24 }) + (Unqual + {OccName: z})) + (MG + (NoExtField) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:34:24-26 }) + [(L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:34:24-26 }) + (Match + (EpAnn + (Anchor + { DumpSemis.hs:34:24-26 } + (UnchangedAnchor)) + [] + (EpaComments + [])) + (FunRhs + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:34:24 }) + (Unqual + {OccName: z})) + (Prefix) + (NoSrcStrict)) + [] + (GRHSs + (EpaComments + []) + [(L + { DumpSemis.hs:34:25-26 } + (GRHS + (EpAnn + (Anchor + { DumpSemis.hs:34:25-26 } + (UnchangedAnchor)) + (GrhsAnn + (Nothing) + (AddEpAnn AnnEqual (EpaSpan { DumpSemis.hs:34:25 }))) + (EpaComments + [])) + [] + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:34:26 }) + (HsOverLit + (EpAnn + (Anchor + { DumpSemis.hs:34:26 } + (UnchangedAnchor)) + (NoEpAnns) + (EpaComments + [])) + (OverLit + (NoExtField) + (HsIntegral + (IL + (SourceText 3) + (False) + (3))))))))] + (EmptyLocalBinds + (NoExtField)))))]) + (FromSource)) + []))]} + [])) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:34:35 }) + (HsVar + (NoExtField) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:34:35 }) + (Unqual + {OccName: y}))))))))] + (EmptyLocalBinds + (NoExtField)))))]) + (FromSource)) + []))) + ,(L + (SrcSpanAnn (EpAnn + (Anchor + { DumpSemis.hs:(36,1)-(44,4) } + (UnchangedAnchor)) + (AnnListItem + []) + (EpaComments + [])) { DumpSemis.hs:(36,1)-(44,4) }) + (ValD + (NoExtField) + (FunBind + (NoExtField) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:36:1-3 }) + (Unqual + {OccName: fot})) + (MG + (NoExtField) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:(36,1)-(44,4) }) + [(L + (SrcSpanAnn (EpAnn + (Anchor + { DumpSemis.hs:(36,1)-(44,4) } + (UnchangedAnchor)) + (AnnListItem + [(AddSemiAnn + (EpaSpan { DumpSemis.hs:45:1 }))]) + (EpaComments + [])) { DumpSemis.hs:(36,1)-(44,4) }) + (Match + (EpAnn + (Anchor + { DumpSemis.hs:(36,1)-(44,4) } + (UnchangedAnchor)) + [] + (EpaComments + [])) + (FunRhs + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:36:1-3 }) + (Unqual + {OccName: fot})) + (Prefix) + (NoSrcStrict)) + [(L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:36:5 }) + (VarPat + (NoExtField) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:36:5 }) + (Unqual + {OccName: x}))))] + (GRHSs + (EpaComments + []) + [(L + { DumpSemis.hs:(36,7)-(44,4) } + (GRHS + (EpAnn + (Anchor + { DumpSemis.hs:(36,7)-(44,4) } + (UnchangedAnchor)) + (GrhsAnn + (Nothing) + (AddEpAnn AnnEqual (EpaSpan { DumpSemis.hs:36:7 }))) + (EpaComments + [])) + [] + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:(37,3)-(44,4) }) + (HsCase + (EpAnn + (Anchor + { DumpSemis.hs:(37,3)-(44,4) } + (UnchangedAnchor)) + (EpAnnHsCase + (EpaSpan { DumpSemis.hs:37:3-6 }) + (EpaSpan { DumpSemis.hs:37:10-11 }) + []) + (EpaComments + [])) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:37:8 }) + (HsVar + (NoExtField) + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:37:8 }) + (Unqual + {OccName: x})))) + (MG + (NoExtField) + (L + (SrcSpanAnn (EpAnn + (Anchor + { DumpSemis.hs:(38,4)-(44,4) } + (UnchangedAnchor)) + (AnnList + (Just + (Anchor + { DumpSemis.hs:(38,6)-(43,13) } + (UnchangedAnchor))) + (Just + (AddEpAnn AnnOpenC (EpaSpan { DumpSemis.hs:38:4 }))) + (Just + (AddEpAnn AnnCloseC (EpaSpan { DumpSemis.hs:44:4 }))) + [(AddEpAnn AnnSemi (EpaSpan { DumpSemis.hs:38:6 })) + ,(AddEpAnn AnnSemi (EpaSpan { DumpSemis.hs:38:7 })) + ,(AddEpAnn AnnSemi (EpaSpan { DumpSemis.hs:38:8 }))] + []) + (EpaComments + [])) { DumpSemis.hs:(38,4)-(44,4) }) + [(L + (SrcSpanAnn (EpAnn + (Anchor + { DumpSemis.hs:39:6-13 } + (UnchangedAnchor)) + (AnnListItem + [(AddSemiAnn + (EpaSpan { DumpSemis.hs:39:14 }))]) + (EpaComments + [])) { DumpSemis.hs:39:6-13 }) + (Match + (EpAnn + (Anchor + { DumpSemis.hs:39:6 } + (UnchangedAnchor)) + [] + (EpaComments + [])) + (CaseAlt) + [(L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:39:6 }) + (NPat + (EpAnnNotUsed) + (L + { DumpSemis.hs:39:6 } + (OverLit + (NoExtField) + (HsIntegral + (IL + (SourceText 0) + (False) + (0))))) + (Nothing) + (NoExtField)))] + (GRHSs + (EpaComments + []) + [(L + { DumpSemis.hs:39:8-13 } + (GRHS + (EpAnn + (Anchor + { DumpSemis.hs:39:8-9 } + (UnchangedAnchor)) + (GrhsAnn + (Nothing) + (AddEpAnn AnnRarrow (EpaSpan { DumpSemis.hs:39:8-9 }))) + (EpaComments + [])) + [] + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:39:11-13 }) + (HsLit + (EpAnn + (Anchor + { DumpSemis.hs:39:11-13 } + (UnchangedAnchor)) + (NoEpAnns) + (EpaComments + [])) + (HsChar + (SourceText 'a') + ('a'))))))] + (EmptyLocalBinds + (NoExtField))))) + ,(L + (SrcSpanAnn (EpAnn + (Anchor + { DumpSemis.hs:40:6-13 } + (UnchangedAnchor)) + (AnnListItem + [(AddSemiAnn + (EpaSpan { DumpSemis.hs:41:4 }))]) + (EpaComments + [])) { DumpSemis.hs:40:6-13 }) + (Match + (EpAnn + (Anchor + { DumpSemis.hs:40:6 } + (UnchangedAnchor)) + [] + (EpaComments + [])) + (CaseAlt) + [(L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:40:6 }) + (NPat + (EpAnnNotUsed) + (L + { DumpSemis.hs:40:6 } + (OverLit + (NoExtField) + (HsIntegral + (IL + (SourceText 1) + (False) + (1))))) + (Nothing) + (NoExtField)))] + (GRHSs + (EpaComments + []) + [(L + { DumpSemis.hs:40:8-13 } + (GRHS + (EpAnn + (Anchor + { DumpSemis.hs:40:8-9 } + (UnchangedAnchor)) + (GrhsAnn + (Nothing) + (AddEpAnn AnnRarrow (EpaSpan { DumpSemis.hs:40:8-9 }))) + (EpaComments + [])) + [] + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:40:11-13 }) + (HsLit + (EpAnn + (Anchor + { DumpSemis.hs:40:11-13 } + (UnchangedAnchor)) + (NoEpAnns) + (EpaComments + [])) + (HsChar + (SourceText 'b') + ('b'))))))] + (EmptyLocalBinds + (NoExtField))))) + ,(L + (SrcSpanAnn (EpAnn + (Anchor + { DumpSemis.hs:41:6-13 } + (UnchangedAnchor)) + (AnnListItem + [(AddSemiAnn + (EpaSpan { DumpSemis.hs:41:15 })) + ,(AddSemiAnn + (EpaSpan { DumpSemis.hs:42:4 }))]) + (EpaComments + [])) { DumpSemis.hs:41:6-13 }) + (Match + (EpAnn + (Anchor + { DumpSemis.hs:41:6 } + (UnchangedAnchor)) + [] + (EpaComments + [])) + (CaseAlt) + [(L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:41:6 }) + (NPat + (EpAnnNotUsed) + (L + { DumpSemis.hs:41:6 } + (OverLit + (NoExtField) + (HsIntegral + (IL + (SourceText 2) + (False) + (2))))) + (Nothing) + (NoExtField)))] + (GRHSs + (EpaComments + []) + [(L + { DumpSemis.hs:41:8-13 } + (GRHS + (EpAnn + (Anchor + { DumpSemis.hs:41:8-9 } + (UnchangedAnchor)) + (GrhsAnn + (Nothing) + (AddEpAnn AnnRarrow (EpaSpan { DumpSemis.hs:41:8-9 }))) + (EpaComments + [])) + [] + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:41:11-13 }) + (HsLit + (EpAnn + (Anchor + { DumpSemis.hs:41:11-13 } + (UnchangedAnchor)) + (NoEpAnns) + (EpaComments + [])) + (HsChar + (SourceText 'c') + ('c'))))))] + (EmptyLocalBinds + (NoExtField))))) + ,(L + (SrcSpanAnn (EpAnn + (Anchor + { DumpSemis.hs:42:6-13 } + (UnchangedAnchor)) + (AnnListItem + [(AddSemiAnn + (EpaSpan { DumpSemis.hs:43:11 })) + ,(AddSemiAnn + (EpaSpan { DumpSemis.hs:43:12 })) + ,(AddSemiAnn + (EpaSpan { DumpSemis.hs:43:13 }))]) + (EpaComments + [])) { DumpSemis.hs:42:6-13 }) + (Match + (EpAnn + (Anchor + { DumpSemis.hs:42:6 } + (UnchangedAnchor)) + [] + (EpaComments + [])) + (CaseAlt) + [(L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:42:6 }) + (NPat + (EpAnnNotUsed) + (L + { DumpSemis.hs:42:6 } + (OverLit + (NoExtField) + (HsIntegral + (IL + (SourceText 3) + (False) + (3))))) + (Nothing) + (NoExtField)))] + (GRHSs + (EpaComments + []) + [(L + { DumpSemis.hs:42:8-13 } + (GRHS + (EpAnn + (Anchor + { DumpSemis.hs:42:8-9 } + (UnchangedAnchor)) + (GrhsAnn + (Nothing) + (AddEpAnn AnnRarrow (EpaSpan { DumpSemis.hs:42:8-9 }))) + (EpaComments + [])) + [] + (L + (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:42:11-13 }) + (HsLit + (EpAnn + (Anchor + { DumpSemis.hs:42:11-13 } + (UnchangedAnchor)) + (NoEpAnns) + (EpaComments + [])) + (HsChar + (SourceText 'd') + ('d'))))))] + (EmptyLocalBinds + (NoExtField)))))]) + (FromSource))))))] + (EmptyLocalBinds + (NoExtField)))))]) + (FromSource)) + [])))] + (Nothing) + (Nothing)))
\ No newline at end of file diff --git a/testsuite/tests/parser/should_compile/T20452.stderr b/testsuite/tests/parser/should_compile/T20452.stderr index 47a05d5770..d1a11145fa 100644 --- a/testsuite/tests/parser/should_compile/T20452.stderr +++ b/testsuite/tests/parser/should_compile/T20452.stderr @@ -155,9 +155,9 @@ { T20452.hs:6:13-22 } (UnchangedAnchor)) [(AddEpAnn AnnDcolon (EpaSpan { T20452.hs:6:17-18 })) + ,(AddEpAnn AnnOpenP (EpaSpan { T20452.hs:6:13 })) ,(AddEpAnn AnnOpenP (EpaSpan { T20452.hs:6:14 })) ,(AddEpAnn AnnCloseP (EpaSpan { T20452.hs:6:21 })) - ,(AddEpAnn AnnOpenP (EpaSpan { T20452.hs:6:13 })) ,(AddEpAnn AnnCloseP (EpaSpan { T20452.hs:6:22 }))] (EpaComments [])) @@ -436,9 +436,9 @@ { T20452.hs:9:14-27 } (UnchangedAnchor)) [(AddEpAnn AnnDcolon (EpaSpan { T20452.hs:9:20-21 })) + ,(AddEpAnn AnnOpenP (EpaSpan { T20452.hs:9:14 })) ,(AddEpAnn AnnOpenP (EpaSpan { T20452.hs:9:15 })) ,(AddEpAnn AnnCloseP (EpaSpan { T20452.hs:9:26 })) - ,(AddEpAnn AnnOpenP (EpaSpan { T20452.hs:9:14 })) ,(AddEpAnn AnnCloseP (EpaSpan { T20452.hs:9:27 }))] (EpaComments [])) @@ -470,9 +470,9 @@ { T20452.hs:9:29-46 } (UnchangedAnchor)) [(AddEpAnn AnnDcolon (EpaSpan { T20452.hs:9:36-37 })) + ,(AddEpAnn AnnOpenP (EpaSpan { T20452.hs:9:29 })) ,(AddEpAnn AnnOpenP (EpaSpan { T20452.hs:9:30 })) ,(AddEpAnn AnnCloseP (EpaSpan { T20452.hs:9:45 })) - ,(AddEpAnn AnnOpenP (EpaSpan { T20452.hs:9:29 })) ,(AddEpAnn AnnCloseP (EpaSpan { T20452.hs:9:46 }))] (EpaComments [])) @@ -504,9 +504,9 @@ { T20452.hs:9:48-76 } (UnchangedAnchor)) [(AddEpAnn AnnDcolon (EpaSpan { T20452.hs:9:54-55 })) + ,(AddEpAnn AnnOpenP (EpaSpan { T20452.hs:9:48 })) ,(AddEpAnn AnnOpenP (EpaSpan { T20452.hs:9:49 })) ,(AddEpAnn AnnCloseP (EpaSpan { T20452.hs:9:75 })) - ,(AddEpAnn AnnOpenP (EpaSpan { T20452.hs:9:48 })) ,(AddEpAnn AnnCloseP (EpaSpan { T20452.hs:9:76 }))] (EpaComments [])) diff --git a/testsuite/tests/parser/should_compile/all.T b/testsuite/tests/parser/should_compile/all.T index d24321a103..5f81a651c3 100644 --- a/testsuite/tests/parser/should_compile/all.T +++ b/testsuite/tests/parser/should_compile/all.T @@ -179,3 +179,5 @@ test('T19521', normal, compile, ['']) test('T20186', normal, compile, ['']) test('T20452', normal, compile, ['']) + +test('DumpSemis', normal, compile, ['-dsuppress-uniques -ddump-parsed-ast']) diff --git a/utils/check-exact/Main.hs b/utils/check-exact/Main.hs index 71af87b760..f1a9ed812d 100644 --- a/utils/check-exact/Main.hs +++ b/utils/check-exact/Main.hs @@ -72,7 +72,7 @@ _tt = testOneFile changers "/home/alanz/mysrc/git.haskell.org/worktree/exactprin -- "../../testsuite/tests/ghc-api/exactprint/RmDecl1.hs" (Just rmDecl1) -- "../../testsuite/tests/ghc-api/exactprint/RmDecl2.hs" (Just rmDecl2) -- "../../testsuite/tests/ghc-api/exactprint/RmDecl3.hs" (Just rmDecl3) - "../../testsuite/tests/ghc-api/exactprint/RmDecl4.hs" (Just rmDecl4) + -- "../../testsuite/tests/ghc-api/exactprint/RmDecl4.hs" (Just rmDecl4) -- "../../testsuite/tests/ghc-api/exactprint/RmDecl5.hs" (Just rmDecl5) -- "../../testsuite/tests/ghc-api/exactprint/RmDecl6.hs" (Just rmDecl6) -- "../../testsuite/tests/ghc-api/exactprint/RmDecl7.hs" (Just rmDecl7) @@ -199,6 +199,7 @@ _tt = testOneFile changers "/home/alanz/mysrc/git.haskell.org/worktree/exactprin -- "../../testsuite/tests/printer/PprLinearArrow.hs" Nothing -- "../../testsuite/tests/printer/PprSemis.hs" Nothing -- "../../testsuite/tests/printer/PprEmptyMostly.hs" Nothing + "../../testsuite/tests/parser/should_compile/DumpSemis.hs" Nothing -- cloneT does not need a test, function can be retired |