Skip to content

Commit 506e958

Browse files
committed
Try enumerating all instances
1 parent 9a4e704 commit 506e958

File tree

2 files changed

+39
-33
lines changed

2 files changed

+39
-33
lines changed

ghcide/src/Development/IDE/Core/RuleTypes.hs

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import Development.IDE.GHC.Compat.Util
2929
import Development.IDE.GHC.CoreFile
3030
import Development.IDE.GHC.Util
3131
import Development.IDE.Graph
32-
import Development.IDE.Graph.Internal.RuleInput (Input(ProjectHaskellFile, DependencyHaskellFile, NoFile), RuleInput)
32+
import Development.IDE.Graph.Internal.RuleInput (Input(ProjectHaskellFile, DependencyHaskellFile, NoFile), RuleInput, ValidInputs(ProjectHaskellFilesOnly, AllHaskellFiles, NoFiles))
3333
import Development.IDE.Import.DependencyInformation
3434
import Development.IDE.Types.HscEnvEq (HscEnvEq)
3535
import Development.IDE.Types.KnownTargets
@@ -66,34 +66,34 @@ encodeLinkableType (Just ObjectLinkable) = "2"
6666

6767
-- | The parse tree for the file using GetFileContents
6868
type instance RuleResult GetParsedModule = ParsedModule
69-
type instance RuleInput GetParsedModule = '[ProjectHaskellFile, DependencyHaskellFile]
69+
type instance RuleInput GetParsedModule = AllHaskellFiles
7070

7171
-- | The parse tree for the file using GetFileContents,
7272
-- all comments included using Opt_KeepRawTokenStream
7373
type instance RuleResult GetParsedModuleWithComments = ParsedModule
74-
type instance RuleInput GetParsedModuleWithComments = '[ProjectHaskellFile, DependencyHaskellFile]
74+
type instance RuleInput GetParsedModuleWithComments = AllHaskellFiles
7575

7676
type instance RuleResult GetModuleGraph = DependencyInformation
77-
type instance RuleInput GetModuleGraph = '[ProjectHaskellFile]
77+
type instance RuleInput GetModuleGraph = ProjectHaskellFilesOnly
7878

7979
data GetKnownTargets = GetKnownTargets
8080
deriving (Show, Generic, Eq, Ord)
8181
instance Hashable GetKnownTargets
8282
instance NFData GetKnownTargets
8383
type instance RuleResult GetKnownTargets = KnownTargets
84-
type instance RuleInput GetKnownTargets = '[NoFile]
84+
type instance RuleInput GetKnownTargets = NoFiles
8585

8686
-- | Convert to Core, requires TypeCheck*
8787
type instance RuleResult GenerateCore = ModGuts
88-
type instance RuleInput GenerateCore = '[ProjectHaskellFile]
88+
type instance RuleInput GenerateCore = ProjectHaskellFilesOnly
8989

9090
data GenerateCore = GenerateCore
9191
deriving (Eq, Show, Typeable, Generic)
9292
instance Hashable GenerateCore
9393
instance NFData GenerateCore
9494

9595
type instance RuleResult GetLinkable = LinkableResult
96-
type instance RuleInput GetLinkable = '[ProjectHaskellFile]
96+
type instance RuleInput GetLinkable = ProjectHaskellFilesOnly
9797

9898
data LinkableResult
9999
= LinkableResult
@@ -119,7 +119,7 @@ instance Hashable GetImportMap
119119
instance NFData GetImportMap
120120

121121
type instance RuleResult GetImportMap = ImportMap
122-
type instance RuleInput GetImportMap = '[ProjectHaskellFile]
122+
type instance RuleInput GetImportMap = ProjectHaskellFilesOnly
123123
newtype ImportMap = ImportMap
124124
{ importMap :: M.Map ModuleName NormalizedFilePath -- ^ Where are the modules imported by this file located?
125125
} deriving stock Show
@@ -240,15 +240,15 @@ instance Show HieAstResult where
240240

241241
-- | The type checked version of this file, requires TypeCheck+
242242
type instance RuleResult TypeCheck = TcModuleResult
243-
type instance RuleInput TypeCheck = '[ProjectHaskellFile]
243+
type instance RuleInput TypeCheck = ProjectHaskellFilesOnly
244244

245245
-- | The uncompressed HieAST
246246
type instance RuleResult GetHieAst = HieAstResult
247-
type instance RuleInput GetHieAst = '[ProjectHaskellFile, DependencyHaskellFile]
247+
type instance RuleInput GetHieAst = AllHaskellFiles
248248

