GHC.Data.TrieMap

ghc-lib-parser-9.14.1.20251220: The GHC API, decoupled from GHC versions

Safe Haskell | Ignore
Language | GHC2021

GHC.Data.TrieMap

Contents

- Maps over `Maybe` values
- Maps over `List` values
- `TrieMap` class
- Things helpful for adding additional Instances.
- Map for leaf compression

Synopsis

- data MaybeMap (m :: Type -> Type) a
- data ListMap (m :: Type -> Type) a
- class Functor m => TrieMap (m :: Type -> Type) where
  - type Key (m :: Type -> Type)
  - emptyTM :: m a
  - lookupTM :: Key m -> m b -> Maybe b
  - alterTM :: Key m -> XT b -> m b -> m b
  - filterTM :: (a -> Bool) -> m a -> m a
  - mapMaybeTM :: (a -> Maybe b) -> m a -> m b
  - foldTM :: (a -> b -> b) -> m a -> b -> b
- insertTM :: TrieMap m => Key m -> a -> m a -> m a
- deleteTM :: TrieMap m => Key m -> m a -> m a
- foldMapTM :: (TrieMap m, Monoid r) => (a -> r) -> m a -> r
- isEmptyTM :: TrieMap m => m a -> Bool
- (>.>) :: (a -> b) -> (b -> c) -> a -> c
- (|>) :: a -> (a -> b) -> b
- (|>>) :: TrieMap m2 => (XT (m2 a) -> m1 (m2 a) -> m1 (m2 a)) -> (m2 a -> m2 a) -> m1 (m2 a) -> m1 (m2 a)
- type XT a = Maybe a -> Maybe a
- foldMaybe :: (a -> b -> b) -> Maybe a -> b -> b
- filterMaybe :: (a -> Bool) -> Maybe a -> Maybe a
- data GenMap (m :: Type -> Type) a
- lkG :: forall (m :: Type -> Type) a. (Eq (Key m), TrieMap m) => Key m -> GenMap m a -> Maybe a
- xtG :: forall (m :: Type -> Type) a. (Eq (Key m), TrieMap m) => Key m -> XT a -> GenMap m a -> GenMap m a
- mapG :: forall (m :: Type -> Type) a b. Functor m => (a -> b) -> GenMap m a -> GenMap m b
- fdG :: forall (m :: Type -> Type) a b. TrieMap m => (a -> b -> b) -> GenMap m a -> b -> b
- xtList :: TrieMap m => (forall b. k -> XT b -> m b -> m b) -> [k] -> XT a -> ListMap m a -> ListMap m a
- lkList :: TrieMap m => (forall b. k -> m b -> Maybe b) -> [k] -> ListMap m a -> Maybe a

# Maps over `Maybe` values

data MaybeMap (m :: Type -> Type) a #

#### Instances

Instances details

Functor m => Functor (MaybeMap m) # |
Instance details Defined in GHC.Data.TrieMap Methods fmap :: (a -> b) -> MaybeMap m a -> MaybeMap m b # (<$) :: a -> MaybeMap m b -> MaybeMap m a #
TrieMap m => Foldable (MaybeMap m) # |
Instance details Defined in GHC.Data.TrieMap Methods fold :: Monoid m0 => MaybeMap m m0 -> m0 # foldMap :: Monoid m0 => (a -> m0) -> MaybeMap m a -> m0 # foldMap' :: Monoid m0 => (a -> m0) -> MaybeMap m a -> m0 # foldr :: (a -> b -> b) -> b -> MaybeMap m a -> b # foldr' :: (a -> b -> b) -> b -> MaybeMap m a -> b # foldl :: (b -> a -> b) -> b -> MaybeMap m a -> b # foldl' :: (b -> a -> b) -> b -> MaybeMap m a -> b # foldr1 :: (a -> a -> a) -> MaybeMap m a -> a # foldl1 :: (a -> a -> a) -> MaybeMap m a -> a # toList :: MaybeMap m a -> [a] # null :: MaybeMap m a -> Bool # length :: MaybeMap m a -> Int # elem :: Eq a => a -> MaybeMap m a -> Bool # maximum :: Ord a => MaybeMap m a -> a # minimum :: Ord a => MaybeMap m a -> a # sum :: Num a => MaybeMap m a -> a # product :: Num a => MaybeMap m a -> a #
TrieMap m => TrieMap (MaybeMap m) # |
Instance details Defined in GHC.Data.TrieMap Associated Types
type Key (MaybeMap m) |
Instance details Defined in GHC.Data.TrieMap type Key (MaybeMap m) = Maybe (Key m)
Methods emptyTM :: MaybeMap m a # lookupTM :: Key (MaybeMap m) -> MaybeMap m b -> Maybe b # alterTM :: Key (MaybeMap m) -> XT b -> MaybeMap m b -> MaybeMap m b # filterTM :: (a -> Bool) -> MaybeMap m a -> MaybeMap m a # mapMaybeTM :: (a -> Maybe b) -> MaybeMap m a -> MaybeMap m b # foldTM :: (a -> b -> b) -> MaybeMap m a -> b -> b #
type Key (MaybeMap m) # |
Instance details Defined in GHC.Data.TrieMap type Key (MaybeMap m) = Maybe (Key m)

