-
-
Notifications
You must be signed in to change notification settings - Fork 389
/
Copy pathCore.hs
824 lines (752 loc) · 23.1 KB
/
Core.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
{-# LANGUAGE CPP #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ViewPatterns #-}
-- | Compat Core module that handles the GHC module hierarchy re-organization
-- by re-exporting everything we care about.
--
-- This module provides no other compat mechanisms, except for simple
-- backward-compatible pattern synonyms.
module Development.IDE.GHC.Compat.Core (
-- * Session
DynFlags,
extensions,
extensionFlags,
targetPlatform,
packageFlags,
generalFlags,
warningFlags,
topDir,
hiDir,
tmpDir,
importPaths,
useColor,
canUseColor,
useUnicode,
objectDir,
flagsForCompletion,
setImportPaths,
outputFile,
pluginModNames,
refLevelHoleFits,
maxRefHoleFits,
maxValidHoleFits,
setOutputFile,
lookupType,
needWiredInHomeIface,
loadWiredInHomeIface,
readIface,
loadSysInterface,
importDecl,
CommandLineOption,
sPgm_F,
settings,
gopt,
gopt_set,
gopt_unset,
wopt,
wopt_set,
xFlags,
xopt,
xopt_unset,
xopt_set,
FlagSpec(..),
WarningFlag(..),
GeneralFlag(..),
PackageFlag,
PackageArg(..),
ModRenaming(..),
pattern ExposePackage,
parseDynamicFlagsCmdLine,
parseDynamicFilePragma,
#if !MIN_VERSION_ghc(9,3,0)
WarnReason(..),
#endif
wWarningFlags,
updOptLevel,
-- slightly unsafe
setUnsafeGlobalDynFlags,
-- * Linear Haskell
scaledThing,
-- * Interface Files
IfaceExport,
IfaceTyCon(..),
ModIface,
ModIface_(..),
HscSource(..),
WhereFrom(..),
loadInterface,
#if !MIN_VERSION_ghc(9,3,0)
SourceModified(..),
#endif
loadModuleInterface,
RecompileRequired(..),
mkPartialIface,
mkFullIface,
IsBootInterface(..),
-- * Fixity
LexicalFixity(..),
Fixity (..),
mi_fix,
defaultFixity,
lookupFixityRn,
-- * ModSummary
ModSummary(..),
-- * HomeModInfo
HomeModInfo(..),
-- * ModGuts
ModGuts(..),
CgGuts(..),
-- * ModDetails
ModDetails(..),
-- * HsExpr,
-- * Var
Type (
TyCoRep.TyVarTy,
TyCoRep.AppTy,
TyCoRep.TyConApp,
TyCoRep.ForAllTy,
-- Omitted on purpose
-- pattern Synonym right below it
-- TyCoRep.FunTy,
TyCoRep.LitTy,
TyCoRep.CastTy,
TyCoRep.CoercionTy
),
pattern FunTy,
pattern ConPatIn,
conPatDetails,
mapConPatDetail,
#if MIN_VERSION_ghc(9,5,0)
mkVisFunTys,
#endif
-- * Specs
ImpDeclSpec(..),
ImportSpec(..),
-- * SourceText
SourceText(..),
-- * Ways
Way,
wayGeneralFlags,
wayUnsetGeneralFlags,
-- * AvailInfo
Avail.AvailInfo,
pattern AvailName,
pattern AvailFL,
pattern AvailTC,
Avail.availName,
Avail.availNames,
#if !MIN_VERSION_ghc(9,7,0)
Avail.availNamesWithSelectors,
#endif
Avail.availsToNameSet,
-- * TcGblEnv
TcGblEnv(..),
-- * Parsing and LExer types
HsModule(..),
GHC.ParsedSource,
GHC.RenamedSource,
-- * Compilation Main
HscEnv,
GHC.runGhc,
unGhc,
Session(..),
modifySession,
getSession,
GHC.setSessionDynFlags,
getSessionDynFlags,
GhcMonad,
Ghc,
runHsc,
compileFile,
Phase(..),
hscDesugar,
hscGenHardCode,
hscInteractive,
hscSimplify,
hscTypecheckRename,
hscUpdateHPT,
Development.IDE.GHC.Compat.Core.makeSimpleDetails,
-- * Typecheck utils
tcSplitForAllTyVars,
tcSplitForAllTyVarBinder_maybe,
typecheckIface,
Development.IDE.GHC.Compat.Core.mkIfaceTc,
Development.IDE.GHC.Compat.Core.mkBootModDetailsTc,
Development.IDE.GHC.Compat.Core.initTidyOpts,
driverNoStop,
tidyProgram,
ImportedModsVal(..),
importedByUser,
GHC.TypecheckedSource,
-- * Source Locations
HasSrcSpan,
SrcLoc.Located,
SrcLoc.unLoc,
getLoc,
GHC.getLocA,
GHC.locA,
GHC.noLocA,
unLocA,
LocatedAn,
GHC.LocatedA,
GHC.AnnListItem(..),
GHC.NameAnn(..),
SrcLoc.RealLocated,
SrcLoc.GenLocated(..),
SrcLoc.SrcSpan(SrcLoc.UnhelpfulSpan),
SrcLoc.RealSrcSpan,
pattern RealSrcSpan,
SrcLoc.RealSrcLoc,
pattern RealSrcLoc,
SrcLoc.SrcLoc(SrcLoc.UnhelpfulLoc),
BufSpan,
GHC.SrcAnn,
SrcLoc.leftmost_smallest,
SrcLoc.containsSpan,
SrcLoc.mkGeneralSrcSpan,
SrcLoc.mkRealSrcSpan,
SrcLoc.mkRealSrcLoc,
SrcLoc.getRealSrcSpan,
SrcLoc.realSrcLocSpan,
SrcLoc.realSrcSpanStart,
SrcLoc.realSrcSpanEnd,
isSubspanOfA,
SrcLoc.isSubspanOf,
SrcLoc.wiredInSrcSpan,
SrcLoc.mkSrcSpan,
SrcLoc.srcSpanStart,
SrcLoc.srcSpanStartLine,
SrcLoc.srcSpanStartCol,
SrcLoc.srcSpanEnd,
SrcLoc.srcSpanEndLine,
SrcLoc.srcSpanEndCol,
SrcLoc.srcSpanFile,
SrcLoc.srcLocCol,
SrcLoc.srcLocFile,
SrcLoc.srcLocLine,
SrcLoc.noSrcSpan,
SrcLoc.noSrcLoc,
SrcLoc.noLoc,
mapLoc,
-- * Finder
FindResult(..),
mkHomeModLocation,
findObjectLinkableMaybe,
InstalledFindResult(..),
-- * Module and Package
ModuleOrigin(..),
PackageName(..),
-- * Linker
Unlinked(..),
Linkable(..),
unload,
-- * Hooks
Hooks,
runMetaHook,
MetaHook,
MetaRequest(..),
metaRequestE,
metaRequestP,
metaRequestT,
metaRequestD,
metaRequestAW,
-- * HPT
addToHpt,
addListToHpt,
-- * Driver-Make
Target(..),
TargetId(..),
mkSimpleTarget,
-- * GHCi
initObjLinker,
loadDLL,
InteractiveImport(..),
GHC.getContext,
GHC.setContext,
GHC.parseImportDecl,
GHC.runDecls,
Warn(..),
-- * ModLocation
GHC.ModLocation,
Module.ml_hs_file,
Module.ml_obj_file,
Module.ml_hi_file,
Module.ml_hie_file,
-- * DataCon
DataCon.dataConExTyCoVars,
-- * Role
Role(..),
-- * Panic
Plain.PlainGhcException,
-- * Other
GHC.CoreModule(..),
GHC.SafeHaskellMode(..),
pattern GRE,
gre_name,
gre_imp,
gre_lcl,
gre_par,
collectHsBindsBinders,
-- * Util Module re-exports
module GHC.Builtin.Names,
module GHC.Builtin.Types,
module GHC.Builtin.Types.Prim,
module GHC.Builtin.Utils,
module GHC.Core.Class,
module GHC.Core.Coercion,
module GHC.Core.ConLike,
module GHC.Core.DataCon,
module GHC.Core.FamInstEnv,
module GHC.Core.InstEnv,
module GHC.Types.Unique.FM,
module GHC.Core.PatSyn,
module GHC.Core.Predicate,
module GHC.Core.TyCon,
module GHC.Core.TyCo.Ppr,
module GHC.Core.Type,
module GHC.Core.Unify,
module GHC.Core.Utils,
module GHC.HsToCore.Docs,
module GHC.HsToCore.Expr,
module GHC.HsToCore.Monad,
module GHC.Iface.Syntax,
module GHC.Iface.Recomp,
module GHC.Hs.Decls,
module GHC.Hs.Expr,
module GHC.Hs.Doc,
module GHC.Hs.Extension,
module GHC.Hs.ImpExp,
module GHC.Hs.Pat,
module GHC.Hs.Type,
module GHC.Hs.Utils,
module Language.Haskell.Syntax,
module GHC.Rename.Names,
module GHC.Rename.Splice,
module GHC.Tc.Instance.Family,
module GHC.Tc.Module,
module GHC.Tc.Types,
module GHC.Tc.Types.Evidence,
module GHC.Tc.Utils.Env,
module GHC.Tc.Utils.Monad,
module GHC.Types.Basic,
module GHC.Types.Id,
module GHC.Types.Name,
module GHC.Types.Name.Set,
module GHC.Types.Name.Cache,
module GHC.Types.Name.Env,
module GHC.Types.Name.Reader,
module GHC.Utils.Error,
#if !MIN_VERSION_ghc(9,7,0)
module GHC.Types.Avail,
#endif
module GHC.Types.SourceFile,
module GHC.Types.SourceText,
module GHC.Types.TyThing,
module GHC.Types.TyThing.Ppr,
module GHC.Types.Unique.Supply,
module GHC.Types.Var,
module GHC.Unit.Module,
module GHC.Unit.Module.Graph,
-- * Syntax re-exports
module GHC.Hs,
module GHC.Hs.Binds,
module GHC.Parser,
module GHC.Parser.Header,
module GHC.Parser.Lexer,
module GHC.Utils.Panic,
#if MIN_VERSION_ghc(9,3,0)
CompileReason(..),
hsc_type_env_vars,
hscUpdateHUG, hsc_HUG,
GhcMessage(..),
getKey,
module GHC.Driver.Env.KnotVars,
module GHC.Linker.Types,
module GHC.Types.Unique.Map,
module GHC.Utils.TmpFs,
module GHC.Unit.Finder.Types,
module GHC.Unit.Env,
module GHC.Driver.Phases,
#endif
#if !MIN_VERSION_ghc(9,4,0)
pattern HsFieldBind,
hfbAnn,
hfbLHS,
hfbRHS,
hfbPun,
#endif
#if !MIN_VERSION_ghc_boot_th(9,4,1)
Extension(.., NamedFieldPuns),
#else
Extension(..),
#endif
mkCgInteractiveGuts,
justBytecode,
justObjects,
emptyHomeModInfoLinkable,
homeModInfoByteCode,
homeModInfoObject,
#if !MIN_VERSION_ghc(9,5,0)
field_label,
#endif
groupOrigin,
isVisibleFunArg,
#if MIN_VERSION_ghc(9,8,0)
lookupGlobalRdrEnv
#endif
) where
import qualified GHC
-- NOTE(ozkutuk): Cpp clashes Phase.Cpp, so we hide it.
-- Not the greatest solution, but gets the job done
-- (until the CPP extension is actually needed).
import GHC.LanguageExtensions.Type hiding (Cpp)
import GHC.Hs.Binds
-- See Note [Guidelines For Using CPP In GHCIDE Import Statements]
import GHC.Builtin.Names hiding (Unique, printName)
import GHC.Builtin.Types
import GHC.Builtin.Types.Prim
import GHC.Builtin.Utils
import GHC.Core.Class
import GHC.Core.Coercion
import GHC.Core.ConLike
import GHC.Core.DataCon hiding (dataConExTyCoVars)
import qualified GHC.Core.DataCon as DataCon
import GHC.Core.FamInstEnv hiding (pprFamInst)
import GHC.Core.InstEnv
import GHC.Types.Unique.FM
import GHC.Core.PatSyn
import GHC.Core.Predicate
import GHC.Core.TyCo.Ppr
import qualified GHC.Core.TyCo.Rep as TyCoRep
import GHC.Core.TyCon
import GHC.Core.Type
import GHC.Core.Unify
import GHC.Core.Utils
import GHC.Driver.CmdLine (Warn (..))
import GHC.Driver.Hooks
import GHC.Driver.Main as GHC
import GHC.Driver.Monad
import GHC.Driver.Phases
import GHC.Driver.Pipeline
import GHC.Driver.Plugins
import GHC.Driver.Session hiding (ExposePackage)
import qualified GHC.Driver.Session as DynFlags
import GHC.HsToCore.Docs
import GHC.HsToCore.Expr
import GHC.HsToCore.Monad
import GHC.Iface.Load
import GHC.Iface.Make as GHC
import GHC.Iface.Recomp
import GHC.Iface.Syntax
import GHC.Iface.Tidy as GHC
import GHC.IfaceToCore
import GHC.Parser
import GHC.Parser.Header hiding (getImports)
import GHC.Rename.Fixity (lookupFixityRn)
import GHC.Rename.Names
import GHC.Rename.Splice
import qualified GHC.Runtime.Interpreter as GHCi
import GHC.Tc.Instance.Family
import GHC.Tc.Module
import GHC.Tc.Types
import GHC.Tc.Types.Evidence hiding ((<.>))
import GHC.Tc.Utils.Env
import GHC.Tc.Utils.Monad hiding (Applicative (..), IORef,
MonadFix (..), MonadIO (..),
allM, anyM, concatMapM,
mapMaybeM, (<$>))
import GHC.Tc.Utils.TcType as TcType
import qualified GHC.Types.Avail as Avail
import GHC.Types.Basic
import GHC.Types.Id
import GHC.Types.Name hiding (varName)
import GHC.Types.Name.Cache
import GHC.Types.Name.Env
import GHC.Types.Name.Reader hiding (GRE, gre_name, gre_imp, gre_lcl, gre_par)
import qualified GHC.Types.Name.Reader as RdrName
import GHC.Types.SrcLoc (BufPos, BufSpan,
SrcLoc (UnhelpfulLoc),
SrcSpan (UnhelpfulSpan))
import qualified GHC.Types.SrcLoc as SrcLoc
import GHC.Types.Unique.Supply
import GHC.Types.Var (Var (varName), setTyVarUnique,
setVarUnique)
import qualified GHC.Types.Var as TypesVar
import GHC.Unit.Info (PackageName (..))
import GHC.Unit.Module hiding (ModLocation (..), UnitId,
moduleUnit,
toUnitId)
import qualified GHC.Unit.Module as Module
import GHC.Unit.State (ModuleOrigin (..))
import GHC.Utils.Error (Severity (..), emptyMessages)
import GHC.Utils.Panic hiding (try)
import qualified GHC.Utils.Panic.Plain as Plain
import Data.Foldable (toList)
import GHC.Data.Bag
import GHC.Core.Multiplicity (scaledThing)
import GHC.Driver.Env
import GHC.Hs (HsModule (..), SrcSpanAnn')
import GHC.Hs.Decls hiding (FunDep)
import GHC.Hs.Doc
import GHC.Hs.Expr
import GHC.Hs.Extension
import GHC.Hs.ImpExp
import GHC.Hs.Pat
import GHC.Hs.Type
import GHC.Hs.Utils hiding (collectHsBindsBinders)
import qualified GHC.Linker.Loader as Linker
import GHC.Linker.Types
import GHC.Parser.Lexer hiding (initParserState, getPsMessages)
import GHC.Parser.Annotation (EpAnn (..))
import GHC.Platform.Ways
import GHC.Runtime.Context (InteractiveImport (..))
#if !MIN_VERSION_ghc(9,7,0)
import GHC.Types.Avail (greNamePrintableName)
#endif
import GHC.Types.Fixity (LexicalFixity (..), Fixity (..), defaultFixity)
import GHC.Types.Meta
import GHC.Types.Name.Set
import GHC.Types.SourceFile (HscSource (..))
import GHC.Types.SourceText
import GHC.Types.Target (Target (..), TargetId (..))
import GHC.Types.TyThing
import GHC.Types.TyThing.Ppr
import GHC.Unit.Finder hiding (mkHomeModLocation)
import GHC.Unit.Home.ModInfo
import GHC.Unit.Module.Imported
import GHC.Unit.Module.ModDetails
import GHC.Unit.Module.ModGuts
import GHC.Unit.Module.ModIface (IfaceExport, ModIface,
ModIface_ (..), mi_fix)
import GHC.Unit.Module.ModSummary (ModSummary (..))
import Language.Haskell.Syntax hiding (FunDep)
#if !MIN_VERSION_ghc(9,3,0)
import GHC.Types.SourceFile (SourceModified(..))
import GHC.Unit.Module.Graph (mkModuleGraph)
import qualified GHC.Unit.Finder as GHC
#endif
#if MIN_VERSION_ghc(9,3,0)
import GHC.Driver.Env.KnotVars
import GHC.Unit.Module.Graph
import GHC.Driver.Errors.Types
import GHC.Types.Unique.Map
import GHC.Types.Unique
import GHC.Utils.TmpFs
import GHC.Utils.Panic
import GHC.Unit.Finder.Types
import GHC.Unit.Env
import qualified GHC.Driver.Config.Tidy as GHC
import qualified GHC.Data.Strict as Strict
import GHC.Driver.Env as GHCi
import qualified GHC.Unit.Finder as GHC
import qualified GHC.Driver.Config.Finder as GHC
#endif
mkHomeModLocation :: DynFlags -> ModuleName -> FilePath -> IO Module.ModLocation
#if MIN_VERSION_ghc(9,3,0)
mkHomeModLocation df mn f = pure $ GHC.mkHomeModLocation (GHC.initFinderOpts df) mn f
#else
mkHomeModLocation = GHC.mkHomeModLocation
#endif
#if MIN_VERSION_ghc(9,3,0)
pattern RealSrcSpan :: SrcLoc.RealSrcSpan -> Maybe BufSpan -> SrcLoc.SrcSpan
#else
pattern RealSrcSpan :: SrcLoc.RealSrcSpan -> Maybe BufSpan -> SrcLoc.SrcSpan
#endif
#if MIN_VERSION_ghc(9,3,0)
pattern RealSrcSpan x y <- SrcLoc.RealSrcSpan x ((\case Strict.Nothing -> Nothing; Strict.Just a -> Just a) -> y) where
RealSrcSpan x y = SrcLoc.RealSrcSpan x (case y of Nothing -> Strict.Nothing; Just a -> Strict.Just a)
#else
pattern RealSrcSpan x y = SrcLoc.RealSrcSpan x y
#endif
{-# COMPLETE RealSrcSpan, UnhelpfulSpan #-}
#if MIN_VERSION_ghc(9,3,0)
pattern RealSrcLoc :: SrcLoc.RealSrcLoc -> Strict.Maybe BufPos-> SrcLoc.SrcLoc
#else
pattern RealSrcLoc :: SrcLoc.RealSrcLoc -> Maybe BufPos-> SrcLoc.SrcLoc
#endif
pattern RealSrcLoc x y = SrcLoc.RealSrcLoc x y
{-# COMPLETE RealSrcLoc, UnhelpfulLoc #-}
pattern AvailTC :: Name -> [Name] -> [FieldLabel] -> Avail.AvailInfo
#if __GLASGOW_HASKELL__ >= 907
pattern AvailTC n names pieces <- Avail.AvailTC n ((,[]) -> (names,pieces))
#else
pattern AvailTC n names pieces <- Avail.AvailTC n ((\gres -> foldr (\gre (names, pieces) -> case gre of
Avail.NormalGreName name -> (name: names, pieces)
Avail.FieldGreName label -> (names, label:pieces)) ([], []) gres) -> (names, pieces))
#endif
pattern AvailName :: Name -> Avail.AvailInfo
#if __GLASGOW_HASKELL__ >= 907
pattern AvailName n <- Avail.Avail n
#else
pattern AvailName n <- Avail.Avail (Avail.NormalGreName n)
#endif
pattern AvailFL :: FieldLabel -> Avail.AvailInfo
#if __GLASGOW_HASKELL__ >= 907
pattern AvailFL fl <- (const Nothing -> Just fl) -- this pattern always fails as this field was removed in 9.7
#else
pattern AvailFL fl <- Avail.Avail (Avail.FieldGreName fl)
#endif
{-# COMPLETE AvailTC, AvailName, AvailFL #-}
setImportPaths :: [FilePath] -> DynFlags -> DynFlags
setImportPaths importPaths flags = flags { importPaths = importPaths }
pattern ExposePackage :: String -> PackageArg -> ModRenaming -> PackageFlag
-- https://github.com/facebook/fbghc
#ifdef __FACEBOOK_HASKELL__
pattern ExposePackage s a mr <- DynFlags.ExposePackage s a _ mr
#else
pattern ExposePackage s a mr = DynFlags.ExposePackage s a mr
#endif
#if __GLASGOW_HASKELL__ >= 906
isVisibleFunArg = TypesVar.isVisibleFunArg
type FunTyFlag = TypesVar.FunTyFlag
#else
isVisibleFunArg VisArg = True
isVisibleFunArg _ = False
type FunTyFlag = TypesVar.AnonArgFlag
#endif
pattern FunTy :: Development.IDE.GHC.Compat.Core.FunTyFlag -> Type -> Type -> Type
pattern FunTy af arg res <- TyCoRep.FunTy {ft_af = af, ft_arg = arg, ft_res = res}
-- type HasSrcSpan x a = (GenLocated SrcSpan a ~ x)
-- type HasSrcSpan x = () :: Constraint
class HasSrcSpan a where
getLoc :: a -> SrcSpan
instance HasSrcSpan SrcSpan where
getLoc = id
instance HasSrcSpan (SrcLoc.GenLocated SrcSpan a) where
getLoc = GHC.getLoc
instance HasSrcSpan (SrcSpanAnn' ann) where
getLoc = GHC.locA
instance HasSrcSpan (SrcLoc.GenLocated (SrcSpanAnn' ann) a) where
getLoc (L l _) = l
pattern L :: HasSrcSpan a => SrcSpan -> e -> SrcLoc.GenLocated a e
pattern L l a <- GHC.L (getLoc -> l) a
{-# COMPLETE L #-}
-- This is from the old api, but it still simplifies
pattern ConPatIn :: SrcLoc.Located (ConLikeP GhcPs) -> HsConPatDetails GhcPs -> Pat GhcPs
pattern ConPatIn con args <- ConPat EpAnnNotUsed (L _ (SrcLoc.noLoc -> con)) args
where
ConPatIn con args = ConPat EpAnnNotUsed (GHC.noLocA $ SrcLoc.unLoc con) args
conPatDetails :: Pat p -> Maybe (HsConPatDetails p)
conPatDetails (ConPat _ _ args) = Just args
conPatDetails _ = Nothing
mapConPatDetail :: (HsConPatDetails p -> Maybe (HsConPatDetails p)) -> Pat p -> Maybe (Pat p)
mapConPatDetail f pat@(ConPat _ _ args) = (\args' -> pat { pat_args = args'}) <$> f args
mapConPatDetail _ _ = Nothing
initObjLinker :: HscEnv -> IO ()
initObjLinker env =
GHCi.initObjLinker (GHCi.hscInterp env)
loadDLL :: HscEnv -> String -> IO (Maybe String)
loadDLL env =
GHCi.loadDLL (GHCi.hscInterp env)
unload :: HscEnv -> [Linkable] -> IO ()
unload hsc_env linkables =
Linker.unload
(GHCi.hscInterp hsc_env)
hsc_env linkables
#if !MIN_VERSION_ghc(9,3,0)
setOutputFile :: FilePath -> DynFlags -> DynFlags
setOutputFile f d = d {
outputFile_ = Just f
}
#endif
isSubspanOfA :: LocatedAn la a -> LocatedAn lb b -> Bool
isSubspanOfA a b = SrcLoc.isSubspanOf (GHC.getLocA a) (GHC.getLocA b)
type LocatedAn a = GHC.LocatedAn a
unLocA :: forall pass a. XRec (GhcPass pass) a -> a
unLocA = unXRec @(GhcPass pass)
pattern GRE :: Name -> Parent -> Bool -> [ImportSpec] -> RdrName.GlobalRdrElt
{-# COMPLETE GRE #-}
pattern GRE{gre_name, gre_par, gre_lcl, gre_imp} <- RdrName.GRE
#if MIN_VERSION_ghc(9,7,0)
{gre_name = gre_name
#else
{gre_name = (greNamePrintableName -> gre_name)
#endif
,gre_par, gre_lcl, gre_imp = (toList -> gre_imp)}
collectHsBindsBinders :: CollectPass p => Bag (XRec p (HsBindLR p idR)) -> [IdP p]
collectHsBindsBinders x = GHC.collectHsBindsBinders CollNoDictBinders x
makeSimpleDetails :: HscEnv -> TcGblEnv -> IO ModDetails
makeSimpleDetails hsc_env =
GHC.makeSimpleDetails
#if MIN_VERSION_ghc(9,3,0)
(hsc_logger hsc_env)
#else
hsc_env
#endif
mkIfaceTc hsc_env sf details _ms tcGblEnv = -- ms is only used in GHC >= 9.4
GHC.mkIfaceTc hsc_env sf details
#if MIN_VERSION_ghc(9,3,0)
_ms
#endif
tcGblEnv
mkBootModDetailsTc :: HscEnv -> TcGblEnv -> IO ModDetails
mkBootModDetailsTc session = GHC.mkBootModDetailsTc
#if MIN_VERSION_ghc(9,3,0)
(hsc_logger session)
#else
session
#endif
#if !MIN_VERSION_ghc(9,3,0)
type TidyOpts = HscEnv
#endif
initTidyOpts :: HscEnv -> IO TidyOpts
initTidyOpts =
#if MIN_VERSION_ghc(9,3,0)
GHC.initTidyOpts
#else
pure
#endif
driverNoStop =
#if MIN_VERSION_ghc(9,3,0)
NoStop
#else
StopLn
#endif
#if !MIN_VERSION_ghc(9,3,0)
hscUpdateHPT :: (HomePackageTable -> HomePackageTable) -> HscEnv -> HscEnv
hscUpdateHPT k session = session { hsc_HPT = k (hsc_HPT session) }
#endif
#if !MIN_VERSION_ghc(9,4,0)
pattern HsFieldBind :: XHsRecField id -> id -> arg -> Bool -> HsRecField' id arg
pattern HsFieldBind {hfbAnn, hfbLHS, hfbRHS, hfbPun} <- HsRecField hfbAnn (SrcLoc.unLoc -> hfbLHS) hfbRHS hfbPun where
HsFieldBind ann lhs rhs pun = HsRecField ann (SrcLoc.noLoc lhs) rhs pun
#endif
#if !MIN_VERSION_ghc_boot_th(9,4,1)
pattern NamedFieldPuns :: Extension
pattern NamedFieldPuns = RecordPuns
#endif
#if MIN_VERSION_ghc(9,5,0)
mkVisFunTys = mkScaledFunctionTys
mapLoc :: (a -> b) -> SrcLoc.GenLocated l a -> SrcLoc.GenLocated l b
mapLoc = fmap
groupOrigin = mg_ext
#else
mapLoc :: (a -> b) -> SrcLoc.GenLocated l a -> SrcLoc.GenLocated l b
mapLoc = SrcLoc.mapLoc
groupOrigin :: MatchGroup p body -> Origin
groupOrigin = mg_origin
#endif
#if !MIN_VERSION_ghc(9,5,0)
mkCgInteractiveGuts :: CgGuts -> CgGuts
mkCgInteractiveGuts = id
emptyHomeModInfoLinkable :: Maybe Linkable
emptyHomeModInfoLinkable = Nothing
justBytecode :: Linkable -> Maybe Linkable
justBytecode = Just
justObjects :: Linkable -> Maybe Linkable
justObjects = Just
homeModInfoByteCode, homeModInfoObject :: HomeModInfo -> Maybe Linkable
homeModInfoByteCode = hm_linkable
homeModInfoObject = hm_linkable
field_label :: a -> a
field_label = id
#endif
mkSimpleTarget :: DynFlags -> FilePath -> Target
#if MIN_VERSION_ghc(9,3,0)
mkSimpleTarget df fp = Target (TargetFile fp Nothing) True (homeUnitId_ df) Nothing
#else
mkSimpleTarget _ fp = Target (TargetFile fp Nothing) True Nothing
#endif
#if MIN_VERSION_ghc(9,7,0)
lookupGlobalRdrEnv gre_env occ = lookupGRE gre_env (LookupOccName occ AllRelevantGREs)
#endif