249249
-- | A IntervalMap telling us what is in scope at each point
250250
type instance RuleResult GetBindings = Bindings
251-
type instance RuleInput GetBindings = '[ProjectHaskellFile]
251+
type instance RuleInput GetBindings = ProjectHaskellFilesOnly
252252

253253
data DocAndTyThingMap = DKMap {getDocMap :: !DocMap, getTyThingMap :: !TyThingMap}
254254
instance NFData DocAndTyThingMap where
@@ -258,50 +258,50 @@ instance Show DocAndTyThingMap where
258258
show = const "docmap"
259259

260260
type instance RuleResult GetDocMap = DocAndTyThingMap
261-
type instance RuleInput GetDocMap = '[ProjectHaskellFile]
261+
type instance RuleInput GetDocMap = ProjectHaskellFilesOnly
262262

263263
-- | A GHC session that we reuse.
264264
type instance RuleResult GhcSession = HscEnvEq
265-
type instance RuleInput GhcSession = '[ProjectHaskellFile]
265+
type instance RuleInput GhcSession = ProjectHaskellFilesOnly
266266

267267
-- | A GHC session preloaded with all the dependencies
268268
-- This rule is also responsible for calling ReportImportCycles for the direct dependencies
269269
type instance RuleResult GhcSessionDeps = HscEnvEq
270-
type instance RuleInput GhcSessionDeps = '[ProjectHaskellFile]
270+
type instance RuleInput GhcSessionDeps = ProjectHaskellFilesOnly
271271

272272
-- | Resolve the imports in a module to the file path of a module in the same package
273273
type instance RuleResult GetLocatedImports = [(Located ModuleName, Maybe ArtifactsLocation)]
274-
type instance RuleInput GetLocatedImports = '[ProjectHaskellFile]
274+
type instance RuleInput GetLocatedImports = ProjectHaskellFilesOnly
275275

276276
-- | This rule is used to report import cycles. It depends on GetModuleGraph.
277277
-- We cannot report the cycles directly from GetModuleGraph since
278278
-- we can only report diagnostics for the current file.
279279
type instance RuleResult ReportImportCycles = ()
280-
type instance RuleInput ReportImportCycles = '[ProjectHaskellFile]
280+
type instance RuleInput ReportImportCycles = ProjectHaskellFilesOnly
281281

282282
-- | Read the module interface file from disk. Throws an error for VFS files.
283283
-- This is an internal rule, use 'GetModIface' instead.
284284
type instance RuleResult GetModIfaceFromDisk = HiFileResult
285-
type instance RuleInput GetModIfaceFromDisk = '[ProjectHaskellFile]
285+
type instance RuleInput GetModIfaceFromDisk = ProjectHaskellFilesOnly
286286

287287
-- | GetModIfaceFromDisk and index the `.hie` file into the database.
288288
-- This is an internal rule, use 'GetModIface' instead.
289289
type instance RuleResult GetModIfaceFromDiskAndIndex = HiFileResult
290-
type instance RuleInput GetModIfaceFromDiskAndIndex = '[ProjectHaskellFile]
290+
type instance RuleInput GetModIfaceFromDiskAndIndex = ProjectHaskellFilesOnly
291291

292292
-- | Get a module interface details, either from an interface file or a typechecked module
293293
type instance RuleResult GetModIface = HiFileResult
294-
type instance RuleInput GetModIface = '[ProjectHaskellFile, DependencyHaskellFile]
294+
type instance RuleInput GetModIface = AllHaskellFiles
295295

296296
-- | Get the contents of a file, either dirty (if the buffer is modified) or Nothing to mean use from disk.
297297
type instance RuleResult GetFileContents = (FileVersion, Maybe Text)
298-
type instance RuleInput GetFileContents = '[ProjectHaskellFile, DependencyHaskellFile]
298+
type instance RuleInput GetFileContents = AllHaskellFiles
299299

300300
type instance RuleResult GetFileExists = Bool
301-
type instance RuleInput GetFileExists = '[ProjectHaskellFile, DependencyHaskellFile]
301+
type instance RuleInput GetFileExists = AllHaskellFiles
302302

303303
type instance RuleResult AddWatchedFile = Bool
304-
type instance RuleInput AddWatchedFile = '[ProjectHaskellFile]
304+
type instance RuleInput AddWatchedFile = ProjectHaskellFilesOnly
305305

306306

307307
-- The Shake key type for getModificationTime queries
@@ -331,7 +331,7 @@ pattern GetModificationTime = GetModificationTime_ {missingFileDiagnostics=True}
331331

