Safe Haskell | None |
---|---|
Language | Haskell2010 |
Data.TypeMap.Dynamic
Synopsis
- data TypeMap x
- type family Item x t
- empty :: TypeMap x
- null :: TypeMap x -> Bool
- size :: TypeMap x -> Int
- insert :: forall t x proxy. Typeable t => proxy t -> Item x t -> TypeMap x -> TypeMap x
- (<:) :: forall t x proxy. Typeable t => TypeMap x -> (proxy t, Item x t) -> TypeMap x
- update :: forall t x proxy. Typeable t => proxy t -> (Item x t -> Maybe (Item x t)) -> TypeMap x -> TypeMap x
- alter :: forall t x proxy. Typeable t => proxy t -> (Maybe (Item x t) -> Maybe (Item x t)) -> TypeMap x -> TypeMap x
- lookup :: forall t x proxy. Typeable t => proxy t -> TypeMap x -> Maybe (Item x t)
- delete :: forall t x proxy. Typeable t => proxy t -> TypeMap x -> TypeMap x
- map :: forall x y. (forall t. Typeable t => Proxy t -> Item x t -> Item y t) -> TypeMap x -> TypeMap y
- traverse :: forall f x y. Applicative f => (forall t. Typeable t => Proxy t -> Item x t -> f (Item y t)) -> TypeMap x -> f (TypeMap y)
- toList :: forall r. TypeMap (OfType r) -> [r]
- toListMap :: forall tm r. (forall t. Proxy t -> Item tm t -> r) -> TypeMap tm -> [r]
- union :: forall x. TypeMap x -> TypeMap x -> TypeMap x
- difference :: forall x. TypeMap x -> TypeMap x -> TypeMap x
- intersection :: forall x y. TypeMap x -> TypeMap y -> TypeMap x
- data OfType a
Dynamic type maps
An extensible type family mapping types (as keys) to types of values,
parameterized by types x
.
Basic operations
insert :: forall t x proxy. Typeable t => proxy t -> Item x t -> TypeMap x -> TypeMap x Source #
Insert an element indexed by type t
.
update :: forall t x proxy. Typeable t => proxy t -> (Item x t -> Maybe (Item x t)) -> TypeMap x -> TypeMap x Source #
Update an element indexed by type t
.
alter :: forall t x proxy. Typeable t => proxy t -> (Maybe (Item x t) -> Maybe (Item x t)) -> TypeMap x -> TypeMap x Source #
Update a (possibly absent) element indexed by type t
.
lookup :: forall t x proxy. Typeable t => proxy t -> TypeMap x -> Maybe (Item x t) Source #
Lookup an element indexed by type t
.
delete :: forall t x proxy. Typeable t => proxy t -> TypeMap x -> TypeMap x Source #
Delete a key and its value from the map. Does nothing if the key does not exist.
Traversals and folds
map :: forall x y. (forall t. Typeable t => Proxy t -> Item x t -> Item y t) -> TypeMap x -> TypeMap y Source #
Map a function on all elements.
traverse :: forall f x y. Applicative f => (forall t. Typeable t => Proxy t -> Item x t -> f (Item y t)) -> TypeMap x -> f (TypeMap y) Source #
Traverse the type map. (map
with effects.)
toList :: forall r. TypeMap (OfType r) -> [r] Source #
Reduce a constant type map into a plain list of values.
toListMap :: forall tm r. (forall t. Proxy t -> Item tm t -> r) -> TypeMap tm -> [r] Source #
Collapse a type map into a plain list of values.
Set-like operations
union :: forall x. TypeMap x -> TypeMap x -> TypeMap x Source #
Left-biased union of two maps; it keeps the first key if duplicates are found.
difference :: forall x. TypeMap x -> TypeMap x -> TypeMap x Source #
Difference of two maps; keep elements of the first map which are not in the second.
intersection :: forall x y. TypeMap x -> TypeMap y -> TypeMap x Source #
Intersection of two maps; keep elements of the first map which are also in the second.
Type-level mappings
A constant mapping to type a
.
is the type of
maps from types to values of type TypeMap
(OfType
a)a
.
Instances
type UnTyped (OfType a) Source # | |
Defined in Data.TypeMap.Internal.Dynamic | |
type Typed (OfType a) t Source # | |
Defined in Data.TypeMap.Internal.Dynamic | |
type Item (OfType a) t Source # | |
Defined in Data.TypeMap.Internal.Dynamic |