1-- Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
2-- SPDX-License-Identifier: Apache-2.0
4{-# LANGUAGE FlexibleInstances #-}
5{-# LANGUAGE TypeFamilies #-}
6{-# OPTIONS_GHC -Wno-orphans #-}
8-- | A Shake implementation of the compiler service, built
9-- using the "Shaker" abstraction layer for in-memory use.
11module Development.IDE.State.RuleTypes(
12 module Development.IDE.State.RuleTypes
16import Development.IDE.Functions.Compile (TcModuleResult, GhcModule, LoadPackageResult(..))
17import qualified Development.IDE.Functions.Compile as Compile
18import Development.IDE.Functions.FindImports (Import(..))
19import Development.IDE.Functions.DependencyInformation
22import Development.Shake hiding (Env, newCache)
23import GHC.Generics (Generic)
26import Development.IDE.Compat
29import Development.IDE.Types.SpanInfo
33-- Foo+ means Foo for the dependencies
34-- Foo* means Foo for me and Foo+
37type instance RuleResult OfInterest = ()
39-- | The parse tree for the file using GetFileContents
40type instance RuleResult GetParsedModule = ParsedModule
42-- | The dependency information produced by following the imports recursively.
43-- This rule will succeed even if there is an error, e.g., a module could not be located,
44-- a module could not be parsed or an import cycle.
45type instance RuleResult GetDependencyInformation = DependencyInformation
47-- | Transitive module and pkg dependencies based on the information produced by GetDependencyInformation.
48-- This rule is also responsible for calling ReportImportCycles for each file in the transitive closure.
49type instance RuleResult GetDependencies = TransitiveDependencies
51-- | The type checked version of this file, requires TypeCheck+
52type instance RuleResult TypeCheck = TcModuleResult
54-- | Information about what spans occur where, requires TypeCheck
55type instance RuleResult GetSpanInfo = [SpanInfo]
57-- | Convert to Core, requires TypeCheck*
58type instance RuleResult GenerateCore = GhcModule
60-- | A GHC session that we reuse.
61type instance RuleResult GhcSession = HscEnv
63-- | Resolve the imports in a module to the list of either external packages or absolute file paths
64-- for modules in the same package.
65type instance RuleResult GetLocatedImports = [(Located ModuleName, Maybe Import)]
67-- | This rule is used to report import cycles. It depends on GetDependencyInformation.
68-- We cannot report the cycles directly from GetDependencyInformation since
69-- we can only report diagnostics for the current file.
70type instance RuleResult ReportImportCycles = ()
72-- | Read the given HIE file.
73type instance RuleResult GetHieFile = HieFile
76data OfInterest = OfInterest
77 deriving (Eq, Show, Typeable, Generic)
78instance Hashable OfInterest
79instance NFData OfInterest
81data GetParsedModule = GetParsedModule
82 deriving (Eq, Show, Typeable, Generic)
83instance Hashable GetParsedModule
84instance NFData GetParsedModule
86data GetLocatedImports = GetLocatedImports
87 deriving (Eq, Show, Typeable, Generic)
88instance Hashable GetLocatedImports
89instance NFData GetLocatedImports
91data GetDependencyInformation = GetDependencyInformation
92 deriving (Eq, Show, Typeable, Generic)
93instance Hashable GetDependencyInformation
94instance NFData GetDependencyInformation
96data ReportImportCycles = ReportImportCycles
97 deriving (Eq, Show, Typeable, Generic)
98instance Hashable ReportImportCycles
99instance NFData ReportImportCycles
101data GetDependencies = GetDependencies
102 deriving (Eq, Show, Typeable, Generic)
103instance Hashable GetDependencies
104instance NFData GetDependencies
106data TypeCheck = TypeCheck
107 deriving (Eq, Show, Typeable, Generic)
108instance Hashable TypeCheck
109instance NFData TypeCheck
111data GetSpanInfo = GetSpanInfo
112 deriving (Eq, Show, Typeable, Generic)
113instance Hashable GetSpanInfo
114instance NFData GetSpanInfo
116data GenerateCore = GenerateCore
117 deriving (Eq, Show, Typeable, Generic)
118instance Hashable GenerateCore
119instance NFData GenerateCore
121data GhcSession = GhcSession
122 deriving (Eq, Show, Typeable, Generic)
123instance Hashable GhcSession
124instance NFData GhcSession
126-- Note that we embed the filepath here instead of using the filepath associated with Shake keys.
127-- Otherwise we will garbage collect the result since files in package dependencies will not be declared reachable.
128data GetHieFile = GetHieFile FilePath
129 deriving (Eq, Show, Typeable, Generic)
130instance Hashable GetHieFile
131instance NFData GetHieFile
133------------------------------------------------------------
136instance NFData (GenLocated SrcSpan ModuleName) where
139instance Show TcModuleResult where
140 show = show . pm_mod_summary . tm_parsed_module . Compile.tmrModule
142instance NFData TcModuleResult where
145instance Show ModSummary where
148instance Show ParsedModule where
149 show = show . pm_mod_summary
151instance NFData ModSummary where
154instance Show HscEnv where
157instance NFData HscEnv where
160instance NFData ParsedModule where
163instance NFData SpanInfo where
166instance NFData Import where
169instance Hashable InstalledUnitId where
170 hashWithSalt salt = hashWithSalt salt . installedUnitIdString
172instance Show LoadPackageResult where
173 show = installedUnitIdString . lprInstalledUnitId
175instance NFData LoadPackageResult where
178instance Show HieFile where
179 show = show . hie_module
181instance NFData HieFile where
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list