332332
-- | Get the modification time of a file.
333333
type instance RuleResult GetModificationTime = FileVersion
334-
type instance RuleInput GetModificationTime = '[ProjectHaskellFile, DependencyHaskellFile]
334+
type instance RuleInput GetModificationTime = AllHaskellFiles
335335

336336
-- | Either the mtime from disk or an LSP version
337337
-- LSP versions always compare as greater than on disk versions
@@ -374,7 +374,7 @@ instance Hashable IsFileOfInterestResult
374374
instance NFData IsFileOfInterestResult
375375

376376
type instance RuleResult IsFileOfInterest = IsFileOfInterestResult
377-
type instance RuleInput IsFileOfInterest = '[ProjectHaskellFile, DependencyHaskellFile]
377+
type instance RuleInput IsFileOfInterest = AllHaskellFiles
378378

379379
data ModSummaryResult = ModSummaryResult
380380
{ msrModSummary :: !ModSummary
@@ -397,11 +397,11 @@ instance NFData ModSummaryResult where
397397
-- | Generate a ModSummary that has enough information to be used to get .hi and .hie files.
398398
-- without needing to parse the entire source
399399
type instance RuleResult GetModSummary = ModSummaryResult
400-
type instance RuleInput GetModSummary = '[ProjectHaskellFile, DependencyHaskellFile]
400+
type instance RuleInput GetModSummary = AllHaskellFiles
401401

402402
-- | Generate a ModSummary with the timestamps and preprocessed content elided, for more successful early cutoff
403403
type instance RuleResult GetModSummaryWithoutTimestamps = ModSummaryResult
404-
type instance RuleInput GetModSummaryWithoutTimestamps = '[ProjectHaskellFile, DependencyHaskellFile]
404+
type instance RuleInput GetModSummaryWithoutTimestamps = AllHaskellFiles
405405

406406
data GetParsedModule = GetParsedModule
407407
deriving (Eq, Show, Typeable, Generic)
@@ -420,7 +420,7 @@ instance NFData GetLocatedImports
420420

421421
-- | Does this module need to be compiled?
422422
type instance RuleResult NeedsCompilation = Maybe LinkableType
423-
type instance RuleInput NeedsCompilation = '[ProjectHaskellFile]
423+
type instance RuleInput NeedsCompilation = ProjectHaskellFilesOnly
424424

425425
data NeedsCompilation = NeedsCompilation
426426
deriving (Eq, Show, Typeable, Generic)
@@ -514,7 +514,7 @@ instance Hashable GetClientSettings
514514
instance NFData GetClientSettings
515515

516516
type instance RuleResult GetClientSettings = Hashed (Maybe Value)
517-
type instance RuleInput GetClientSettings = '[NoFile]
517+
type instance RuleInput GetClientSettings = NoFiles
518518

519519
data AddWatchedFile = AddWatchedFile deriving (Eq, Show, Typeable, Generic)
520520
instance Hashable AddWatchedFile
@@ -525,7 +525,7 @@ instance NFData AddWatchedFile
525525
-- thread killed exception issues, so we lift it to a full rule.
526526
-- https://github.com/digital-asset/daml/pull/2808#issuecomment-529639547
527527
type instance RuleResult GhcSessionIO = IdeGhcSession
528-
type instance RuleInput GhcSessionIO = '[ProjectHaskellFile]
528+
type instance RuleInput GhcSessionIO = ProjectHaskellFilesOnly
529529

530530
data IdeGhcSession = IdeGhcSession
531531
{ loadSessionFun :: FilePath -> IO (IdeResult HscEnvEq, [FilePath])
Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
{-# LANGUAGE TypeFamilies #-}
22
module Development.IDE.Graph.Internal.RuleInput where
33

4-
type ValidInputs = [Input]
4+
data ValidInputs
5+
= ProjectHaskellFilesOnly
6+
| AllHaskellFiles
7+
| NoFiles
58

69
data Input
710
= ProjectHaskellFile
@@ -12,7 +15,10 @@ type family RuleInput k :: ValidInputs
1215

1316
class HasInput (i :: Input) (is :: ValidInputs)
1417

15-
instance HasInput i (i : is)
18+
instance HasInput ProjectHaskellFile ProjectHaskellFilesOnly
1619

17-
instance {-# OVERLAPPABLE #-}
18-
HasInput i is => HasInput i (j : is)
20+
instance HasInput ProjectHaskellFile AllHaskellFiles
21+
22+
instance HasInput DependencyHaskellFile AllHaskellFiles
23+
24+
instance HasInput NoFile NoFiles

0 commit comments

Comments
 (0)