ghc-9.6.3: The GHC API
Safe HaskellSafe-Inferred
LanguageHaskell2010

GHC.Core.RoughMap

Description

RoughMap is an approximate finite map data structure keyed on [RoughMatchTc]. This is useful when keying maps on lists of Types (e.g. an instance head).

Synopsis

RoughMatchTc

data RoughMatchTc Source #

Constructors

RM_KnownTc Name 
RM_WildCard 

Instances

Instances details
Data RoughMatchTc Source # 
Instance details

Defined in GHC.Core.RoughMap

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> RoughMatchTc -> c RoughMatchTc Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c RoughMatchTc Source #

toConstr :: RoughMatchTc -> Constr Source #

dataTypeOf :: RoughMatchTc -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c RoughMatchTc) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c RoughMatchTc) Source #

gmapT :: (forall b. Data b => b -> b) -> RoughMatchTc -> RoughMatchTc Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> RoughMatchTc -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> RoughMatchTc -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> RoughMatchTc -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> RoughMatchTc -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> RoughMatchTc -> m RoughMatchTc Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> RoughMatchTc -> m RoughMatchTc Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> RoughMatchTc -> m RoughMatchTc Source #

Outputable RoughMatchTc Source # 
Instance details

Defined in GHC.Core.RoughMap

data RoughMatchLookupTc Source #

Constructors

RML_KnownTc Name

The position only matches the specified KnownTc

RML_NoKnownTc

The position definitely doesn't match any KnownTc

RML_WildCard

The position can match anything

Instances

Instances details
Data RoughMatchLookupTc Source # 
Instance details

Defined in GHC.Core.RoughMap

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> RoughMatchLookupTc -> c RoughMatchLookupTc Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c RoughMatchLookupTc Source #

toConstr :: RoughMatchLookupTc -> Constr Source #

dataTypeOf :: RoughMatchLookupTc -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c RoughMatchLookupTc) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c RoughMatchLookupTc) Source #

gmapT :: (forall b. Data b => b -> b) -> RoughMatchLookupTc -> RoughMatchLookupTc Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> RoughMatchLookupTc -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> RoughMatchLookupTc -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> RoughMatchLookupTc -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> RoughMatchLookupTc -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> RoughMatchLookupTc -> m RoughMatchLookupTc Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> RoughMatchLookupTc -> m RoughMatchLookupTc Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> RoughMatchLookupTc -> m RoughMatchLookupTc Source #

Outputable RoughMatchLookupTc Source # 
Instance details

Defined in GHC.Core.RoughMap

RoughMap

data RoughMap a Source #

Trie of [RoughMatchTc]

  • Examples* insert [OtherTc] 1 insert [OtherTc] 2 lookup [OtherTc] == [1,2]

Instances

Instances details
Functor RoughMap Source # 
Instance details

Defined in GHC.Core.RoughMap

Methods

fmap :: (a -> b) -> RoughMap a -> RoughMap b Source #

(<$) :: a -> RoughMap b -> RoughMap a Source #

Outputable a => Outputable (RoughMap a) Source # 
Instance details

Defined in GHC.Core.RoughMap

Methods

ppr :: RoughMap a -> SDoc Source #

lookupRM :: [RoughMatchLookupTc] -> RoughMap a -> [a] Source #

Order of result is deterministic.

lookupRM' :: [RoughMatchLookupTc] -> RoughMap a -> (Bag a, [a]) Source #

N.B. Returns a Bag for matches, which allows us to avoid rebuilding all of the lists we find in rm_empty, which would otherwise be necessary due to ++ if we returned a list. We use a list for unifiers because the tail is computed lazily and we often only care about the first couple of potential unifiers. Constructing a bag forces the tail which performs much too much work.

See Note [Matching a RoughMap] See Note [Matches vs Unifiers]

filterRM :: (a -> Bool) -> RoughMap a -> RoughMap a Source #

filterMatchingRM :: (a -> Bool) -> [RoughMatchTc] -> RoughMap a -> RoughMap a Source #

Filter all elements that might match a particular key with the given predicate.

elemsRM :: RoughMap a -> [a] Source #

foldRM :: (a -> b -> b) -> b -> RoughMap a -> b Source #