hobbits-1.3.1: A library for canonically representing terms with binding
Copyright(c) 2019 Edwin Westbrook
LicenseBSD3
Maintainerwestbrook@galois.com
Stabilityexperimental
PortabilityGHC
Safe HaskellNone
LanguageHaskell2010

Data.Binding.Hobbits.NameMap

Description

Implements mappings from Names to some associated data, using Strict. Note that these mappings are strict.

All of the functions in this module operate in an identical manner as those of the same name in the Strict module.

Synopsis

Documentation

data NameMap (f :: k -> *) Source #

A heterogeneous map from Names of arbitrary type a to elements of f a

data NameAndElem f where Source #

A pair of a Name of some type a along with an element of type f a

Constructors

NameAndElem :: Name a -> f a -> NameAndElem f 

Instances

Instances details
NuMatchingAny1 f => NuMatching (NameAndElem f) Source # 
Instance details

Defined in Data.Binding.Hobbits.NameMap

empty :: NameMap f Source #

The empty NameMap

singleton :: Name a -> f a -> NameMap f Source #

The singleton NameMap with precisely one Name and corresponding value

fromList :: [NameAndElem f] -> NameMap f Source #

Build a NameMap from a list of pairs of names and values they map to

insert :: Name a -> f a -> NameMap f -> NameMap f Source #

Insert a Name and a value it maps to into a NameMap

delete :: Name a -> NameMap f -> NameMap f Source #

Delete a Name and the value it maps to from a NameMap

adjust :: (f a -> f a) -> Name a -> NameMap f -> NameMap f Source #

Apply a function to the value mapped to by a Name

update :: (f a -> Maybe (f a)) -> Name a -> NameMap f -> NameMap f Source #

Update the value mapped to by a Name, possibly deleting it

alter :: (Maybe (f a) -> Maybe (f a)) -> Name a -> NameMap f -> NameMap f Source #

Apply a function to the optional value associated with a Name, where Nothing represents the Name not being present in the NameMap

lookup :: Name a -> NameMap f -> Maybe (f a) Source #

Look up the value associated with a Name, returning Nothing if there is none

(!) :: NameMap f -> Name a -> f a Source #

Synonym for lookup with the argument order reversed

member :: Name a -> NameMap f -> Bool Source #

Test if a Name has a value in a NameMap

null :: NameMap f -> Bool Source #

Test if a NameMap is empty

size :: NameMap f -> Int Source #

Return the number of Names in a NameMap

union :: NameMap f -> NameMap f -> NameMap f Source #

Union two NameMaps

difference :: NameMap f -> NameMap f -> NameMap f Source #

Remove all bindings in the first NameMap for Names in the second

(\\) :: NameMap f -> NameMap f -> NameMap f Source #

Infix synonym for difference

intersection :: NameMap f -> NameMap f -> NameMap f Source #

Intersect two NameMaps

map :: (forall a. f a -> g a) -> NameMap f -> NameMap g Source #

Map a function across the values associated with each Name

foldr :: (forall a. f a -> b -> b) -> b -> NameMap f -> b Source #

Perform a right fold across all values in a NameMap

foldl :: (forall b. a -> f b -> a) -> a -> NameMap f -> a Source #

Perform a left fold across all values in a NameMap

assocs :: NameMap f -> [NameAndElem f] Source #

Return all Names in a NameMap with their associated values

liftNameMap :: forall ctx f a. NuMatchingAny1 f => (forall a. Mb ctx (f a) -> Maybe (f a)) -> Mb ctx (NameMap f) -> NameMap f Source #

Lift a NameMap out of a name-binding using a "partial lifting function" that can lift some values in the NameMap out of the binding. The resulting NameMap contains those names and associated values where the names were not bound by the name-binding and the partial lifting function was able to lift their associated values.