TrieMap

ghc-8.4.4: The GHC API

Safe Haskell | None
Language | Haskell2010

TrieMap

Contents

- Maps over Core expressions
- Maps over `Type`s
  - With explicit scoping
- Maps over `Maybe` values
- Maps over `List` values
- Maps over `Literal`s
- `TrieMap` class

Synopsis

- data CoreMap a
- emptyCoreMap :: CoreMap a
- extendCoreMap :: CoreMap a -> CoreExpr -> a -> CoreMap a
- lookupCoreMap :: CoreMap a -> CoreExpr -> Maybe a
- foldCoreMap :: (a -> b -> b) -> b -> CoreMap a -> b
- data TypeMap a
- emptyTypeMap :: TypeMap a
- extendTypeMap :: TypeMap a -> Type -> a -> TypeMap a
- lookupTypeMap :: TypeMap a -> Type -> Maybe a
- foldTypeMap :: (a -> b -> b) -> b -> TypeMap a -> b
- data LooseTypeMap a
- data CmEnv
- lookupCME :: CmEnv -> Var -> Maybe BoundVar
- extendTypeMapWithScope :: TypeMap a -> CmEnv -> Type -> a -> TypeMap a
- lookupTypeMapWithScope :: TypeMap a -> CmEnv -> Type -> Maybe a
- mkDeBruijnContext :: [Var] -> CmEnv
- data MaybeMap m a
- data ListMap m a
- type LiteralMap a = Map Literal a
- class TrieMap m where
  - type Key m :: *
- insertTM :: TrieMap m => Key m -> a -> m a -> m a
- deleteTM :: TrieMap m => Key m -> m a -> m a
- lkDFreeVar :: Var -> DVarEnv a -> Maybe a
- xtDFreeVar :: Var -> XT a -> DVarEnv a -> DVarEnv a
- lkDNamed :: NamedThing n => n -> DNameEnv a -> Maybe a
- xtDNamed :: NamedThing n => n -> XT a -> DNameEnv a -> DNameEnv a
- (>.>) :: (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)

# Maps over Core expressions

data CoreMap a #

`CoreMap a` is a map from `CoreExpr` to `a`. If you are a client, this is the type you want.

Instances

TrieMap CoreMap # |
Instance details Defined in TrieMap Associated Types type Key CoreMap :: * # Methods emptyTM :: CoreMap a # lookupTM :: Key CoreMap -> CoreMap b -> Maybe b # alterTM :: Key CoreMap -> XT b -> CoreMap b -> CoreMap b # mapTM :: (a -> b) -> CoreMap a -> CoreMap b # foldTM :: (a -> b -> b) -> CoreMap a -> b -> b #
Outputable a => Outputable (CoreMap a) # |
Instance details Defined in TrieMap Methods ppr :: CoreMap a -> SDoc # pprPrec :: Rational -> CoreMap a -> SDoc #
type Key CoreMap # |
Instance details Defined in TrieMap type Key CoreMap = CoreExpr

emptyCoreMap :: CoreMap a #

extendCoreMap :: CoreMap a -> CoreExpr -> a -> CoreMap a #

lookupCoreMap :: CoreMap a -> CoreExpr -> Maybe a #

foldCoreMap :: (a -> b -> b) -> b -> CoreMap a -> b #

# Maps over `Type`s

data TypeMap a #

`TypeMap a` is a map from `Type` to `a`. If you are a client, this is the type you want. The keys in this map may have different kinds.

Instances

TrieMap TypeMap # |
Instance details Defined in TrieMap Associated Types type Key TypeMap :: * # Methods emptyTM :: TypeMap a # lookupTM :: Key TypeMap -> TypeMap b -> Maybe b # alterTM :: Key TypeMap -> XT b -> TypeMap b -> TypeMap b # mapTM :: (a -> b) -> TypeMap a -> TypeMap b # foldTM :: (a -> b -> b) -> TypeMap a -> b -> b #
type Key TypeMap # |
Instance details Defined in TrieMap type Key TypeMap = Type

emptyTypeMap :: TypeMap a #

extendTypeMap :: TypeMap a -> Type -> a -> TypeMap a #

lookupTypeMap :: TypeMap a -> Type -> Maybe a #

foldTypeMap :: (a -> b -> b) -> b -> TypeMap a -> b #

data LooseTypeMap a #

A `LooseTypeMap` doesn't do a kind-check. Thus, when lookup up (t |> g), you'll find entries inserted under (t), even if (g) is non-reflexive.

Instances

TrieMap LooseTypeMap # |
Instance details Defined in TrieMap Associated Types type Key LooseTypeMap :: * # Methods emptyTM :: LooseTypeMap a # lookupTM :: Key LooseTypeMap -> LooseTypeMap b -> Maybe b # alterTM :: Key LooseTypeMap -> XT b -> LooseTypeMap b -> LooseTypeMap b # mapTM :: (a -> b) -> LooseTypeMap a -> LooseTypeMap b # foldTM :: (a -> b -> b) -> LooseTypeMap a -> b -> b #
type Key LooseTypeMap # |
Instance details Defined in TrieMap type Key LooseTypeMap = Type

## With explicit scoping

data CmEnv #

lookupCME :: CmEnv -> Var -> Maybe BoundVar #

extendTypeMapWithScope :: TypeMap a -> CmEnv -> Type -> a -> TypeMap a #

