parameterized-utils-1.0.0: Classes and data structures for working with data-kind indexed types

Copyright(c) Galois Inc 2014-2017
Safe HaskellTrustworthy
LanguageHaskell98

Data.Parameterized.Map

Contents

Description

This module defines finite maps where the key and value types are parameterized by an arbitrary kind.

Some code was adapted from containers.

Synopsis

Documentation

data MapF (k :: v -> *) (a :: v -> *) Source #

A map from parameterized keys to values with the same paramter type.

Instances

TraversableF k (MapF k ktp) Source # 

Methods

traverseF :: Applicative m => (forall (s :: MapF k ktp). e s -> m (f s)) -> t e -> m (t f) Source #

FoldableF k (MapF k ktp) Source # 

Methods

foldMapF :: Monoid m => (forall (s :: MapF k ktp). e s -> m) -> t e -> m Source #

foldrF :: (forall (s :: MapF k ktp). e s -> b -> b) -> b -> t e -> b Source #

foldlF :: (forall (s :: MapF k ktp). b -> e s -> b) -> b -> t e -> b Source #

foldrF' :: (forall (s :: MapF k ktp). e s -> b -> b) -> b -> t e -> b Source #

foldlF' :: (forall (s :: MapF k ktp). b -> e s -> b) -> b -> t e -> b Source #

toListF :: (forall (tp :: MapF k ktp). f tp -> a) -> t f -> [a] Source #

FunctorF k (MapF k ktp) Source # 

Methods

fmapF :: (forall (x :: MapF k ktp). f x -> g x) -> m f -> m g Source #

OrdF a k => AtF a (MapF a k v) Source #

Turn a map key into a lens that points into the indicated position in the map.

Methods

atF :: IndexF a (MapF a k v) x -> Lens' (MapF a k v) (Maybe (IxValueF a (MapF a k v) x)) Source #

OrdF a k => IxedF a (MapF a k v) Source #

Turn a map key into a traversal that visits the indicated element in the map, if it exists.

Methods

ixF :: IndexF a (MapF a k v) x -> Traversal' (MapF a k v) (IxValueF a (MapF a k v) x) Source #

(TestEquality v k, EqF v a) => Eq (MapF v k a) Source # 

Methods

(==) :: MapF v k a -> MapF v k a -> Bool #

(/=) :: MapF v k a -> MapF v k a -> Bool #

(ShowF v ktp, ShowF v rtp) => Show (MapF v ktp rtp) Source # 

Methods

showsPrec :: Int -> MapF v ktp rtp -> ShowS #

show :: MapF v ktp rtp -> String #

showList :: [MapF v ktp rtp] -> ShowS #

IsBinTree (MapF k1 k2 a) (Pair k1 k2 a) Source # 

Methods

asBin :: MapF k1 k2 a -> TreeApp (Pair k1 k2 a) (MapF k1 k2 a) Source #

tip :: MapF k1 k2 a Source #

bin :: Pair k1 k2 a -> MapF k1 k2 a -> MapF k1 k2 a -> MapF k1 k2 a Source #

size :: MapF k1 k2 a -> Int Source #

type IxValueF k1 (MapF k1 k2 v) Source # 
type IxValueF k1 (MapF k1 k2 v) = v
type IndexF k1 (MapF k1 k2 v) Source # 
type IndexF k1 (MapF k1 k2 v) = k2

Construction

empty :: MapF k a Source #

Return empty map

singleton :: k tp -> a tp -> MapF k a Source #

Return map containing a single element

insert :: OrdF k => k tp -> a tp -> MapF k a -> MapF k a Source #

Insert a binding into the map, replacing the existing binding if needed.

insertWith :: OrdF k => (a tp -> a tp -> a tp) -> k tp -> a tp -> MapF k a -> MapF k a Source #

insertWith f new m inserts the binding into m.

It inserts f new old if m already contains an equivaltn value old, and new otherwise. It returns an Unchanged value if the map stays the same size and an updated value if a new entry was inserted.

delete :: OrdF k => k tp -> MapF k a -> MapF k a Source #

Delete a value from the map if present.

union :: OrdF k => MapF k a -> MapF k a -> MapF k a Source #

Union two sets

Query

null :: MapF k a -> Bool Source #

Return true if map is empty

lookup :: OrdF k => k tp -> MapF k a -> Maybe (a tp) Source #

Lookup value in map.

member :: OrdF k => k tp -> MapF k a -> Bool Source #

Return true if key is bound in map.

notMember :: OrdF k => k tp -> MapF k a -> Bool Source #

Return true if key is not bound in map.

size :: IsBinTree t e => t -> Int Source #

Conversion

keys :: MapF k a -> [Some k] Source #

Return all keys of the map in ascending order.

elems :: MapF k a -> [Some a] Source #

Return all elements of the map in the ascending order of their keys.

fromList :: OrdF k => [Pair k a] -> MapF k a Source #