# Maps over `List` values

data ListMap (m :: Type -> Type) a #

#### Instances

Instances details

Functor m => Functor (ListMap m) # |
Instance details Defined in GHC.Data.TrieMap Methods fmap :: (a -> b) -> ListMap m a -> ListMap m b # (<$) :: a -> ListMap m b -> ListMap m a #
TrieMap m => Foldable (ListMap m) # |
Instance details Defined in GHC.Data.TrieMap Methods fold :: Monoid m0 => ListMap m m0 -> m0 # foldMap :: Monoid m0 => (a -> m0) -> ListMap m a -> m0 # foldMap' :: Monoid m0 => (a -> m0) -> ListMap m a -> m0 # foldr :: (a -> b -> b) -> b -> ListMap m a -> b # foldr' :: (a -> b -> b) -> b -> ListMap m a -> b # foldl :: (b -> a -> b) -> b -> ListMap m a -> b # foldl' :: (b -> a -> b) -> b -> ListMap m a -> b # foldr1 :: (a -> a -> a) -> ListMap m a -> a # foldl1 :: (a -> a -> a) -> ListMap m a -> a # toList :: ListMap m a -> [a] # null :: ListMap m a -> Bool # length :: ListMap m a -> Int # elem :: Eq a => a -> ListMap m a -> Bool # maximum :: Ord a => ListMap m a -> a # minimum :: Ord a => ListMap m a -> a # sum :: Num a => ListMap m a -> a # product :: Num a => ListMap m a -> a #
TrieMap m => TrieMap (ListMap m) # |
Instance details Defined in GHC.Data.TrieMap Associated Types
type Key (ListMap m) |
Instance details Defined in GHC.Data.TrieMap type Key (ListMap m) = [Key m]
Methods emptyTM :: ListMap m a # lookupTM :: Key (ListMap m) -> ListMap m b -> Maybe b # alterTM :: Key (ListMap m) -> XT b -> ListMap m b -> ListMap m b # filterTM :: (a -> Bool) -> ListMap m a -> ListMap m a # mapMaybeTM :: (a -> Maybe b) -> ListMap m a -> ListMap m b # foldTM :: (a -> b -> b) -> ListMap m a -> b -> b #
(TrieMap m, Outputable a) => Outputable (ListMap m a) # |
Instance details Defined in GHC.Data.TrieMap Methods ppr :: ListMap m a -> SDoc #
type Key (ListMap m) # |
Instance details Defined in GHC.Data.TrieMap type Key (ListMap m) = [Key m]

# `TrieMap` class

class Functor m => TrieMap (m :: Type -> Type) where #

Associated Types

type Key (m :: Type -> Type) #

Methods

emptyTM :: m a #

lookupTM :: Key m -> m b -> Maybe b #

alterTM :: Key m -> XT b -> m b -> m b #

filterTM :: (a -> Bool) -> m a -> m a #

mapMaybeTM :: (a -> Maybe b) -> m a -> m b #

foldTM :: (a -> b -> b) -> m a -> b -> b #

#### Instances

Instances details

