@@ -103,6 +103,8 @@ import GHC.Driver.Errors.Ppr () -- instance Diagnostic GhcMessage
103
103
import qualified GHC.Driver.Config.Diagnostic as GHC
104
104
import qualified GHC.Driver.Errors.Types as GHC
105
105
import qualified GHC.Utils.Logger as GHC
106
+ #endif
107
+ #if __GLASGOW_HASKELL__ < 910 && __GLASGOW_HASKELL__ >= 904
106
108
import qualified GHC.Parser.PostProcess as GHC
107
109
#endif
108
110
@@ -207,11 +209,20 @@ locA = id
207
209
#else
208
210
type MsgDoc = Outputable. SDoc
209
211
212
+ #if __GLASGOW_HASKELL__ < 910
210
213
locA :: SrcSpanAnn' a -> SrcSpan
214
+ #else
215
+ locA :: EpAnn ann -> SrcSpan
216
+ #endif
211
217
locA = GHC. locA
212
218
219
+ #if __GLASGOW_HASKELL__ < 910
213
220
noAnnSortKey :: AnnSortKey
214
221
noAnnSortKey = NoAnnSortKey
222
+ #else
223
+ noAnnSortKey :: AnnSortKey tag
224
+ noAnnSortKey = NoAnnSortKey
225
+ #endif
215
226
#endif
216
227
217
228
#if __GLASGOW_HASKELL__ < 902
@@ -230,7 +241,10 @@ sevFatal :: Err.MessageClass
230
241
sevFatal = Err. MCFatal
231
242
#endif
232
243
233
- #if __GLASGOW_HASKELL__ > 900
244
+ #if __GLASGOW_HASKELL__ > 908
245
+ noExt :: NoAnn a => a
246
+ noExt = noAnn
247
+ #elif __GLASGOW_HASKELL__ > 900
234
248
noExt :: EpAnn ann
235
249
noExt = EpAnnNotUsed
236
250
#elif __GLASGOW_HASKELL__ > 808
@@ -246,7 +260,7 @@ noExtField = NoExt
246
260
type NoExtField = NoExt
247
261
#endif
248
262
249
- #if __GLASGOW_HASKELL__ < 904
263
+ #if __GLASGOW_HASKELL__ < 904 || __GLASGOW_HASKELL__ >= 910
250
264
pattern HsParP :: LHsExpr p -> HsExpr p
251
265
pattern HsParP e <- HsPar _ e
252
266
@@ -430,12 +444,15 @@ conPatIn loc con = ConPat noExt loc con
430
444
conPatIn loc con = ConPatIn loc con
431
445
#endif
432
446
433
- #if __GLASGOW_HASKELL__ >= 902
434
- noEpAnn :: GenLocated SrcSpan e -> GenLocated (SrcAnn ann ) e
435
- noEpAnn ( L l e) = L ( SrcSpanAnn EpAnnNotUsed l) e
436
-
447
+ #if __GLASGOW_HASKELL__ >= 910
448
+ noLoc :: NoAnn ann => e -> GenLocated (EpAnn ann ) e
449
+ noLoc = L noAnn
450
+ #elif __GLASGOW_HASKELL__ >= 902
437
451
noLoc :: e -> GenLocated (SrcAnn ann ) e
438
452
noLoc = noEpAnn . GHC. noLoc
453
+ where
454
+ noEpAnn :: GenLocated SrcSpan e -> GenLocated (SrcAnn ann ) e
455
+ noEpAnn (L l e) = L (SrcSpanAnn EpAnnNotUsed l) e
439
456
#else
440
457
noLoc :: e -> Located e
441
458
noLoc = GHC. noLoc
@@ -448,7 +465,7 @@ tupP pats = noLoc $ TuplePat noExt pats GHC.Boxed
448
465
vecP :: (? nms :: ExternalNames ) => SrcSpanAnnA -> [LPat GhcPs ] -> LPat GhcPs
449
466
vecP srcLoc = \ case
450
467
[] -> go []
451
- #if __GLASGOW_HASKELL__ < 904
468
+ #if __GLASGOW_HASKELL__ < 904 || __GLASGOW_HASKELL__ >= 910
452
469
as -> L srcLoc $ ParPat noExt $ go as
453
470
where
454
471
#else
@@ -497,13 +514,19 @@ appTy :: LHsType GhcPs -> LHsType GhcPs -> LHsType GhcPs
497
514
appTy a b = noLoc (HsAppTy noExtField a (parenthesizeHsType GHC. appPrec b))
498
515
499
516
appE :: LHsExpr GhcPs -> LHsExpr GhcPs -> LHsExpr GhcPs
500
- appE fun arg = L noSrcSpanA $ HsApp noExt fun (parenthesizeHsExpr GHC. appPrec arg)
517
+ appE fun arg = L noSrcSpanA $ HsApp
518
+ #if __GLASGOW_HASKELL__ >= 910
519
+ noExtField
520
+ #else
521
+ noExt
522
+ #endif
523
+ fun (parenthesizeHsExpr GHC. appPrec arg)
501
524
502
525
varE :: SrcSpanAnnA -> GHC. RdrName -> LHsExpr GhcPs
503
526
varE loc rdr = L loc (HsVar noExtField (noLoc rdr))
504
527
505
528
parenE :: LHsExpr GhcPs -> LHsExpr GhcPs
506
- #if __GLASGOW_HASKELL__ < 904
529
+ #if __GLASGOW_HASKELL__ < 904 || __GLASGOW_HASKELL__ >= 910
507
530
parenE e@ (L l _) = L l (HsPar noExt e)
508
531
#else
509
532
parenE e@ (L l _) = L l (HsPar noExt pL e pR)
@@ -533,7 +556,9 @@ tupE :: p ~ GhcPs => SrcSpanAnnA -> [LHsExpr p] -> LHsExpr p
533
556
tupE _ [ele] = ele
534
557
tupE loc elems = L loc $ ExplicitTuple noExt tupArgs GHC. Boxed
535
558
where
536
- #if __GLASGOW_HASKELL__ >= 902
559
+ #if __GLASGOW_HASKELL__ >= 910
560
+ tupArgs = map (Present noExtField) elems
561
+ #elif __GLASGOW_HASKELL__ >= 902
537
562
tupArgs = map (Present noExt) elems
538
563
#else
539
564
tupArgs = map (\ arg@ (L l _) -> L l (Present noExt arg)) elems
@@ -567,8 +592,10 @@ simpleLambda :: HsExpr GhcPs -> Maybe ([LPat GhcPs], LHsExpr GhcPs)
567
592
simpleLambda expr = do
568
593
#if __GLASGOW_HASKELL__ < 906
569
594
HsLam _ (MG _x alts _origin) <- Just expr
570
- #else
595
+ #elif __GLASGOW_HASKELL__ < 910
571
596
HsLam _ (MG _x alts) <- Just expr
597
+ #else
598
+ HsLam _ _ (MG _x alts) <- Just expr
572
599
#endif
573
600
L _ [L _ (Match _matchX _matchContext matchPats matchGr)] <- Just alts
574
601
GRHSs _grX grHss _grLocalBinds <- Just matchGr
588
615
-- ^ final `in` expressions
589
616
-> LHsExpr p
590
617
letE loc sigs binds expr =
591
- #if __GLASGOW_HASKELL__ < 904
618
+ #if __GLASGOW_HASKELL__ < 904 || __GLASGOW_HASKELL__ >= 910
592
619
L loc (HsLet noExt localBinds expr)
593
620
#else
594
621
L loc (HsLet noExt tkLet localBinds tkIn expr)
@@ -602,7 +629,7 @@ letE loc sigs binds expr =
602
629
localBinds = L loc $ HsValBinds noExt valBinds
603
630
#endif
604
631
605
- #if __GLASGOW_HASKELL__ >= 904
632
+ #if __GLASGOW_HASKELL__ >= 904 && __GLASGOW_HASKELL__ < 910
606
633
tkLet = L (GHC. mkTokenLocation $ locA loc) HsTok
607
634
tkIn = L (GHC. mkTokenLocation $ locA loc) HsTok
608
635
#endif
@@ -615,22 +642,38 @@ letE loc sigs binds expr =
615
642
616
643
-- | Simple construction of a lambda expression
617
644
lamE :: [LPat GhcPs ] -> LHsExpr GhcPs -> LHsExpr GhcPs
618
- lamE pats expr = noLoc $ HsLam noExtField mg
645
+ lamE pats expr = noLoc $ HsLam
646
+ #if __GLASGOW_HASKELL__ >= 910
647
+ noAnn
648
+ LamSingle
649
+ #else
650
+ noExtField
651
+ #endif
652
+ mg
619
653
where
620
654
mg :: MatchGroup GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs ))
621
655
#if __GLASGOW_HASKELL__ < 906
622
656
mg = MG noExtField matches GHC. Generated
623
657
#elif __GLASGOW_HASKELL__ < 908
624
658
mg = MG GHC. Generated matches
625
- #else
659
+ #elif __GLASGOW_HASKELL__ < 910
626
660
mg = MG (GHC. Generated GHC. DoPmc ) matches
661
+ #else
662
+ -- TODO: Add explanation
663
+ mg = MG (GHC. Generated GHC. OtherExpansion GHC. DoPmc ) matches
627
664
#endif
628
665
629
666
matches :: GenLocated SrcSpanAnnL [GenLocated SrcSpanAnnA (Match GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs )))]
630
667
matches = noLoc $ [singleMatch]
631
668
632
669
singleMatch :: GenLocated SrcSpanAnnA (Match GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs )))
633
- singleMatch = noLoc $ Match noExt LambdaExpr pats grHss
670
+ singleMatch = noLoc $ Match noExt
671
+ #if __GLASGOW_HASKELL__ < 910
672
+ LambdaExpr
673
+ #else
674
+ (LamAlt LamSingle )
675
+ #endif
676
+ pats grHss
634
677
635
678
grHss :: GRHSs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs ))
636
679
grHss = GRHSs emptyComments [grHs] $
@@ -988,7 +1031,17 @@ decFromBinding dflags Binding {..} = do
988
1031
in patBind bindPat bod
989
1032
990
1033
patBind :: LPat GhcPs -> LHsExpr GhcPs -> HsBind GhcPs
991
- patBind lhs expr = PatBind noExt lhs rhs
1034
+ patBind lhs expr = PatBind
1035
+ #if __GLASGOW_HASKELL__ >= 910
1036
+ noExtField
1037
+ #else
1038
+ noExt
1039
+ #endif
1040
+ lhs
1041
+ #if __GLASGOW_HASKELL__ >= 910
1042
+ (HsNoMultAnn noExtField)
1043
+ #endif
1044
+ rhs
992
1045
#if __GLASGOW_HASKELL__ < 906
993
1046
([] , [] )
994
1047
#endif
@@ -1087,9 +1140,16 @@ unsnoc (x:xs) = Just (x:a, b)
1087
1140
1088
1141
hsFunTy :: (p ~ GhcPs ) => LHsType p -> LHsType p -> HsType p
1089
1142
hsFunTy =
1090
- HsFunTy noExt
1143
+ HsFunTy
1144
+ #if __GLASGOW_HASKELL__ >= 910
1145
+ noExtField
1146
+ #else
1147
+ noExt
1148
+ #endif
1091
1149
#if __GLASGOW_HASKELL__ >= 900 && __GLASGOW_HASKELL__ < 904
1092
1150
(HsUnrestrictedArrow GHC. NormalSyntax )
1151
+ #elif __GLASGOW_HASKELL__ >= 910
1152
+ (HsUnrestrictedArrow NoEpUniTok )
1093
1153
#elif __GLASGOW_HASKELL__ >= 904
1094
1154
(HsUnrestrictedArrow $ L NoTokenLoc HsNormalTok )
1095
1155
#endif
0 commit comments