Create a Map from a list of pairs.

toList :: MapF k a -> [Pair k a] Source #

fromKeys Source #

Arguments

:: forall (t :: * -> *) (a :: k -> *) (v :: k -> *). (Monad m, Foldable t, OrdF a) 
=> (forall tp. a tp -> m (v tp))

Function for evaluating a register value.

-> t (Some a)

Set of X86 registers

-> m (MapF a v) 

Generate a map from a foldable collection of keys and a function from keys to values.

fromKeysM Source #

Arguments

:: forall (t :: * -> *) (a :: k -> *) (v :: k -> *). (Monad m, Foldable t, OrdF a) 
=> (forall tp. a tp -> m (v tp))

Function for evaluating a register value.

-> t (Some a)

Set of X86 registers

-> m (MapF a v) 

Generate a map from a foldable collection of keys and a monadic function from keys to values.

Filter

filterGt :: OrdF k => k tp -> MapF k v -> MapF k v Source #

filterGt k m returns submap of m that only contains entries that are larger than k.

filterLt :: OrdF k => k tp -> MapF k v -> MapF k v Source #

filterLt k m returns submap of m that only contains entries that are smaller than k.

Folds

foldrWithKey :: (forall s. k s -> a s -> b -> b) -> b -> MapF k a -> b Source #

Perform a fold with the key also provided.

Traversal

map :: (forall tp. f tp -> g tp) -> MapF ktp f -> MapF ktp g Source #

Modify elements in a map

mapMaybe :: (forall tp. f tp -> Maybe (g tp)) -> MapF ktp f -> MapF ktp g Source #

Run partial map over elements.

traverseWithKey :: Applicative m => (forall tp. ktp tp -> f tp -> m (g tp)) -> MapF ktp f -> m (MapF ktp g) Source #

Traverse elements in a map

traverseWithKey_ :: Applicative m => (forall tp. ktp tp -> f tp -> m ()) -> MapF ktp f -> m () Source #

Traverse elements in a map without returning result.

Complex interface.

data UpdateRequest v Source #

Update request tells when to do with value

Constructors

Keep

Keep the current value.

Set !v

Set the value to a new value.

Delete

Delete a value.

data Updated a Source #

Updated a contains a value that has been flagged on whether it was modified by an operation.

Constructors

Updated !a 
Unchanged !a 

updateAtKey Source #

Arguments

:: (OrdF k, Functor f) 
=> k tp

Key to update

-> f (Maybe (a tp))

Action to call if nothing is found

-> (a tp -> f (UpdateRequest (a tp)))

Action to call if value is found.

-> MapF k a

Map to update

-> f (Updated (MapF k a)) 

Log-time algorithm that allows a value at a specific key to be added, replaced, or deleted.

mergeWithKeyM :: forall k a b c m. (Applicative m, OrdF k) => (forall tp. k tp -> a tp -> b tp -> m (Maybe (c tp))) -> (MapF k a -> m (MapF k c)) -> (MapF k b -> m (MapF k c)) -> MapF k a -> MapF k b -> m (MapF k c) Source #

Merge bindings in two maps to get a third.

Pair

data Pair (a :: k -> *) (b :: k -> *) where Source #

Like a 2-tuple, but with an existentially quantified parameter that both of the elements share.

Constructors

Pair :: !(a tp) -> !(b tp) -> Pair a b 

Instances

FoldableF k (Pair k a) Source # 

Methods

foldMapF :: Monoid m => (forall (s :: Pair k a). e s -> m) -> t e -> m Source #

foldrF :: (forall (s :: Pair k a). e s -> b -> b) -> b -> t e -> b Source #

foldlF :: (forall (s :: Pair k a). b -> e s -> b) -> b -> t e -> b Source #

foldrF' :: (forall (s :: Pair k a). e s -> b -> b) -> b -> t e -> b Source #

foldlF' :: (forall (s :: Pair k a). b -> e s -> b) -> b -> t e -> b Source #

toListF :: (forall (tp :: Pair k a). f tp -> a) -> t f -> [a] Source #

FunctorF k (Pair k a) Source # 

Methods

fmapF :: (forall (x :: Pair k a). f x -> g x) -> m f -> m g Source #

(TestEquality k a, EqF k b) => Eq (Pair k a b) Source # 

Methods

(==) :: Pair k a b -> Pair k a b -> Bool #

(/=) :: Pair k a b -> Pair k a b -> Bool #

IsBinTree (MapF k1 k2 a) (Pair k1 k2 a) Source # 

Methods

asBin :: MapF k1 k2 a -> TreeApp (Pair k1 k2 a) (MapF k1 k2 a) Source #

tip :: MapF k1 k2 a Source #

bin :: Pair k1 k2 a -> MapF k1 k2 a -> MapF k1 k2 a -> MapF k1 k2 a Source #

size :: MapF k1 k2 a -> Int Source #