ghcide-2.9.0.0: The core of an IDE

Safe Haskell | None
Language | GHC2021

Development.IDE.Types.KnownTargets

Synopsis

- data KnownTargets = KnownTargets {
  - targetMap :: !(HashMap Target (HashSet NormalizedFilePath))
  - normalisingMap :: !(HashMap Target Target)
  }
- emptyKnownTargets :: KnownTargets
- mkKnownTargets :: [(Target, HashSet NormalizedFilePath)] -> KnownTargets
- unionKnownTargets :: KnownTargets -> KnownTargets -> KnownTargets
- data Target
  - = TargetModule ModuleName
  - | TargetFile NormalizedFilePath
- toKnownFiles :: KnownTargets -> HashSet NormalizedFilePath

# Documentation

data KnownTargets #

A mapping of module name to known files

Constructors

KnownTargets |

Fields

- targetMap :: !(HashMap Target (HashSet NormalizedFilePath))
- normalisingMap :: !(HashMap Target Target)

  `normalisingMap` is a cached copy of `HMap.mapKey const targetMap`

  At startup `GetLocatedImports` is called on all known files. Say you have 10000 modules in your project then this leads to 10000 calls to `GetLocatedImports` running concurrently.

  In `GetLocatedImports` the known targets are consulted and the targetsMap is created by mapping the known targets. This map is used for introducing sharing amongst filepaths. This operation copies a local copy of the `target` map which is local to the rule.

      let targetsMap = HMap.mapWithKey const targets

  So now each rule has a `HashMap` of size 10000 held locally to it and depending on how the threads are scheduled there will be 10000^2 elements in total allocated in `HashMap`s. This used a lot of memory.

  Solution: Return the `normalisingMap` in the result of the `GetKnownTargets` rule so it is shared across threads.

#### Instances

Instances details

NFData KnownTargets # |
Instance details Defined in Development.IDE.Types.KnownTargets Methods rnf :: KnownTargets -> () #
Show KnownTargets # |
Instance details Defined in Development.IDE.Types.KnownTargets Methods showsPrec :: Int -> KnownTargets -> ShowS # show :: KnownTargets -> String # showList :: [KnownTargets] -> ShowS #
Eq KnownTargets # |
Instance details Defined in Development.IDE.Types.KnownTargets Methods (==) :: KnownTargets -> KnownTargets -> Bool # (/=) :: KnownTargets -> KnownTargets -> Bool #
Hashable KnownTargets # |
Instance details Defined in Development.IDE.Types.KnownTargets Methods hashWithSalt :: Int -> KnownTargets -> Int # hash :: KnownTargets -> Int #

emptyKnownTargets :: KnownTargets #

mkKnownTargets :: [(Target, HashSet NormalizedFilePath)] -> KnownTargets #

unionKnownTargets :: KnownTargets -> KnownTargets -> KnownTargets #

data Target #

Constructors

TargetModule ModuleName |
TargetFile NormalizedFilePath |

#### Instances

Instances details

NFData Target # |
Instance details Defined in Development.IDE.Types.KnownTargets Methods rnf :: Target -> () #
Generic Target # |

Instance details

Defined in Development.IDE.Types.KnownTargets

Associated Types

type Rep Target |

Instance details

Defined in Development.IDE.Types.KnownTargets

type Rep Target = D1 ('MetaData "Target" "Development.IDE.Types.KnownTargets" "ghcide-2.9.0.0-1G3u1vh8JKWDpMQ8kfXrG1" 'False) (C1 ('MetaCons "TargetModule" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ModuleName)) :+: C1 ('MetaCons "TargetFile" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 NormalizedFilePath)))

Methods

from :: Target -> Rep Target x #

to :: Rep Target x -> Target #

Show Target # |
Instance details Defined in Development.IDE.Types.KnownTargets Methods showsPrec :: Int -> Target -> ShowS # show :: Target -> String # showList :: [Target] -> ShowS #
Eq Target # |
Instance details Defined in Development.IDE.Types.KnownTargets Methods (==) :: Target -> Target -> Bool # (/=) :: Target -> Target -> Bool #
Ord Target # |
Instance details Defined in Development.IDE.Types.KnownTargets Methods compare :: Target -> Target -> Ordering # (<) :: Target -> Target -> Bool # (<=) :: Target -> Target -> Bool # (>) :: Target -> Target -> Bool # (>=) :: Target -> Target -> Bool # max :: Target -> Target -> Target # min :: Target -> Target -> Target #
Hashable Target # |
Instance details Defined in Development.IDE.Types.KnownTargets Methods hashWithSalt :: Int -> Target -> Int # hash :: Target -> Int #
type Rep Target # |

Instance details

Defined in Development.IDE.Types.KnownTargets

type Rep Target = D1 ('MetaData "Target" "Development.IDE.Types.KnownTargets" "ghcide-2.9.0.0-1G3u1vh8JKWDpMQ8kfXrG1" 'False) (C1 ('MetaCons "TargetModule" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ModuleName)) :+: C1 ('MetaCons "TargetFile" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 NormalizedFilePath)))

toKnownFiles :: KnownTargets -> HashSet NormalizedFilePath #