TrieMap IntMap # |
Instance details Defined in GHC.Data.TrieMap Associated Types
type Key IntMap |
Instance details Defined in GHC.Data.TrieMap type Key IntMap = Int
Methods emptyTM :: IntMap a # lookupTM :: Key IntMap -> IntMap b -> Maybe b # alterTM :: Key IntMap -> XT b -> IntMap b -> IntMap b # filterTM :: (a -> Bool) -> IntMap a -> IntMap a # mapMaybeTM :: (a -> Maybe b) -> IntMap a -> IntMap b # foldTM :: (a -> b -> b) -> IntMap a -> b -> b #
TrieMap LabelMap # |
Instance details Defined in GHC.Cmm.Dataflow.Label Associated Types
type Key LabelMap |
Instance details Defined in GHC.Cmm.Dataflow.Label type Key LabelMap = Label
Methods emptyTM :: LabelMap a # lookupTM :: Key LabelMap -> LabelMap b -> Maybe b # alterTM :: Key LabelMap -> XT b -> LabelMap b -> LabelMap b # filterTM :: (a -> Bool) -> LabelMap a -> LabelMap a # mapMaybeTM :: (a -> Maybe b) -> LabelMap a -> LabelMap b # foldTM :: (a -> b -> b) -> LabelMap a -> b -> b #
TrieMap CoreMap # |
Instance details Defined in GHC.Core.Map.Expr Associated Types
type Key CoreMap |
Instance details Defined in GHC.Core.Map.Expr type Key CoreMap = CoreExpr
Methods emptyTM :: CoreMap a # lookupTM :: Key CoreMap -> CoreMap b -> Maybe b # alterTM :: Key CoreMap -> XT b -> CoreMap b -> CoreMap b # filterTM :: (a -> Bool) -> CoreMap a -> CoreMap a # mapMaybeTM :: (a -> Maybe b) -> CoreMap a -> CoreMap b # foldTM :: (a -> b -> b) -> CoreMap a -> b -> b #
TrieMap BndrMap # |
Instance details Defined in GHC.Core.Map.Type Associated Types
type Key BndrMap |
Instance details Defined in GHC.Core.Map.Type type Key BndrMap = Var
Methods emptyTM :: BndrMap a # lookupTM :: Key BndrMap -> BndrMap b -> Maybe b # alterTM :: Key BndrMap -> XT b -> BndrMap b -> BndrMap b # filterTM :: (a -> Bool) -> BndrMap a -> BndrMap a # mapMaybeTM :: (a -> Maybe b) -> BndrMap a -> BndrMap b # foldTM :: (a -> b -> b) -> BndrMap a -> b -> b #
TrieMap LooseTypeMap # |
Instance details Defined in GHC.Core.Map.Type Associated Types
type Key LooseTypeMap |
Instance details Defined in GHC.Core.Map.Type type Key LooseTypeMap = Type
Methods emptyTM :: LooseTypeMap a # lookupTM :: Key LooseTypeMap -> LooseTypeMap b -> Maybe b # alterTM :: Key LooseTypeMap -> XT b -> LooseTypeMap b -> LooseTypeMap b # filterTM :: (a -> Bool) -> LooseTypeMap a -> LooseTypeMap a # mapMaybeTM :: (a -> Maybe b) -> LooseTypeMap a -> LooseTypeMap b # foldTM :: (a -> b -> b) -> LooseTypeMap a -> b -> b #
TrieMap TypeMap # |
Instance details Defined in GHC.Core.Map.Type Associated Types
type Key TypeMap |
Instance details Defined in GHC.Core.Map.Type type Key TypeMap = Type
Methods emptyTM :: TypeMap a # lookupTM :: Key TypeMap -> TypeMap b -> Maybe b # alterTM :: Key TypeMap -> XT b -> TypeMap b -> TypeMap b # filterTM :: (a -> Bool) -> TypeMap a -> TypeMap a # mapMaybeTM :: (a -> Maybe b) -> TypeMap a -> TypeMap b # foldTM :: (a -> b -> b) -> TypeMap a -> b -> b #
TrieMap VarMap # |
Instance details Defined in GHC.Core.Map.Type Associated Types
type Key VarMap |
Instance details Defined in GHC.Core.Map.Type type Key VarMap = Var
Methods emptyTM :: VarMap a # lookupTM :: Key VarMap -> VarMap b -> Maybe b # alterTM :: Key VarMap -> XT b -> VarMap b -> VarMap b # filterTM :: (a -> Bool) -> VarMap a -> VarMap a # mapMaybeTM :: (a -> Maybe b) -> VarMap a -> VarMap b # foldTM :: (a -> b -> b) -> VarMap a -> b -> b #
Ord k => TrieMap (Map k) # |
Instance details Defined in GHC.Data.TrieMap Associated Types
type Key (Map k) |
Instance details Defined in GHC.Data.TrieMap type Key (Map k) = k
Methods emptyTM :: Map k a # lookupTM :: Key (Map k) -> Map k b -> Maybe b # alterTM :: Key (Map k) -> XT b -> Map k b -> Map k b # filterTM :: (a -> Bool) -> Map k a -> Map k a # mapMaybeTM :: (a -> Maybe b) -> Map k a -> Map k b # foldTM :: (a -> b -> b) -> Map k a -> b -> b #
(Eq (Key m), TrieMap m) => TrieMap (GenMap m) # |
Instance details Defined in GHC.Data.TrieMap Associated Types
type Key (GenMap m) |
Instance details Defined in GHC.Data.TrieMap type Key (GenMap m) = Key m
Methods emptyTM :: GenMap m a # lookupTM :: Key (GenMap m) -> GenMap m b -> Maybe b # alterTM :: Key (GenMap m) -> XT b -> GenMap m b -> GenMap m b # filterTM :: (a -> Bool) -> GenMap m a -> GenMap m a # mapMaybeTM :: (a -> Maybe b) -> GenMap m a -> GenMap m b # foldTM :: (a -> b -> b) -> GenMap m a -> b -> b #
TrieMap m => TrieMap (ListMap m) # |
Instance details Defined in GHC.Data.TrieMap Associated Types
type Key (ListMap m) |
Instance details Defined in GHC.Data.TrieMap type Key (ListMap m) = [Key m]
Methods emptyTM :: ListMap m a # lookupTM :: Key (ListMap m) -> ListMap m b -> Maybe b # alterTM :: Key (ListMap m) -> XT b -> ListMap m b -> ListMap m b # filterTM :: (a -> Bool) -> ListMap m a -> ListMap m a # mapMaybeTM :: (a -> Maybe b) -> ListMap m a -> ListMap m b # foldTM :: (a -> b -> b) -> ListMap m a -> b -> b #
TrieMap m => TrieMap (MaybeMap m) # |
Instance details Defined in GHC.Data.TrieMap Associated Types
type Key (MaybeMap m) |
Instance details Defined in GHC.Data.TrieMap type Key (MaybeMap m) = Maybe (Key m)
Methods emptyTM :: MaybeMap m a # lookupTM :: Key (MaybeMap m) -> MaybeMap m b -> Maybe b # alterTM :: Key (MaybeMap m) -> XT b -> MaybeMap m b -> MaybeMap m b # filterTM :: (a -> Bool) -> MaybeMap m a -> MaybeMap m a # mapMaybeTM :: (a -> Maybe b) -> MaybeMap m a -> MaybeMap m b # foldTM :: (a -> b -> b) -> MaybeMap m a -> b -> b #
Uniquable key => TrieMap (UniqDFM key) # |
Instance details Defined in GHC.Data.TrieMap Associated Types
type Key (UniqDFM key) |
Instance details Defined in GHC.Data.TrieMap type Key (UniqDFM key) = key
Methods emptyTM :: UniqDFM key a # lookupTM :: Key (UniqDFM key) -> UniqDFM key b -> Maybe b # alterTM :: Key (UniqDFM key) -> XT b -> UniqDFM key b -> UniqDFM key b # filterTM :: (a -> Bool) -> UniqDFM key a -> UniqDFM key a # mapMaybeTM :: (a -> Maybe b) -> UniqDFM key a -> UniqDFM key b # foldTM :: (a -> b -> b) -> UniqDFM key a -> b -> b #

