Skip to content

Commit 31d55e2

Browse files
committed
Add haddock documentation and fix spacing
1 parent 62e878c commit 31d55e2

2 files changed

Lines changed: 21 additions & 9 deletions

File tree

ghcide/session-loader/Development/IDE/Session.hs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ import Data.List.Extra as L
4040
import qualified Data.Map.Strict as Map
4141
import Data.Maybe
4242
import Data.Proxy
43-
4443
import qualified Data.Text as T
4544
import Data.Version
4645
import Development.IDE.Core.RuleTypes
@@ -1078,10 +1077,8 @@ toFlagsMap :: TargetDetails -> [(NormalizedFilePath, (IdeResult HscEnvEq, Depend
10781077
toFlagsMap TargetDetails{..} =
10791078
[ (l, (targetEnv, targetDepends)) | l <- targetLocations]
10801079

1081-
10821080
-- | Mapping from @hie.yaml@ to all components that have been loaded
10831081
-- from this @hie.yaml@ location.
1084-
10851082
--
10861083
-- See Note [Multi Cradle Dependency Info]
10871084
type HieMap = Map.Map (Maybe FilePath) [RawComponentInfo]
@@ -1110,7 +1107,6 @@ memoIO op = do
11101107
return (Map.insert k res mp, res)
11111108
Just res -> return (mp, res)
11121109

1113-
11141110
----------------------------------------------------------------------------------------------------
11151111

11161112
data PackageSetupException

ghcide/session-loader/Development/IDE/Session/Ghc.hs

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,16 @@ instance Pretty Log where
8080
"New component cache HscEnvEq:" <+> viaShow componentCache
8181
LogDLLLoadError errorString ->
8282
"Error dynamically loading libm.so.6:" <+> pretty errorString
83-
83+
-- | Configuration info for a particular home unit.
8484
data HomeUnitConfig = HomeUnitConfig
85-
{ homeUnitDynFlags :: DynFlags
85+
{
86+
-- | The dynamic flags to compile this specific unit.
87+
homeUnitDynFlags :: DynFlags
88+
-- | All the targets for this unit.
8689
, homeUnitTargets :: [GHC.Target]
90+
-- | Optional hash seed to differentiate home units
91+
-- with same `-this-unit-id`. Used when `-this-unit-id` is "main"
92+
-- , common when loading a single target.
8793
, homeUnitHash :: Maybe B.ByteString
8894
}
8995
-- This is pristine information about a component
@@ -101,7 +107,7 @@ data RawComponentInfo = RawComponentInfo
101107
-- | Maps cradle dependencies, such as `stack.yaml`, or `.cabal` file
102108
-- to last modification time. See Note [Multi Cradle Dependency Info].
103109
, rawComponentDependencyInfo :: DependencyInfo
104-
-- | The raw ByteString for the hash generated in setoptions for the uid "main"
110+
-- | An optional hash seed generated in 'setOptions' for the unit id "main".
105111
, rawComponentHash :: Maybe B.ByteString
106112
}
107113

@@ -431,13 +437,23 @@ setCacheDirs recorder CacheDirs{..} dflags = do
431437
& maybe id setHieDir hieCacheDir
432438
& maybe id setODir oCacheDir
433439

440+
-- | Append the hash to the unit id to create unique cache folders.
441+
--
442+
-- This function generates a single, unified hash.
443+
-- If an optional base hash (@mFirstHash@) is provided—which
444+
-- is common for a single target with `-this-unit-id` as "main"-
445+
-- we set the prefix to "main", extract the context generated
446+
-- from the @mFirstHash@, and update the @opts@ into the same hash.
447+
--
448+
-- This guarantees a unique cache folder for different GHC
449+
-- options(avoiding incompatible interface files) while
450+
-- keeping the path short and clean.
434451
getCacheDirsDefault :: String -> Maybe B.ByteString -> [String] -> IO CacheDirs
435452
getCacheDirsDefault prefix mFirstHash opts = do
436453
dir <- Just <$> getXdgDirectory XdgCache (cacheDir </> prefix' ++ "-" ++ opts_hash)
437454
return $ CacheDirs dir dir dir
438455
where
439-
-- Create a unique folder per set of different GHC options, assuming that each different set of
440-
-- GHC options will create incompatible interface files.
456+
-- Create a unique folder per set of different GHC options.
441457
prefix' = if isJust mFirstHash then "main" else prefix
442458
basectx = case mFirstHash of
443459
Just h -> H.updates H.init [h]

0 commit comments

Comments
 (0)