Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC
Commits:
-
e55d1e73
by Wolfgang Jeltsch at 2026-05-11T12:23:14-04:00
-
f127d6b8
by Vladislav Zavialov at 2026-05-11T12:23:15-04:00
-
d8a6ac65
by Alice Rixte at 2026-05-11T12:23:23-04:00
27 changed files:
- + changelog.d/ghc-api-epa-parens
- compiler/GHC/Hs/Dump.hs
- compiler/GHC/Hs/Expr.hs
- compiler/GHC/Hs/Pat.hs
- compiler/GHC/Hs/Type.hs
- compiler/GHC/Parser.y
- compiler/GHC/Parser/Annotation.hs
- compiler/GHC/Parser/PostProcess.hs
- libraries/base/src/Data/Functor/Classes.hs
- libraries/base/src/Data/Functor/Compose.hs
- libraries/base/src/Prelude.hs
- libraries/base/src/Text/Read.hs
- libraries/ghc-internal/ghc-internal.cabal.in
- libraries/ghc-internal/src/GHC/Internal/IO/Encoding.hs
- − libraries/ghc-internal/src/GHC/Internal/Text/Read.hs
- testsuite/tests/ghc-api/T25121_status.stdout
- + testsuite/tests/interface-stability/.gitignore
- testsuite/tests/interface-stability/README.mkd
- + testsuite/tests/interface-stability/download-base-exports.sh
- testsuite/tests/parser/should_compile/DumpParsedAst.stderr
- testsuite/tests/parser/should_compile/DumpRenamedAst.stderr
- testsuite/tests/parser/should_compile/KindSigs.stderr
- testsuite/tests/parser/should_compile/T20452.stderr
- testsuite/tests/th/T24111.stdout
- testsuite/tests/typecheck/should_compile/subsumption_sort_hole_fits.stderr
- testsuite/tests/typecheck/should_fail/T21130.stderr
- utils/check-exact/ExactPrint.hs
Changes:
| 1 | +section: ghc-lib
|
|
| 2 | +synopsis: Use ``AnnParen`` for tuples and sums
|
|
| 3 | +issues: #26969
|
|
| 4 | +mrs: !15836
|
|
| 5 | + |
|
| 6 | +description: {
|
|
| 7 | +Do not use ``AnnParen`` in ``XListTy``, replacing it with ``EpToken "["`` and ``"]"``,
|
|
| 8 | +and specialise it to tuples/sums by dropping the ``AnnParensSquare`` constructor,
|
|
| 9 | +keeping only ``AnnParens`` and ``AnnParensHash``. Use ``AnnParen`` in ``XExplicitTuple``,
|
|
| 10 | +``XExplicitTupleTy``, ``XTuplePat``, ``XExplicitSum`` (via ``AnnExplicitSum``), and
|
|
| 11 | +``XSumPat`` (via ``EpAnnSumPat``).
|
|
| 12 | +} |
| ... | ... | @@ -221,7 +221,6 @@ showAstData bs ba a0 = blankLine $$ showAstData' a0 |
| 221 | 221 | NoBlankEpAnnotations -> parens (case ap of
|
| 222 | 222 | (AnnParens o c) -> text "AnnParens" $$ vcat [showAstData' o, showAstData' c]
|
| 223 | 223 | (AnnParensHash o c) -> text "AnnParensHash" $$ vcat [showAstData' o, showAstData' c]
|
| 224 | - (AnnParensSquare o c) -> text "AnnParensSquare" $$ vcat [showAstData' o, showAstData' c]
|
|
| 225 | 224 | )
|
| 226 | 225 | |
| 227 | 226 | annClassDecl :: AnnClassDecl -> SDoc
|
| ... | ... | @@ -264,7 +264,7 @@ type instance XPar GhcPs = (EpToken "(", EpToken ")") |
| 264 | 264 | type instance XPar GhcRn = NoExtField
|
| 265 | 265 | type instance XPar GhcTc = NoExtField
|
| 266 | 266 | |
| 267 | -type instance XExplicitTuple GhcPs = (EpaLocation, EpaLocation)
|
|
| 267 | +type instance XExplicitTuple GhcPs = AnnParen
|
|
| 268 | 268 | type instance XExplicitTuple GhcRn = NoExtField
|
| 269 | 269 | type instance XExplicitTuple GhcTc = NoExtField
|
| 270 | 270 | |
| ... | ... | @@ -554,14 +554,13 @@ mkHsVarWithUserRdr rdr n = HsVar noExtField $ |
| 554 | 554 | |
| 555 | 555 | data AnnExplicitSum
|
| 556 | 556 | = AnnExplicitSum {
|
| 557 | - aesOpen :: EpaLocation,
|
|
| 557 | + aesParens :: AnnParen,
|
|
| 558 | 558 | aesBarsBefore :: [EpToken "|"],
|
| 559 | - aesBarsAfter :: [EpToken "|"],
|
|
| 560 | - aesClose :: EpaLocation
|
|
| 559 | + aesBarsAfter :: [EpToken "|"]
|
|
| 561 | 560 | } deriving Data
|
| 562 | 561 | |
| 563 | 562 | instance NoAnn AnnExplicitSum where
|
| 564 | - noAnn = AnnExplicitSum noAnn noAnn noAnn noAnn
|
|
| 563 | + noAnn = AnnExplicitSum noAnn noAnn noAnn
|
|
| 565 | 564 | |
| 566 | 565 | data AnnFieldLabel
|
| 567 | 566 | = AnnFieldLabel {
|
| ... | ... | @@ -113,7 +113,7 @@ type instance XListPat GhcRn = NoExtField |
| 113 | 113 | type instance XListPat GhcTc = Type
|
| 114 | 114 | -- List element type, for use in hsPatType.
|
| 115 | 115 | |
| 116 | -type instance XTuplePat GhcPs = (EpaLocation, EpaLocation)
|
|
| 116 | +type instance XTuplePat GhcPs = AnnParen
|
|
| 117 | 117 | type instance XTuplePat GhcRn = NoExtField
|
| 118 | 118 | type instance XTuplePat GhcTc = [Type]
|
| 119 | 119 | |
| ... | ... | @@ -263,13 +263,13 @@ discarded inside tcMatchPats, where we know if visible pattern retained or erase |
| 263 | 263 | -- API Annotations types
|
| 264 | 264 | |
| 265 | 265 | data EpAnnSumPat = EpAnnSumPat
|
| 266 | - { sumPatParens :: (EpaLocation, EpaLocation)
|
|
| 266 | + { sumPatParens :: AnnParen
|
|
| 267 | 267 | , sumPatVbarsBefore :: [EpToken "|"]
|
| 268 | 268 | , sumPatVbarsAfter :: [EpToken "|"]
|
| 269 | 269 | } deriving Data
|
| 270 | 270 | |
| 271 | 271 | instance NoAnn EpAnnSumPat where
|
| 272 | - noAnn = EpAnnSumPat (noAnn, noAnn) [] []
|
|
| 272 | + noAnn = EpAnnSumPat noAnn [] []
|
|
| 273 | 273 | |
| 274 | 274 | -- ---------------------------------------------------------------------
|
| 275 | 275 |
| ... | ... | @@ -445,7 +445,7 @@ type instance XQualTy (GhcPass _) = NoExtField |
| 445 | 445 | type instance XTyVar (GhcPass _) = EpToken "'"
|
| 446 | 446 | type instance XAppTy (GhcPass _) = NoExtField
|
| 447 | 447 | type instance XFunTy (GhcPass _) = NoExtField
|
| 448 | -type instance XListTy (GhcPass _) = AnnParen
|
|
| 448 | +type instance XListTy (GhcPass _) = (EpToken "[", EpToken "]")
|
|
| 449 | 449 | type instance XTupleTy (GhcPass _) = AnnParen
|
| 450 | 450 | type instance XSumTy (GhcPass _) = AnnParen
|
| 451 | 451 | type instance XOpTy (GhcPass _) = NoExtField
|
| ... | ... | @@ -470,7 +470,7 @@ type instance XExplicitListTy GhcPs = (EpToken "'", EpToken "[", EpToken "]") |
| 470 | 470 | type instance XExplicitListTy GhcRn = NoExtField
|
| 471 | 471 | type instance XExplicitListTy GhcTc = Kind
|
| 472 | 472 | |
| 473 | -type instance XExplicitTupleTy GhcPs = (EpToken "'", EpToken "(", EpToken ")")
|
|
| 473 | +type instance XExplicitTupleTy GhcPs = (EpToken "'", AnnParen)
|
|
| 474 | 474 | type instance XExplicitTupleTy GhcRn = NoExtField
|
| 475 | 475 | type instance XExplicitTupleTy GhcTc = [Kind]
|
| 476 | 476 |
| ... | ... | @@ -2398,14 +2398,14 @@ atype :: { LHsType GhcPs } |
| 2398 | 2398 | | '(' ktype ')' {% amsA' (sLL $1 $> $ HsParTy (epTok $1, epTok $3) $2) }
|
| 2399 | 2399 | -- see Note [Promotion] for the followings
|
| 2400 | 2400 | | SIMPLEQUOTE '(' ')' {% do { requireLTPuns PEP_QuoteDisambiguation $1 $>
|
| 2401 | - ; amsA' (sLL $1 $> $ HsExplicitTupleTy (epTok $1,epTok $2,epTok $3) IsPromoted []) }}
|
|
| 2401 | + ; amsA' (sLL $1 $> $ HsExplicitTupleTy (epTok $1, AnnParens (epTok $2) (epTok $3)) IsPromoted []) }}
|
|
| 2402 | 2402 | | SIMPLEQUOTE gen_qcon {% amsA' (sLL $1 $> $ HsTyVar (epTok $1) IsPromoted $2) }
|
| 2403 | 2403 | | SIMPLEQUOTE sysdcon_nolist {% do { requireLTPuns PEP_QuoteDisambiguation $1 (reLoc $>)
|
| 2404 | 2404 | ; amsA' (sLL $1 $> $ HsTyVar (epTok $1) IsPromoted (L (getLoc $2) $ nameRdrName (dataConName (unLoc $2)))) }}
|
| 2405 | 2405 | | SIMPLEQUOTE '(' ktype ',' comma_types1 ')'
|
| 2406 | 2406 | {% do { requireLTPuns PEP_QuoteDisambiguation $1 $>
|
| 2407 | 2407 | ; h <- addTrailingCommaA $3 (epTok $4)
|
| 2408 | - ; amsA' (sLL $1 $> $ HsExplicitTupleTy (epTok $1,epTok $2,epTok $6) IsPromoted (h : $5)) }}
|
|
| 2408 | + ; amsA' (sLL $1 $> $ HsExplicitTupleTy (epTok $1, AnnParens (epTok $2) (epTok $6)) IsPromoted (h : $5)) }}
|
|
| 2409 | 2409 | | '[' ']' {% withCombinedComments $1 $> (mkListSyntaxTy0 (epTok $1) (epTok $2)) }
|
| 2410 | 2410 | | SIMPLEQUOTE '[' comma_types0 ']' {% do { requireLTPuns PEP_QuoteDisambiguation $1 $>
|
| 2411 | 2411 | ; amsA' (sLL $1 $> $ HsExplicitListTy (epTok $1, epTok $2, epTok $4) IsPromoted $3) }}
|
| ... | ... | @@ -3221,7 +3221,7 @@ aexp2 :: { ECP } |
| 3221 | 3221 | | '(' tup_exprs ')' { ECP $
|
| 3222 | 3222 | $2 >>= \ $2 ->
|
| 3223 | 3223 | mkSumOrTuplePV (noAnnSrcSpan $ comb2 $1 $>) Boxed $2
|
| 3224 | - (glR $1,glR $3)}
|
|
| 3224 | + (AnnParens (epTok $1) (epTok $3))}
|
|
| 3225 | 3225 | |
| 3226 | 3226 | | '(' orpats(exp2) ')' {% do
|
| 3227 | 3227 | { pat <- hintOrPats (sL1a $2 (OrPat NoExtField (unLoc $2)))
|
| ... | ... | @@ -3237,11 +3237,11 @@ aexp2 :: { ECP } |
| 3237 | 3237 | | '(#' texp '#)' { ECP $
|
| 3238 | 3238 | unECP $2 >>= \ $2 ->
|
| 3239 | 3239 | mkSumOrTuplePV (noAnnSrcSpan $ comb2 $1 $>) Unboxed (Tuple [Right $2])
|
| 3240 | - (glR $1,glR $3) }
|
|
| 3240 | + (AnnParensHash (epTok $1) (epTok $3)) }
|
|
| 3241 | 3241 | | '(#' tup_exprs '#)' { ECP $
|
| 3242 | 3242 | $2 >>= \ $2 ->
|
| 3243 | 3243 | mkSumOrTuplePV (noAnnSrcSpan $ comb2 $1 $>) Unboxed $2
|
| 3244 | - (glR $1,glR $3) }
|
|
| 3244 | + (AnnParensHash (epTok $1) (epTok $3)) }
|
|
| 3245 | 3245 | |
| 3246 | 3246 | | '[' list ']' { ECP $ $2 (comb2 $1 $>) (glR $1,glR $3) }
|
| 3247 | 3247 | | '_' { ECP $ mkHsWildCardPV (getLoc $1) }
|
| ... | ... | @@ -552,12 +552,11 @@ data AnnListBrackets |
| 552 | 552 | -- Annotations for parenthesised elements, such as tuples, lists
|
| 553 | 553 | -- ---------------------------------------------------------------------
|
| 554 | 554 | |
| 555 | --- | exact print annotation for an item having surrounding "brackets", such as
|
|
| 556 | --- tuples or lists
|
|
| 555 | +-- | exact print annotation for an item having parentheses, with or without
|
|
| 556 | +-- the hash symbol, e.g. tuples, unboxed tuples, unboxed sums
|
|
| 557 | 557 | data AnnParen
|
| 558 | 558 | = AnnParens (EpToken "(") (EpToken ")") -- ^ '(', ')'
|
| 559 | 559 | | AnnParensHash (EpToken "(#") (EpToken "#)") -- ^ '(#', '#)'
|
| 560 | - | AnnParensSquare (EpToken "[") (EpToken "]") -- ^ '[', ']'
|
|
| 561 | 560 | deriving Data
|
| 562 | 561 | |
| 563 | 562 | -- ---------------------------------------------------------------------
|
| ... | ... | @@ -1219,7 +1218,6 @@ instance (Outputable e) |
| 1219 | 1218 | instance Outputable AnnParen where
|
| 1220 | 1219 | ppr (AnnParens o c) = text "AnnParens" <+> ppr o <+> ppr c
|
| 1221 | 1220 | ppr (AnnParensHash o c) = text "AnnParensHash" <+> ppr o <+> ppr c
|
| 1222 | - ppr (AnnParensSquare o c) = text "AnnParensSquare" <+> ppr o <+> ppr c
|
|
| 1223 | 1221 | |
| 1224 | 1222 | instance Outputable AnnListItem where
|
| 1225 | 1223 | ppr (AnnListItem ts) = text "AnnListItem" <+> ppr ts
|
| ... | ... | @@ -1228,17 +1228,11 @@ checkContext orig_t@(L (EpAnn l _ cs) _orig_t) = |
| 1228 | 1228 | -- With NoListTuplePuns, contexts are parsed as data constructors, which causes failure
|
| 1229 | 1229 | -- downstream.
|
| 1230 | 1230 | -- This converts them just like when they are parsed as types in the punned case.
|
| 1231 | - check (oparens,cparens,cs) (L _l (HsExplicitTupleTy (q,o,c) _ ts))
|
|
| 1232 | - = punsAllowed >>= \case
|
|
| 1233 | - True -> unprocessed
|
|
| 1234 | - False -> do
|
|
| 1235 | - let
|
|
| 1236 | - (op, cp) = case q of
|
|
| 1237 | - EpTok ql -> ([EpTok ql], [c])
|
|
| 1238 | - _ -> ([o], [c])
|
|
| 1239 | - mkCTuple (oparens ++ op, cp ++ cparens, cs) ts
|
|
| 1231 | + check (oparens,cparens,cs) (L _l (HsExplicitTupleTy (_, AnnParens o c) NotPromoted ts))
|
|
| 1232 | + = mkCTuple (oparens ++ [o], c : cparens, cs) ts
|
|
| 1233 | + |
|
| 1240 | 1234 | check (opi,cpi,csi) (L _lp1 (HsParTy (o,c) ty))
|
| 1241 | - -- to be sure HsParTy doesn't get into the way
|
|
| 1235 | + -- to be sure HsParTy doesn't get in the way
|
|
| 1242 | 1236 | = check (o:opi, c:cpi, csi) ty
|
| 1243 | 1237 | |
| 1244 | 1238 | -- No need for anns, returning original
|
| ... | ... | @@ -1269,11 +1263,10 @@ checkContextExpr orig_expr@(L (EpAnn l _ cs) _) = |
| 1269 | 1263 | where
|
| 1270 | 1264 | check :: ([EpToken "("],[EpToken ")"],EpAnnComments)
|
| 1271 | 1265 | -> LHsExpr GhcPs -> PV (LocatedC [LHsExpr GhcPs])
|
| 1272 | - check (oparens,cparens,cs) (L _ (ExplicitTuple (ap_open, ap_close) tup_args boxity))
|
|
| 1266 | + check (oparens,cparens,cs) (L _ (ExplicitTuple (AnnParens open_tok close_tok) tup_args Boxed))
|
|
| 1273 | 1267 | -- Neither unboxed tuples (#e1,e2#) nor tuple sections (e1,,e2,) can be a context
|
| 1274 | - | isBoxed boxity
|
|
| 1275 | - , Just es <- tupArgsPresent_maybe tup_args
|
|
| 1276 | - = mkCTuple (oparens ++ [EpTok ap_open], EpTok ap_close : cparens, cs) es
|
|
| 1268 | + | Just es <- tupArgsPresent_maybe tup_args
|
|
| 1269 | + = mkCTuple (oparens ++ [open_tok], close_tok : cparens, cs) es
|
|
| 1277 | 1270 | check (opi, cpi, csi) (L _ (HsPar (open_tok, close_tok) expr))
|
| 1278 | 1271 | = check (opi ++ [open_tok], close_tok : cpi, csi) expr
|
| 1279 | 1272 | check (oparens,cparens,cs) (L _ (HsVar _ (L (EpAnn _ (NameAnnOnly (NameParens open closed) []) _) name)))
|
| ... | ... | @@ -1861,7 +1854,7 @@ class (b ~ (Body b) GhcPs, AnnoBody b) => DisambECP b where |
| 1861 | 1854 | mkHsBangPatPV :: SrcSpan -> LocatedA b -> EpToken "!" -> PV (LocatedA b)
|
| 1862 | 1855 | -- | Disambiguate tuple sections and unboxed sums
|
| 1863 | 1856 | mkSumOrTuplePV
|
| 1864 | - :: SrcSpanAnnA -> Boxity -> SumOrTuple b -> (EpaLocation, EpaLocation) -> PV (LocatedA b)
|
|
| 1857 | + :: SrcSpanAnnA -> Boxity -> SumOrTuple b -> AnnParen -> PV (LocatedA b)
|
|
| 1865 | 1858 | -- | Disambiguate "type t" (embedded type)
|
| 1866 | 1859 | mkHsEmbTyPV :: SrcSpan -> EpToken "type" -> LHsType GhcPs -> PV (LocatedA b)
|
| 1867 | 1860 | -- | Disambiguate modifiers (%a)
|
| ... | ... | @@ -3694,7 +3687,7 @@ hintBangPat span e = do |
| 3694 | 3687 | addError $ mkPlainErrorMsgEnvelope span $ PsErrIllegalBangPattern e
|
| 3695 | 3688 | |
| 3696 | 3689 | mkSumOrTupleExpr :: SrcSpanAnnA -> Boxity -> SumOrTuple (HsExpr GhcPs)
|
| 3697 | - -> (EpaLocation, EpaLocation)
|
|
| 3690 | + -> AnnParen
|
|
| 3698 | 3691 | -> PV (LHsExpr GhcPs)
|
| 3699 | 3692 | |
| 3700 | 3693 | -- Tuple
|
| ... | ... | @@ -3709,15 +3702,15 @@ mkSumOrTupleExpr l@(EpAnn anc an csIn) boxity (Tuple es) anns = do |
| 3709 | 3702 | -- Sum
|
| 3710 | 3703 | -- mkSumOrTupleExpr l Unboxed (Sum alt arity e) =
|
| 3711 | 3704 | -- return $ L l (ExplicitSum noExtField alt arity e)
|
| 3712 | -mkSumOrTupleExpr l@(EpAnn anc anIn csIn) Unboxed (Sum alt arity e barsp barsa) (o, c) = do
|
|
| 3713 | - let an = AnnExplicitSum o barsp barsa c
|
|
| 3705 | +mkSumOrTupleExpr l@(EpAnn anc anIn csIn) Unboxed (Sum alt arity e barsp barsa) anns = do
|
|
| 3706 | + let an = AnnExplicitSum anns barsp barsa
|
|
| 3714 | 3707 | !cs <- getCommentsFor (locA l)
|
| 3715 | 3708 | return $ L (EpAnn anc anIn (csIn Semi.<> cs)) (ExplicitSum an alt arity e)
|
| 3716 | 3709 | mkSumOrTupleExpr l Boxed a@Sum{} _ =
|
| 3717 | 3710 | addFatalError $ mkPlainErrorMsgEnvelope (locA l) $ PsErrUnsupportedBoxedSumExpr a
|
| 3718 | 3711 | |
| 3719 | 3712 | mkSumOrTuplePat
|
| 3720 | - :: SrcSpanAnnA -> Boxity -> SumOrTuple (PatBuilder GhcPs) -> (EpaLocation, EpaLocation)
|
|
| 3713 | + :: SrcSpanAnnA -> Boxity -> SumOrTuple (PatBuilder GhcPs) -> AnnParen
|
|
| 3721 | 3714 | -> PV (LocatedA (PatBuilder GhcPs))
|
| 3722 | 3715 | |
| 3723 | 3716 | -- Tuple
|
| ... | ... | @@ -3843,7 +3836,7 @@ mkTupleSyntaxTy parOpen args parClose = |
| 3843 | 3836 | HsExplicitTupleTy annsKeyword NotPromoted args
|
| 3844 | 3837 | |
| 3845 | 3838 | annParen = AnnParens parOpen parClose
|
| 3846 | - annsKeyword = (NoEpTok, parOpen, parClose)
|
|
| 3839 | + annsKeyword = (NoEpTok, annParen)
|
|
| 3847 | 3840 | |
| 3848 | 3841 | -- | Decide whether to parse tuple con syntax @(,)@ in a type as a
|
| 3849 | 3842 | -- type or data constructor, based on the extension @ListTuplePuns@.
|
| ... | ... | @@ -3895,7 +3888,7 @@ mkListSyntaxTy1 brkOpen t brkClose = |
| 3895 | 3888 | HsExplicitListTy annsKeyword NotPromoted [t]
|
| 3896 | 3889 | |
| 3897 | 3890 | annsKeyword = (NoEpTok, brkOpen, brkClose)
|
| 3898 | - annParen = AnnParensSquare brkOpen brkClose
|
|
| 3891 | + annParen = (brkOpen, brkClose)
|
|
| 3899 | 3892 | |
| 3900 | 3893 | parseError :: HsExpr GhcPs
|
| 3901 | 3894 | parseError = HsHole HoleError
|
| ... | ... | @@ -85,7 +85,7 @@ import GHC.Internal.Read (expectP, list, paren, readField) |
| 85 | 85 | import GHC.Internal.Show (appPrec)
|
| 86 | 86 | |
| 87 | 87 | import GHC.Internal.Text.ParserCombinators.ReadPrec (ReadPrec, readPrec_to_S, readS_to_Prec, pfail)
|
| 88 | -import GHC.Internal.Text.Read (Read(..), parens, prec, step, reset)
|
|
| 88 | +import Text.Read (Read(..), parens, prec, step, reset)
|
|
| 89 | 89 | import GHC.Internal.Text.Read.Lex (Lexeme(..))
|
| 90 | 90 | import GHC.Internal.Text.Show (showListWith)
|
| 91 | 91 | import Prelude
|
| ... | ... | @@ -35,7 +35,7 @@ import GHC.Internal.Data.Foldable (Foldable(..)) |
| 35 | 35 | import GHC.Internal.Data.Monoid (Sum(..), All(..), Any(..), Product(..))
|
| 36 | 36 | import GHC.Internal.Data.Type.Equality (TestEquality(..), (:~:)(..))
|
| 37 | 37 | import GHC.Generics (Generic, Generic1)
|
| 38 | -import GHC.Internal.Text.Read (Read(..), ReadPrec, readListDefault, readListPrecDefault)
|
|
| 38 | +import Text.Read (Read(..), ReadPrec, readListDefault, readListPrecDefault)
|
|
| 39 | 39 | import Prelude
|
| 40 | 40 | |
| 41 | 41 | infixr 9 `Compose`
|
| ... | ... | @@ -179,7 +179,7 @@ import GHC.Internal.Data.Tuple |
| 179 | 179 | import GHC.Internal.Base hiding ( foldr, mapM, sequence )
|
| 180 | 180 | import GHC.Internal.Classes
|
| 181 | 181 | import GHC.Internal.Err
|
| 182 | -import GHC.Internal.Text.Read
|
|
| 182 | +import Text.Read
|
|
| 183 | 183 | import GHC.Internal.Enum
|
| 184 | 184 | import GHC.Internal.Num
|
| 185 | 185 | import GHC.Internal.Prim (seq)
|
| ... | ... | @@ -39,5 +39,84 @@ module Text.Read |
| 39 | 39 | readMaybe
|
| 40 | 40 | ) where
|
| 41 | 41 | |
| 42 | -import GHC.Internal.Text.Read
|
|
| 42 | +import GHC.Err (errorWithoutStackTrace)
|
|
| 43 | +import GHC.Read
|
|
| 44 | + (
|
|
| 45 | + ReadS,
|
|
| 46 | + Read (readsPrec, readList, readPrec, readListPrec),
|
|
| 47 | + lex,
|
|
| 48 | + readParen,
|
|
| 49 | + readListDefault,
|
|
| 50 | + lexP,
|
|
| 51 | + parens,
|
|
| 52 | + readListPrecDefault
|
|
| 53 | + )
|
|
| 54 | +import Control.Monad (return)
|
|
| 55 | +import Data.Function (id)
|
|
| 56 | +import Data.Maybe (Maybe (Nothing, Just))
|
|
| 57 | +import Data.Either (Either (Left, Right), either)
|
|
| 58 | +import Data.String (String)
|
|
| 59 | +import Text.Read.Lex (Lexeme (Char, String, Punc, Ident, Symbol, Number, EOF))
|
|
| 60 | +import Text.ParserCombinators.ReadP (skipSpaces)
|
|
| 43 | 61 | import Text.ParserCombinators.ReadPrec
|
| 62 | + |
|
| 63 | +-- $setup
|
|
| 64 | +-- >>> import Prelude
|
|
| 65 | + |
|
| 66 | +------------------------------------------------------------------------
|
|
| 67 | +-- utility functions
|
|
| 68 | + |
|
| 69 | +-- | equivalent to 'readsPrec' with a precedence of 0.
|
|
| 70 | +reads :: Read a => ReadS a
|
|
| 71 | +reads = readsPrec minPrec
|
|
| 72 | + |
|
| 73 | +-- | Parse a string using the 'Read' instance.
|
|
| 74 | +-- Succeeds if there is exactly one valid result.
|
|
| 75 | +-- A 'Left' value indicates a parse error.
|
|
| 76 | +--
|
|
| 77 | +-- >>> readEither "123" :: Either String Int
|
|
| 78 | +-- Right 123
|
|
| 79 | +--
|
|
| 80 | +-- >>> readEither "hello" :: Either String Int
|
|
| 81 | +-- Left "Prelude.read: no parse"
|
|
| 82 | +--
|
|
| 83 | +-- @since base-4.6.0.0
|
|
| 84 | +readEither :: Read a => String -> Either String a
|
|
| 85 | +readEither s =
|
|
| 86 | + case [ x | (x,"") <- readPrec_to_S read' minPrec s ] of
|
|
| 87 | + [x] -> Right x
|
|
| 88 | + [] -> Left "Prelude.read: no parse"
|
|
| 89 | + _ -> Left "Prelude.read: ambiguous parse"
|
|
| 90 | + where
|
|
| 91 | + read' =
|
|
| 92 | + do x <- readPrec
|
|
| 93 | + lift skipSpaces
|
|
| 94 | + return x
|
|
| 95 | + |
|
| 96 | +-- | Parse a string using the 'Read' instance.
|
|
| 97 | +-- Succeeds if there is exactly one valid result.
|
|
| 98 | +--
|
|
| 99 | +-- >>> readMaybe "123" :: Maybe Int
|
|
| 100 | +-- Just 123
|
|
| 101 | +--
|
|
| 102 | +-- >>> readMaybe "hello" :: Maybe Int
|
|
| 103 | +-- Nothing
|
|
| 104 | +--
|
|
| 105 | +-- @since base-4.6.0.0
|
|
| 106 | +readMaybe :: Read a => String -> Maybe a
|
|
| 107 | +readMaybe s = case readEither s of
|
|
| 108 | + Left _ -> Nothing
|
|
| 109 | + Right a -> Just a
|
|
| 110 | + |
|
| 111 | +-- | The 'read' function reads input from a string, which must be
|
|
| 112 | +-- completely consumed by the input process. 'read' fails with an 'error' if the
|
|
| 113 | +-- parse is unsuccessful, and it is therefore discouraged from being used in
|
|
| 114 | +-- real applications. Use 'readMaybe' or 'readEither' for safe alternatives.
|
|
| 115 | +--
|
|
| 116 | +-- >>> read "123" :: Int
|
|
| 117 | +-- 123
|
|
| 118 | +--
|
|
| 119 | +-- >>> read "hello" :: Int
|
|
| 120 | +-- *** Exception: Prelude.read: no parse
|
|
| 121 | +read :: Read a => String -> a
|
|
| 122 | +read s = either errorWithoutStackTrace id (readEither s) |
| ... | ... | @@ -329,7 +329,6 @@ Library |
| 329 | 329 | GHC.Internal.System.Posix.Types
|
| 330 | 330 | GHC.Internal.Text.ParserCombinators.ReadP
|
| 331 | 331 | GHC.Internal.Text.ParserCombinators.ReadPrec
|
| 332 | - GHC.Internal.Text.Read
|
|
| 333 | 332 | GHC.Internal.Text.Read.Lex
|
| 334 | 333 | GHC.Internal.Text.Show
|
| 335 | 334 | GHC.Internal.Type.Reflection
|
| ... | ... | @@ -46,7 +46,7 @@ import GHC.Internal.IO.Encoding.Types |
| 46 | 46 | import qualified GHC.Internal.IO.Encoding.Iconv as Iconv
|
| 47 | 47 | #else
|
| 48 | 48 | import qualified GHC.Internal.IO.Encoding.CodePage as CodePage
|
| 49 | -import GHC.Internal.Text.Read (reads)
|
|
| 49 | +import GHC.Internal.Read (readsPrec)
|
|
| 50 | 50 | #endif
|
| 51 | 51 | import qualified GHC.Internal.IO.Encoding.Latin1 as Latin1
|
| 52 | 52 | import qualified GHC.Internal.IO.Encoding.UTF8 as UTF8
|
| ... | ... | @@ -319,7 +319,8 @@ mkTextEncoding' cfm enc = |
| 319 | 319 | _ | isAscii -> return (Latin1.mkAscii cfm)
|
| 320 | 320 | _ | isLatin1 -> return (Latin1.mkLatin1_checked cfm)
|
| 321 | 321 | #if defined(mingw32_HOST_OS)
|
| 322 | - 'C':'P':n | [(cp,"")] <- reads n -> return $ CodePage.mkCodePageEncoding cfm cp
|
|
| 322 | + 'C':'P':n | [(cp,"")] <- readsPrec 0 n -> return $ CodePage.mkCodePageEncoding cfm cp
|
|
| 323 | + -- 'readsPrec 0' is the same as 'reads', but 'reads' is only defined in @base@.
|
|
| 323 | 324 | _ -> unknownEncodingErr (enc ++ codingFailureModeSuffix cfm)
|
| 324 | 325 | #else
|
| 325 | 326 | -- Otherwise, handle other encoding needs via iconv.
|
| 1 | -{-# LANGUAGE Trustworthy #-}
|
|
| 2 | -{-# LANGUAGE NoImplicitPrelude #-}
|
|
| 3 | - |
|
| 4 | ------------------------------------------------------------------------------
|
|
| 5 | --- |
|
|
| 6 | --- Module : GHC.Internal.Text.Read
|
|
| 7 | --- Copyright : (c) The University of Glasgow 2001
|
|
| 8 | --- License : BSD-style (see the file libraries/base/LICENSE)
|
|
| 9 | ---
|
|
| 10 | --- Maintainer : libraries@haskell.org
|
|
| 11 | --- Stability : provisional
|
|
| 12 | --- Portability : non-portable (uses Text.ParserCombinators.ReadP)
|
|
| 13 | ---
|
|
| 14 | --- Converting strings to values.
|
|
| 15 | ---
|
|
| 16 | --- The "Text.Read" library is the canonical library to import for
|
|
| 17 | --- 'Read'-class facilities. For GHC only, it offers an extended and much
|
|
| 18 | --- improved 'Read' class, which constitutes a proposed alternative to the
|
|
| 19 | --- Haskell 2010 'Read'. In particular, writing parsers is easier, and
|
|
| 20 | --- the parsers are much more efficient.
|
|
| 21 | ---
|
|
| 22 | ------------------------------------------------------------------------------
|
|
| 23 | - |
|
| 24 | -module GHC.Internal.Text.Read (
|
|
| 25 | - -- * The 'Read' class
|
|
| 26 | - Read(..),
|
|
| 27 | - ReadS,
|
|
| 28 | - |
|
| 29 | - -- * Haskell 2010 functions
|
|
| 30 | - reads,
|
|
| 31 | - read,
|
|
| 32 | - readParen,
|
|
| 33 | - lex,
|
|
| 34 | - |
|
| 35 | - -- * New parsing functions
|
|
| 36 | - module GHC.Internal.Text.ParserCombinators.ReadPrec,
|
|
| 37 | - L.Lexeme(..),
|
|
| 38 | - lexP,
|
|
| 39 | - parens,
|
|
| 40 | - readListDefault,
|
|
| 41 | - readListPrecDefault,
|
|
| 42 | - readEither,
|
|
| 43 | - readMaybe
|
|
| 44 | - |
|
| 45 | - ) where
|
|
| 46 | - |
|
| 47 | -import GHC.Internal.Base (String, id, return)
|
|
| 48 | -import GHC.Internal.Err (errorWithoutStackTrace)
|
|
| 49 | -import GHC.Internal.Maybe (Maybe(..))
|
|
| 50 | -import GHC.Internal.Read
|
|
| 51 | -import GHC.Internal.Data.Either
|
|
| 52 | -import GHC.Internal.Text.ParserCombinators.ReadP as P
|
|
| 53 | -import GHC.Internal.Text.ParserCombinators.ReadPrec
|
|
| 54 | -import qualified GHC.Internal.Text.Read.Lex as L
|
|
| 55 | - |
|
| 56 | --- $setup
|
|
| 57 | --- >>> import Prelude
|
|
| 58 | - |
|
| 59 | -------------------------------------------------------------------------
|
|
| 60 | --- utility functions
|
|
| 61 | - |
|
| 62 | --- | equivalent to 'readsPrec' with a precedence of 0.
|
|
| 63 | -reads :: Read a => ReadS a
|
|
| 64 | -reads = readsPrec minPrec
|
|
| 65 | - |
|
| 66 | --- | Parse a string using the 'Read' instance.
|
|
| 67 | --- Succeeds if there is exactly one valid result.
|
|
| 68 | --- A 'Left' value indicates a parse error.
|
|
| 69 | ---
|
|
| 70 | --- >>> readEither "123" :: Either String Int
|
|
| 71 | --- Right 123
|
|
| 72 | ---
|
|
| 73 | --- >>> readEither "hello" :: Either String Int
|
|
| 74 | --- Left "Prelude.read: no parse"
|
|
| 75 | ---
|
|
| 76 | --- @since base-4.6.0.0
|
|
| 77 | -readEither :: Read a => String -> Either String a
|
|
| 78 | -readEither s =
|
|
| 79 | - case [ x | (x,"") <- readPrec_to_S read' minPrec s ] of
|
|
| 80 | - [x] -> Right x
|
|
| 81 | - [] -> Left "Prelude.read: no parse"
|
|
| 82 | - _ -> Left "Prelude.read: ambiguous parse"
|
|
| 83 | - where
|
|
| 84 | - read' =
|
|
| 85 | - do x <- readPrec
|
|
| 86 | - lift P.skipSpaces
|
|
| 87 | - return x
|
|
| 88 | - |
|
| 89 | --- | Parse a string using the 'Read' instance.
|
|
| 90 | --- Succeeds if there is exactly one valid result.
|
|
| 91 | ---
|
|
| 92 | --- >>> readMaybe "123" :: Maybe Int
|
|
| 93 | --- Just 123
|
|
| 94 | ---
|
|
| 95 | --- >>> readMaybe "hello" :: Maybe Int
|
|
| 96 | --- Nothing
|
|
| 97 | ---
|
|
| 98 | --- @since base-4.6.0.0
|
|
| 99 | -readMaybe :: Read a => String -> Maybe a
|
|
| 100 | -readMaybe s = case readEither s of
|
|
| 101 | - Left _ -> Nothing
|
|
| 102 | - Right a -> Just a
|
|
| 103 | - |
|
| 104 | --- | The 'read' function reads input from a string, which must be
|
|
| 105 | --- completely consumed by the input process. 'read' fails with an 'error' if the
|
|
| 106 | --- parse is unsuccessful, and it is therefore discouraged from being used in
|
|
| 107 | --- real applications. Use 'readMaybe' or 'readEither' for safe alternatives.
|
|
| 108 | ---
|
|
| 109 | --- >>> read "123" :: Int
|
|
| 110 | --- 123
|
|
| 111 | ---
|
|
| 112 | --- >>> read "hello" :: Int
|
|
| 113 | --- *** Exception: Prelude.read: no parse
|
|
| 114 | -read :: Read a => String -> a
|
|
| 115 | -read s = either errorWithoutStackTrace id (readEither s) |
| ... | ... | @@ -18,8 +18,8 @@ X(ExplicitList) mismatch |
| 18 | 18 | >>> AnnList ()
|
| 19 | 19 | <<< ((EpToken "'"),(EpToken "["),(EpToken "]"))
|
| 20 | 20 | X(ExplicitTuple) mismatch
|
| 21 | - >>> ((EpaLocation' [GenLocated (EpaLocation' NoComments) EpaComment]),(EpaLocation' [GenLocated (EpaLocation' NoComments) EpaComment]))
|
|
| 22 | - <<< ((EpToken "'"),(EpToken "("),(EpToken ")"))
|
|
| 21 | + >>> AnnParen
|
|
| 22 | + <<< ((EpToken "'"),AnnParen)
|
|
| 23 | 23 | X(Hole) match = HoleKind
|
| 24 | 24 | |
| 25 | 25 | Extension fields @GhcRn
|
| 1 | +download-base-exports |
| 1 | 1 | # Interface stability testing
|
| 2 | 2 | |
| 3 | -The tests in this directory verify that the interfaces of exposed by GHC's
|
|
| 3 | +The tests in this directory verify that the interfaces exposed by GHC's
|
|
| 4 | 4 | core libraries do not inadvertently change. They use the `utils/dump-decls`
|
| 5 | 5 | utility to dump all exported declarations of all exposed modules for the
|
| 6 | 6 | following packages:
|
| ... | ... | @@ -27,7 +27,9 @@ The `base-exports` test in particular has rather platform-dependent output. |
| 27 | 27 | Consequently, updating its output can be a bit tricky. There are two ways by
|
| 28 | 28 | which one can do this:
|
| 29 | 29 | |
| 30 | - * Extrapolation: The various platforms' `base-exports.stdout` files are
|
|
| 30 | +#### Extrapolation
|
|
| 31 | + |
|
| 32 | +The various platforms' `base-exports.stdout` files are
|
|
| 31 | 33 | similar enough that one can often apply the same patch of one file to the
|
| 32 | 34 | others. For instance:
|
| 33 | 35 | ```
|
| ... | ... | @@ -40,8 +42,44 @@ which one can do this: |
| 40 | 42 | In the case of conflicts, increasing the fuzz factor (using `-F`) can be
|
| 41 | 43 | quite effective.
|
| 42 | 44 | |
| 43 | - * Using CI: Each CI job produces a tarball, `unexpected-test-output.tar.gz`,
|
|
| 45 | +#### Using CI
|
|
| 46 | + |
|
| 47 | +Each CI job produces a tarball, `unexpected-test-output.tar.gz`,
|
|
| 44 | 48 | which contains the output produced by the job's failing tests. Simply
|
| 45 | - download this tarball and extracting the appropriate `base-exports.stdout-*`
|
|
| 49 | + download this tarball and extract the appropriate `base-exports.stdout-*`
|
|
| 46 | 50 | files into this directory.
|
| 47 | 51 | |
| 52 | +Doing this by hand is of course very annoying. To make things faster, use the script in this folder called `download.base-exports.sh` :
|
|
| 53 | + |
|
| 54 | +* Running for the first time
|
|
| 55 | + 1. Find the URL for downloading unexpected-test-output.tar.gz. To do so
|
|
| 56 | + * Go to the CI job page you want to download
|
|
| 57 | + * Click on "Browse"
|
|
| 58 | + * Find unexpected-test-output.tar.gz
|
|
| 59 | + * Right-click the download link then "Copy link" (Firefox)
|
|
| 60 | + 2. The URL should look like this :
|
|
| 61 | + `https://gitlab.haskell.org/ghc/ghc/-/jobs/2503744/artifacts/file/unexpected-test-output.tar.gz`
|
|
| 62 | + * the prefix is : `https://gitlab.haskell.org/ghc/ghc/-/jobs/`
|
|
| 63 | + * the job ID is : `2503744`
|
|
| 64 | + * and the suffix : `/artifacts/file/unexpected-test-output.tar.gz`
|
|
| 65 | + 3. The script prompts you with URL prefix and suffix.
|
|
| 66 | + 4. It will save a file to remember this, so you only need to do this once.
|
|
| 67 | + 5. If you need to change the URL, just edit the file `download-base-exports/url-unexpected-test-output` directly.
|
|
| 68 | + |
|
| 69 | +* Downloading the artifacts
|
|
| 70 | + 1. Find all the job IDs you want to download. For this, just go to the jobs
|
|
| 71 | + page `https://gitlab.haskell.org/<YOUR-FORK>/ghc/-/jobs`
|
|
| 72 | + 2. Make sure you get all the artifacts. You need 3 of them.
|
|
| 73 | + To get all 3 CI jobs, the label `javascript` must be on the MR.
|
|
| 74 | + If you don't have the rights for adding these labels, ask.
|
|
| 75 | + 1. The `x86` CI job for darwin or linux : `base-exports.stdout`
|
|
| 76 | + 2. The `windows` job : `base-exports.stdout-mingw32`
|
|
| 77 | + 3. The `javascript` CI job :
|
|
| 78 | + `base-exports.stdout-javascript-unknown-ghcjs`
|
|
| 79 | + 3. Run the script with all the job IDs :
|
|
| 80 | + `./download-base-exports.sh 2502789 2502792 2502793`
|
|
| 81 | + |
|
| 82 | + Using a range downloads more artifacts than necessary, but is a
|
|
| 83 | + no-brainer:
|
|
| 84 | + |
|
| 85 | + `./download-base-exports.sh {2502789..2502795}` |
| 1 | +#!/usr/bin/env bash
|
|
| 2 | + |
|
| 3 | +# See the README file in this folder for usage
|
|
| 4 | + |
|
| 5 | +jobIDs=("$@")
|
|
| 6 | + |
|
| 7 | +BASE_DIR_NAME=download-base-exports
|
|
| 8 | +DL_DIR_NAME=dl
|
|
| 9 | +BASE_DIR="$(dirname "$0")/$BASE_DIR_NAME"
|
|
| 10 | +DL_DIR=$BASE_DIR/$DL_DIR_NAME
|
|
| 11 | +URL_FILE="$BASE_DIR/url-unexpected-test-output"
|
|
| 12 | + |
|
| 13 | +DEFAULT_PREFIX="https://gitlab.haskell.org/ghc/ghc/-/jobs/"
|
|
| 14 | +DEFAULT_POSTFIX="/artifacts/raw/unexpected-test-output.tar.gz"
|
|
| 15 | + |
|
| 16 | +mkdir -p "$BASE_DIR"
|
|
| 17 | + |
|
| 18 | +# URL configuration for finding unexpected-test-output.tar.gz
|
|
| 19 | + |
|
| 20 | +if [[ ! -f "$URL_FILE" ]]; then
|
|
| 21 | + echo "No URL for unexpected-test-output.tar.gz was found"
|
|
| 22 | + |
|
| 23 | + read -p "Enter job URL prefix [${DEFAULT_PREFIX}]: " inputPrefix
|
|
| 24 | + read -p "Enter job URL postfix [${DEFAULT_POSTFIX}]: " inputPostfix
|
|
| 25 | + |
|
| 26 | + urlPrefix="${inputPrefix:-$DEFAULT_PREFIX}"
|
|
| 27 | + urlPostfix="${inputPostfix:-$DEFAULT_POSTFIX}"
|
|
| 28 | + |
|
| 29 | + {
|
|
| 30 | + echo "urlPrefix=$urlPrefix"
|
|
| 31 | + echo "urlPostfix=$urlPostfix"
|
|
| 32 | + } > "$URL_FILE"
|
|
| 33 | +else
|
|
| 34 | + source "$URL_FILE"
|
|
| 35 | +fi
|
|
| 36 | + |
|
| 37 | +mkdir -p $DL_DIR
|
|
| 38 | + |
|
| 39 | +echo "urlPrefix: $urlPrefix"
|
|
| 40 | +echo "jobIDs: $jobIDs"
|
|
| 41 | +echo "urlPostfix: $urlPostfix"
|
|
| 42 | +echo ""
|
|
| 43 | +echo "Downloading unexpected-test-output.tar.gz for each job ..."
|
|
| 44 | + |
|
| 45 | +# Download and copy base-exports* files
|
|
| 46 | + |
|
| 47 | +for jobID in "${jobIDs[@]}"; do
|
|
| 48 | + unexpectedOutputUrl="$urlPrefix$jobID$urlPostfix"
|
|
| 49 | + |
|
| 50 | + wget -O "$DL_DIR/job$jobID.tar.gz" $unexpectedOutputUrl
|
|
| 51 | + |
|
| 52 | + mkdir -p "$DL_DIR/job$jobID"
|
|
| 53 | + tar -xzf "$DL_DIR/job$jobID.tar.gz" -C "$DL_DIR/job$jobID"
|
|
| 54 | + cp "$DL_DIR/job$jobID"/unexpected-test-output/testsuite/tests/interface-stability/base-exports* "$BASE_DIR/.."
|
|
| 55 | +done |
| ... | ... | @@ -274,7 +274,7 @@ |
| 274 | 274 | (EpaComments
|
| 275 | 275 | []))
|
| 276 | 276 | (HsListTy
|
| 277 | - (AnnParensSquare
|
|
| 277 | + ((,)
|
|
| 278 | 278 | (EpTok
|
| 279 | 279 | (EpaSpan { DumpParsedAst.hs:9:16 }))
|
| 280 | 280 | (EpTok
|
| ... | ... | @@ -656,7 +656,7 @@ |
| 656 | 656 | (EpaComments
|
| 657 | 657 | []))
|
| 658 | 658 | (HsListTy
|
| 659 | - (AnnParensSquare
|
|
| 659 | + ((,)
|
|
| 660 | 660 | (EpTok
|
| 661 | 661 | (EpaSpan { DumpParsedAst.hs:10:27 }))
|
| 662 | 662 | (EpTok
|
| ... | ... | @@ -602,7 +602,7 @@ |
| 602 | 602 | (EpaComments
|
| 603 | 603 | []))
|
| 604 | 604 | (HsListTy
|
| 605 | - (AnnParensSquare
|
|
| 605 | + ((,)
|
|
| 606 | 606 | (EpTok
|
| 607 | 607 | (EpaSpan { DumpRenamedAst.hs:12:27 }))
|
| 608 | 608 | (EpTok
|
| ... | ... | @@ -710,7 +710,7 @@ |
| 710 | 710 | (EpaComments
|
| 711 | 711 | []))
|
| 712 | 712 | (HsListTy
|
| 713 | - (AnnParensSquare
|
|
| 713 | + ((,)
|
|
| 714 | 714 | (EpTok
|
| 715 | 715 | (EpaSpan { DumpRenamedAst.hs:11:16 }))
|
| 716 | 716 | (EpTok
|
| ... | ... | @@ -1930,7 +1930,7 @@ |
| 1930 | 1930 | (EpaComments
|
| 1931 | 1931 | []))
|
| 1932 | 1932 | (HsListTy
|
| 1933 | - (AnnParensSquare
|
|
| 1933 | + ((,)
|
|
| 1934 | 1934 | (EpTok
|
| 1935 | 1935 | (EpaSpan { DumpRenamedAst.hs:31:12 }))
|
| 1936 | 1936 | (EpTok
|
| ... | ... | @@ -1995,7 +1995,7 @@ |
| 1995 | 1995 | (EpaComments
|
| 1996 | 1996 | []))
|
| 1997 | 1997 | (HsListTy
|
| 1998 | - (AnnParensSquare
|
|
| 1998 | + ((,)
|
|
| 1999 | 1999 | (EpTok
|
| 2000 | 2000 | (EpaSpan { DumpRenamedAst.hs:32:10 }))
|
| 2001 | 2001 | (EpTok
|
| ... | ... | @@ -728,7 +728,7 @@ |
| 728 | 728 | (EpaComments
|
| 729 | 729 | []))
|
| 730 | 730 | (HsListTy
|
| 731 | - (AnnParensSquare
|
|
| 731 | + ((,)
|
|
| 732 | 732 | (EpTok
|
| 733 | 733 | (EpaSpan { KindSigs.hs:19:12 }))
|
| 734 | 734 | (EpTok
|
| ... | ... | @@ -1424,13 +1424,14 @@ |
| 1424 | 1424 | (EpaComments
|
| 1425 | 1425 | []))
|
| 1426 | 1426 | (HsExplicitTupleTy
|
| 1427 | - ((,,)
|
|
| 1427 | + ((,)
|
|
| 1428 | 1428 | (EpTok
|
| 1429 | 1429 | (EpaSpan { KindSigs.hs:28:16 }))
|
| 1430 | - (EpTok
|
|
| 1431 | - (EpaSpan { KindSigs.hs:28:17 }))
|
|
| 1432 | - (EpTok
|
|
| 1433 | - (EpaSpan { KindSigs.hs:28:44 })))
|
|
| 1430 | + (AnnParens
|
|
| 1431 | + (EpTok
|
|
| 1432 | + (EpaSpan { KindSigs.hs:28:17 }))
|
|
| 1433 | + (EpTok
|
|
| 1434 | + (EpaSpan { KindSigs.hs:28:44 }))))
|
|
| 1434 | 1435 | (IsPromoted)
|
| 1435 | 1436 | [(L
|
| 1436 | 1437 | (EpAnn
|
| ... | ... | @@ -1508,7 +1509,7 @@ |
| 1508 | 1509 | (EpaComments
|
| 1509 | 1510 | []))
|
| 1510 | 1511 | (HsListTy
|
| 1511 | - (AnnParensSquare
|
|
| 1512 | + ((,)
|
|
| 1512 | 1513 | (EpTok
|
| 1513 | 1514 | (EpaSpan { KindSigs.hs:28:34 }))
|
| 1514 | 1515 | (EpTok
|
| ... | ... | @@ -458,7 +458,7 @@ |
| 458 | 458 | (EpaComments
|
| 459 | 459 | []))
|
| 460 | 460 | (HsListTy
|
| 461 | - (AnnParensSquare
|
|
| 461 | + ((,)
|
|
| 462 | 462 | (EpTok
|
| 463 | 463 | (EpaSpan { T20452.hs:8:57 }))
|
| 464 | 464 | (EpTok
|
| ... | ... | @@ -705,7 +705,7 @@ |
| 705 | 705 | (EpaComments
|
| 706 | 706 | []))
|
| 707 | 707 | (HsListTy
|
| 708 | - (AnnParensSquare
|
|
| 708 | + ((,)
|
|
| 709 | 709 | (EpTok
|
| 710 | 710 | (EpaSpan { T20452.hs:9:57 }))
|
| 711 | 711 | (EpTok
|
| ... | ... | @@ -3,6 +3,6 @@ pattern (:+_0) :: GHC.Internal.Types.Int -> |
| 3 | 3 | (GHC.Internal.Types.Int, GHC.Internal.Types.Int)
|
| 4 | 4 | pattern x_1 :+_0 y_2 = (x_1, y_2)
|
| 5 | 5 | pattern A_0 :: GHC.Internal.Types.Int -> GHC.Internal.Base.String
|
| 6 | -pattern A_0 n_1 <- (GHC.Internal.Text.Read.read -> n_1) where
|
|
| 6 | +pattern A_0 n_1 <- (Text.Read.read -> n_1) where
|
|
| 7 | 7 | A_0 0 = "hi"
|
| 8 | 8 | A_0 1 = "bye" |
| ... | ... | @@ -11,14 +11,13 @@ subsumption_sort_hole_fits.hs:2:5: warning: [GHC-88464] [-Wtyped-holes (in -Wdef |
| 11 | 11 | words :: String -> [String]
|
| 12 | 12 | (imported from ‘Prelude’
|
| 13 | 13 | (and originally defined in ‘GHC.Internal.Data.OldList’))
|
| 14 | - read :: forall a. Read a => String -> a
|
|
| 15 | - with read @[String]
|
|
| 16 | - (imported from ‘Prelude’
|
|
| 17 | - (and originally defined in ‘GHC.Internal.Text.Read’))
|
|
| 18 | 14 | repeat :: forall a. a -> [a]
|
| 19 | 15 | with repeat @String
|
| 20 | 16 | (imported from ‘Prelude’
|
| 21 | 17 | (and originally defined in ‘GHC.Internal.List’))
|
| 18 | + read :: forall a. Read a => String -> a
|
|
| 19 | + with read @[String]
|
|
| 20 | + (imported from ‘Prelude’ (and originally defined in ‘Text.Read’))
|
|
| 22 | 21 | mempty :: forall a. Monoid a => a
|
| 23 | 22 | with mempty @(String -> [String])
|
| 24 | 23 | (imported from ‘Prelude’
|
| ... | ... | @@ -6,6 +6,9 @@ T21130.hs:10:6: error: [GHC-88464] |
| 6 | 6 | In an equation for ‘x’: x = (_ f) :: Int
|
| 7 | 7 | • Relevant bindings include x :: Int (bound at T21130.hs:10:1)
|
| 8 | 8 | Valid hole fits include
|
| 9 | + read :: forall a. Read a => String -> a
|
|
| 10 | + with read @Int
|
|
| 11 | + (imported from ‘Prelude’ (and originally defined in ‘Text.Read’))
|
|
| 9 | 12 | head :: forall a. GHC.Internal.Stack.Types.HasCallStack => [a] -> a
|
| 10 | 13 | with head @Int
|
| 11 | 14 | (imported from ‘Prelude’
|
| ... | ... | @@ -14,10 +17,6 @@ T21130.hs:10:6: error: [GHC-88464] |
| 14 | 17 | with last @Int
|
| 15 | 18 | (imported from ‘Prelude’
|
| 16 | 19 | (and originally defined in ‘GHC.Internal.List’))
|
| 17 | - read :: forall a. Read a => String -> a
|
|
| 18 | - with read @Int
|
|
| 19 | - (imported from ‘Prelude’
|
|
| 20 | - (and originally defined in ‘GHC.Internal.Text.Read’))
|
|
| 21 | 20 | |
| 22 | 21 | T21130.hs:10:8: error: [GHC-39999]
|
| 23 | 22 | • Ambiguous type variable ‘t0’ arising from a use of ‘f’
|
| ... | ... | @@ -858,9 +858,6 @@ markParenO (AnnParens o c) = do |
| 858 | 858 | markParenO (AnnParensHash o c) = do
|
| 859 | 859 | o' <- markEpToken o
|
| 860 | 860 | return (AnnParensHash o' c)
|
| 861 | -markParenO (AnnParensSquare o c) = do
|
|
| 862 | - o' <- markEpToken o
|
|
| 863 | - return (AnnParensSquare o' c)
|
|
| 864 | 861 | |
| 865 | 862 | markParenC :: (Monad m, Monoid w) => AnnParen -> EP w m AnnParen
|
| 866 | 863 | markParenC (AnnParens o c) = do
|
| ... | ... | @@ -869,9 +866,6 @@ markParenC (AnnParens o c) = do |
| 869 | 866 | markParenC (AnnParensHash o c) = do
|
| 870 | 867 | c' <- markEpToken c
|
| 871 | 868 | return (AnnParensHash o c')
|
| 872 | -markParenC (AnnParensSquare o c) = do
|
|
| 873 | - c' <- markEpToken c
|
|
| 874 | - return (AnnParensSquare o c')
|
|
| 875 | 869 | |
| 876 | 870 | -- ---------------------------------------------------------------------
|
| 877 | 871 | -- Bare bones Optics
|
| ... | ... | @@ -1015,15 +1009,14 @@ lsnd k parent = fmap (\new -> (fst parent, new)) |
| 1015 | 1009 | -- -------------------------------------
|
| 1016 | 1010 | -- data AnnExplicitSum
|
| 1017 | 1011 | -- = AnnExplicitSum {
|
| 1018 | --- aesOpen :: EpaLocation,
|
|
| 1012 | +-- aesParens :: AnnParen,
|
|
| 1019 | 1013 | -- aesBarsBefore :: [EpToken "|"],
|
| 1020 | --- aesBarsAfter :: [EpToken "|"],
|
|
| 1021 | --- aesClose :: EpaLocation
|
|
| 1014 | +-- aesBarsAfter :: [EpToken "|"]
|
|
| 1022 | 1015 | -- } deriving Data
|
| 1023 | 1016 | |
| 1024 | -laesOpen :: Lens AnnExplicitSum EpaLocation
|
|
| 1025 | -laesOpen k parent = fmap (\new -> parent { aesOpen = new })
|
|
| 1026 | - (k (aesOpen parent))
|
|
| 1017 | +laesParens :: Lens AnnExplicitSum AnnParen
|
|
| 1018 | +laesParens k parent = fmap (\new -> parent { aesParens = new })
|
|
| 1019 | + (k (aesParens parent))
|
|
| 1027 | 1020 | |
| 1028 | 1021 | laesBarsBefore :: Lens AnnExplicitSum [EpToken "|"]
|
| 1029 | 1022 | laesBarsBefore k parent = fmap (\new -> parent { aesBarsBefore = new })
|
| ... | ... | @@ -1033,10 +1026,6 @@ laesBarsAfter :: Lens AnnExplicitSum [EpToken "|"] |
| 1033 | 1026 | laesBarsAfter k parent = fmap (\new -> parent { aesBarsAfter = new })
|
| 1034 | 1027 | (k (aesBarsAfter parent))
|
| 1035 | 1028 | |
| 1036 | -laesClose :: Lens AnnExplicitSum EpaLocation
|
|
| 1037 | -laesClose k parent = fmap (\new -> parent { aesClose = new })
|
|
| 1038 | - (k (aesClose parent))
|
|
| 1039 | - |
|
| 1040 | 1029 | -- -------------------------------------
|
| 1041 | 1030 | -- data AnnFieldLabel
|
| 1042 | 1031 | -- = AnnFieldLabel {
|
| ... | ... | @@ -1183,12 +1172,12 @@ lga_sep k parent = fmap (\new -> parent { ga_sep = new }) |
| 1183 | 1172 | |
| 1184 | 1173 | -- ---------------------------------------------------------------------
|
| 1185 | 1174 | -- data EpAnnSumPat = EpAnnSumPat
|
| 1186 | --- { sumPatParens :: (EpaLocation, EpaLocation)
|
|
| 1175 | +-- { sumPatParens :: AnnParen
|
|
| 1187 | 1176 | -- , sumPatVbarsBefore :: [EpToken "|"]
|
| 1188 | 1177 | -- , sumPatVbarsAfter :: [EpToken "|"]
|
| 1189 | 1178 | -- } deriving Data
|
| 1190 | 1179 | |
| 1191 | -lsumPatParens :: Lens EpAnnSumPat (EpaLocation, EpaLocation)
|
|
| 1180 | +lsumPatParens :: Lens EpAnnSumPat AnnParen
|
|
| 1192 | 1181 | lsumPatParens k parent = fmap (\new -> parent { sumPatParens = new })
|
| 1193 | 1182 | (k (sumPatParens parent))
|
| 1194 | 1183 | |
| ... | ... | @@ -2940,23 +2929,21 @@ instance ExactPrint (HsExpr GhcPs) where |
| 2940 | 2929 | expr' <- markAnnotated expr
|
| 2941 | 2930 | return (SectionR an op' expr')
|
| 2942 | 2931 | |
| 2943 | - exact (ExplicitTuple (o,c) args b) = do
|
|
| 2944 | - o0 <- if b == Boxed then printStringAtAA o "("
|
|
| 2945 | - else printStringAtAA o "(#"
|
|
| 2932 | + exact (ExplicitTuple an args b) = do
|
|
| 2933 | + an0 <- markOpeningParen an
|
|
| 2946 | 2934 | |
| 2947 | 2935 | args' <- mapM markAnnotated args
|
| 2948 | 2936 | |
| 2949 | - c0 <- if b == Boxed then printStringAtAA c ")"
|
|
| 2950 | - else printStringAtAA c "#)"
|
|
| 2937 | + an1 <- markClosingParen an0
|
|
| 2951 | 2938 | debugM $ "ExplicitTuple done"
|
| 2952 | - return (ExplicitTuple (o0,c0) args' b)
|
|
| 2939 | + return (ExplicitTuple an1 args' b)
|
|
| 2953 | 2940 | |
| 2954 | 2941 | exact (ExplicitSum an alt arity expr) = do
|
| 2955 | - an0 <- markLensFun an laesOpen (\loc -> printStringAtAA loc "(#")
|
|
| 2942 | + an0 <- markLensFun an laesParens markOpeningParen
|
|
| 2956 | 2943 | an1 <- markLensFun an0 laesBarsBefore (\locs -> mapM markEpToken locs)
|
| 2957 | 2944 | expr' <- markAnnotated expr
|
| 2958 | 2945 | an2 <- markLensFun an1 laesBarsAfter (\locs -> mapM markEpToken locs)
|
| 2959 | - an3 <- markLensFun an2 laesClose (\loc -> printStringAtAA loc "#)")
|
|
| 2946 | + an3 <- markLensFun an2 laesParens markClosingParen
|
|
| 2960 | 2947 | return (ExplicitSum an3 alt arity expr')
|
| 2961 | 2948 | |
| 2962 | 2949 | exact (HsCase an e alts) = do
|
| ... | ... | @@ -3970,11 +3957,11 @@ instance ExactPrint (HsType GhcPs) where |
| 3970 | 3957 | (mult', ty1') <- markModifiedFunArrOf mult (markAnnotated ty1)
|
| 3971 | 3958 | ty2' <- markAnnotated ty2
|
| 3972 | 3959 | return (HsFunTy an mult' ty1' ty2')
|
| 3973 | - exact (HsListTy an tys) = do
|
|
| 3974 | - an0 <- markOpeningParen an
|
|
| 3975 | - tys' <- markAnnotated tys
|
|
| 3976 | - an1 <- markClosingParen an0
|
|
| 3977 | - return (HsListTy an1 tys')
|
|
| 3960 | + exact (HsListTy (o,c) t) = do
|
|
| 3961 | + o' <- markEpToken o
|
|
| 3962 | + t' <- markAnnotated t
|
|
| 3963 | + c' <- markEpToken c
|
|
| 3964 | + return (HsListTy (o',c') t')
|
|
| 3978 | 3965 | exact (HsTupleTy an con tys) = do
|
| 3979 | 3966 | an0 <- markOpeningParen an
|
| 3980 | 3967 | tys' <- markAnnotated tys
|
| ... | ... | @@ -4026,14 +4013,14 @@ instance ExactPrint (HsType GhcPs) where |
| 4026 | 4013 | tys' <- markAnnotated tys
|
| 4027 | 4014 | c' <- markEpToken c
|
| 4028 | 4015 | return (HsExplicitListTy (sq',o',c') prom tys')
|
| 4029 | - exact (HsExplicitTupleTy (sq, o, c) prom tys) = do
|
|
| 4016 | + exact (HsExplicitTupleTy (sq, an) prom tys) = do
|
|
| 4030 | 4017 | sq' <- if (isPromoted prom)
|
| 4031 | 4018 | then markEpToken sq
|
| 4032 | 4019 | else return sq
|
| 4033 | - o' <- markEpToken o
|
|
| 4020 | + an0 <- markOpeningParen an
|
|
| 4034 | 4021 | tys' <- markAnnotated tys
|
| 4035 | - c' <- markEpToken c
|
|
| 4036 | - return (HsExplicitTupleTy (sq', o', c') prom tys')
|
|
| 4022 | + an1 <- markClosingParen an0
|
|
| 4023 | + return (HsExplicitTupleTy (sq', an1) prom tys')
|
|
| 4037 | 4024 | exact (HsTyLit an lit) = do
|
| 4038 | 4025 | lit' <- withPpr lit
|
| 4039 | 4026 | return (HsTyLit an lit')
|
| ... | ... | @@ -4713,22 +4700,18 @@ instance ExactPrint (Pat GhcPs) where |
| 4713 | 4700 | (an', pats') <- markAnnList' an (markAnnotated pats)
|
| 4714 | 4701 | return (ListPat an' pats')
|
| 4715 | 4702 | |
| 4716 | - exact (TuplePat (o,c) pats boxity) = do
|
|
| 4717 | - o0 <- case boxity of
|
|
| 4718 | - Boxed -> printStringAtAA o "("
|
|
| 4719 | - Unboxed -> printStringAtAA o "(#"
|
|
| 4703 | + exact (TuplePat an pats boxity) = do
|
|
| 4704 | + an0 <- markOpeningParen an
|
|
| 4720 | 4705 | pats' <- markAnnotated pats
|
| 4721 | - c0 <- case boxity of
|
|
| 4722 | - Boxed -> printStringAtAA c ")"
|
|
| 4723 | - Unboxed -> printStringAtAA c "#)"
|
|
| 4724 | - return (TuplePat (o0,c0) pats' boxity)
|
|
| 4706 | + an1 <- markClosingParen an0
|
|
| 4707 | + return (TuplePat an1 pats' boxity)
|
|
| 4725 | 4708 | |
| 4726 | 4709 | exact (SumPat an pat alt arity) = do
|
| 4727 | - an0 <- markLensFun an (lsumPatParens . lfst) (\loc -> printStringAtAA loc "(#")
|
|
| 4710 | + an0 <- markLensFun an lsumPatParens markOpeningParen
|
|
| 4728 | 4711 | an1 <- markLensFun an0 lsumPatVbarsBefore (\locs -> mapM markEpToken locs)
|
| 4729 | 4712 | pat' <- markAnnotated pat
|
| 4730 | 4713 | an2 <- markLensFun an1 lsumPatVbarsAfter (\locs -> mapM markEpToken locs)
|
| 4731 | - an3 <- markLensFun an2 (lsumPatParens . lsnd) (\loc -> printStringAtAA loc "#)")
|
|
| 4714 | + an3 <- markLensFun an2 lsumPatParens markClosingParen
|
|
| 4732 | 4715 | return (SumPat an3 pat' alt arity)
|
| 4733 | 4716 | |
| 4734 | 4717 | exact (OrPat an pats) = do
|