insertTM :: TrieMap m => Key m -> a -> m a -> m a #

deleteTM :: TrieMap m => Key m -> m a -> m a #

foldMapTM :: (TrieMap m, Monoid r) => (a -> r) -> m a -> r #

isEmptyTM :: TrieMap m => m a -> Bool #

# Things helpful for adding additional Instances.

(>.>) :: (a -> b) -> (b -> c) -> a -> c infixr 1 #

(|>) :: a -> (a -> b) -> b infixr 1 #

(|>>) :: TrieMap m2 => (XT (m2 a) -> m1 (m2 a) -> m1 (m2 a)) -> (m2 a -> m2 a) -> m1 (m2 a) -> m1 (m2 a) infixr 1 #

type XT a = Maybe a -> Maybe a #

foldMaybe :: (a -> b -> b) -> Maybe a -> b -> b #

filterMaybe :: (a -> Bool) -> Maybe a -> Maybe a #

# Map for leaf compression

data GenMap (m :: Type -> Type) a #

#### Instances

Instances details

Functor m => Functor (GenMap m) # |
Instance details Defined in GHC.Data.TrieMap Methods fmap :: (a -> b) -> GenMap m a -> GenMap m b # (<$) :: a -> GenMap m b -> GenMap m a #
(Eq (Key m), TrieMap m) => Foldable (GenMap m) # |
Instance details Defined in GHC.Data.TrieMap Methods fold :: Monoid m0 => GenMap m m0 -> m0 # foldMap :: Monoid m0 => (a -> m0) -> GenMap m a -> m0 # foldMap' :: Monoid m0 => (a -> m0) -> GenMap m a -> m0 # foldr :: (a -> b -> b) -> b -> GenMap m a -> b # foldr' :: (a -> b -> b) -> b -> GenMap m a -> b # foldl :: (b -> a -> b) -> b -> GenMap m a -> b # foldl' :: (b -> a -> b) -> b -> GenMap m a -> b # foldr1 :: (a -> a -> a) -> GenMap m a -> a # foldl1 :: (a -> a -> a) -> GenMap m a -> a # toList :: GenMap m a -> [a] # null :: GenMap m a -> Bool # length :: GenMap m a -> Int # elem :: Eq a => a -> GenMap m a -> Bool # maximum :: Ord a => GenMap m a -> a # minimum :: Ord a => GenMap m a -> a # sum :: Num a => GenMap m a -> a # product :: Num a => GenMap m a -> a #
(Eq (Key m), TrieMap m) => TrieMap (GenMap m) # |
Instance details Defined in GHC.Data.TrieMap Associated Types
type Key (GenMap m) |
Instance details Defined in GHC.Data.TrieMap type Key (GenMap m) = Key m
Methods emptyTM :: GenMap m a # lookupTM :: Key (GenMap m) -> GenMap m b -> Maybe b # alterTM :: Key (GenMap m) -> XT b -> GenMap m b -> GenMap m b # filterTM :: (a -> Bool) -> GenMap m a -> GenMap m a # mapMaybeTM :: (a -> Maybe b) -> GenMap m a -> GenMap m b # foldTM :: (a -> b -> b) -> GenMap m a -> b -> b #
Outputable a => Outputable (TypeMapG a) # |
Instance details Defined in GHC.Core.Map.Type Methods ppr :: TypeMapG a -> SDoc #
(Outputable a, Outputable (m a)) => Outputable (GenMap m a) # |
Instance details Defined in GHC.Data.TrieMap Methods ppr :: GenMap m a -> SDoc #
type Key (GenMap m) # |
Instance details Defined in GHC.Data.TrieMap type Key (GenMap m) = Key m

lkG :: forall (m :: Type -> Type) a. (Eq (Key m), TrieMap m) => Key m -> GenMap m a -> Maybe a #

xtG :: forall (m :: Type -> Type) a. (Eq (Key m), TrieMap m) => Key m -> XT a -> GenMap m a -> GenMap m a #

mapG :: forall (m :: Type -> Type) a b. Functor m => (a -> b) -> GenMap m a -> GenMap m b #

fdG :: forall (m :: Type -> Type) a b. TrieMap m => (a -> b -> b) -> GenMap m a -> b -> b #

xtList :: TrieMap m => (forall b. k -> XT b -> m b -> m b) -> [k] -> XT a -> ListMap m a -> ListMap m a #

lkList :: TrieMap m => (forall b. k -> m b -> Maybe b) -> [k] -> ListMap m a -> Maybe a #