Extend a `TypeMap` with a type in the given context. `extendTypeMapWithScope m (mkDeBruijnContext [a,b,c]) t v` is equivalent to `extendTypeMap m (forall a b c. t) v`, but allows reuse of the context over multiple insertions.

lookupTypeMapWithScope :: TypeMap a -> CmEnv -> Type -> Maybe a #

mkDeBruijnContext :: [Var] -> CmEnv #

Construct a deBruijn environment with the given variables in scope. e.g. `mkDeBruijnEnv [a,b,c]` constructs a context `forall a b c.`

# Maps over `Maybe` values

data MaybeMap m a #

Instances

TrieMap m => TrieMap (MaybeMap m) # |
Instance details Defined in TrieMap Associated Types type Key (MaybeMap 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 # mapTM :: (a -> b) -> MaybeMap m a -> MaybeMap m b # foldTM :: (a -> b -> b) -> MaybeMap m a -> b -> b #
type Key (MaybeMap m) # |
Instance details Defined in TrieMap type Key (MaybeMap m) = Maybe (Key m)

# Maps over `List` values

data ListMap m a #

Instances

TrieMap m => TrieMap (ListMap m) # |
Instance details Defined in TrieMap Associated Types type Key (ListMap 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 # mapTM :: (a -> 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 TrieMap Methods ppr :: ListMap m a -> SDoc # pprPrec :: Rational -> ListMap m a -> SDoc #
type Key (ListMap m) # |
Instance details Defined in TrieMap type Key (ListMap m) = [Key m]

# Maps over `Literal`s

type LiteralMap a = Map Literal a #

# `TrieMap` class

class TrieMap m where #

Minimal complete definition

emptyTM, lookupTM, alterTM, mapTM, foldTM

Associated Types

type Key m :: * #

Methods

emptyTM :: m a #

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

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

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

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

Instances

TrieMap IntMap # |
Instance details Defined in TrieMap Associated Types type Key IntMap :: * # Methods emptyTM :: IntMap a # lookupTM :: Key IntMap -> IntMap b -> Maybe b # alterTM :: Key IntMap -> XT b -> IntMap b -> IntMap b # mapTM :: (a -> b) -> IntMap a -> IntMap b # foldTM :: (a -> b -> b) -> IntMap a -> b -> b #
TrieMap UniqDFM # |
Instance details Defined in TrieMap Associated Types type Key UniqDFM :: * # Methods emptyTM :: UniqDFM a # lookupTM :: Key UniqDFM -> UniqDFM b -> Maybe b # alterTM :: Key UniqDFM -> XT b -> UniqDFM b -> UniqDFM b # mapTM :: (a -> b) -> UniqDFM a -> UniqDFM b # foldTM :: (a -> b -> b) -> UniqDFM a -> b -> b #
TrieMap LooseTypeMap # |
Instance details Defined in TrieMap Associated Types type Key LooseTypeMap :: * # Methods emptyTM :: LooseTypeMap a # lookupTM :: Key LooseTypeMap -> LooseTypeMap b -> Maybe b # alterTM :: Key LooseTypeMap -> XT b -> LooseTypeMap b -> LooseTypeMap b # mapTM :: (a -> b) -> LooseTypeMap a -> LooseTypeMap b # foldTM :: (a -> b -> b) -> LooseTypeMap a -> b -> b #
TrieMap TypeMap # |
Instance details Defined in TrieMap Associated Types type Key TypeMap :: * # Methods emptyTM :: TypeMap a # lookupTM :: Key TypeMap -> TypeMap b -> Maybe b # alterTM :: Key TypeMap -> XT b -> TypeMap b -> TypeMap b # mapTM :: (a -> b) -> TypeMap a -> TypeMap b # foldTM :: (a -> b -> b) -> TypeMap a -> b -> b #
TrieMap CoreMap # |
Instance details Defined in TrieMap Associated Types type Key CoreMap :: * # Methods emptyTM :: CoreMap a # lookupTM :: Key CoreMap -> CoreMap b -> Maybe b # alterTM :: Key CoreMap -> XT b -> CoreMap b -> CoreMap b # mapTM :: (a -> b) -> CoreMap a -> CoreMap b # foldTM :: (a -> b -> b) -> CoreMap a -> b -> b #
Ord k => TrieMap (Map k) # |
Instance details Defined in TrieMap Associated Types type Key (Map 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 # mapTM :: (a -> b) -> Map k a -> Map k b # foldTM :: (a -> b -> b) -> Map k a -> b -> b #
TrieMap m => TrieMap (ListMap m) # |
Instance details Defined in TrieMap Associated Types type Key (ListMap 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 # mapTM :: (a -> 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 TrieMap Associated Types type Key (MaybeMap 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 # mapTM :: (a -> b) -> MaybeMap m a -> MaybeMap m b # foldTM :: (a -> b -> b) -> MaybeMap m a -> b -> b #

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

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

lkDFreeVar :: Var -> DVarEnv a -> Maybe a #

xtDFreeVar :: Var -> XT a -> DVarEnv a -> DVarEnv a #

lkDNamed :: NamedThing n => n -> DNameEnv a -> Maybe a #

xtDNamed :: NamedThing n => n -> XT a -> DNameEnv a -> DNameEnv a #

(>.>) :: (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 #