Copyright | (c) Michael Szvetits 2020 |
---|---|
License | BSD3 (see the file LICENSE) |
Maintainer | typedbyte@qualified.name |
Stability | stable |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
The map effect for modeling a mutable collection of key-value pairs.
Lazy and strict interpretations of the effect are available here: Control.Effect.Map.Lazy and Control.Effect.Map.Strict.
Synopsis
- class Monad m => Map' tag k v m | tag m -> k v where
- type Map k v = Map' G k v
- clear :: Map k v m => m ()
- lookup :: Map k v m => k -> m (Maybe v)
- update :: Map k v m => k -> Maybe v -> m ()
- delete' :: forall tag k v m. Map' tag k v m => k -> m ()
- delete :: Map k v m => k -> m ()
- exists' :: forall tag k v m. Map' tag k v m => k -> m Bool
- exists :: Map k v m => k -> m Bool
- insert' :: forall tag k v m. Map' tag k v m => k -> v -> m ()
- insert :: Map k v m => k -> v -> m ()
- modify' :: forall tag k v m. Map' tag k v m => v -> (v -> v) -> k -> m ()
- modify :: Map k v m => v -> (v -> v) -> k -> m ()
- tagMap' :: forall new k v m a. Via (Map' G k v) (Tagger G new) m a -> m a
- retagMap' :: forall tag new k v m a. Via (Map' tag k v) (Tagger tag new) m a -> m a
- untagMap' :: forall tag k v m a. Via (Map' tag k v) (Tagger tag G) m a -> m a
Tagged Map Effect
class Monad m => Map' tag k v m | tag m -> k v where Source #
An effect that adds a mutable collection of key-value pairs to a given computation.
Deletes all key-value pairs from the map.
lookup' :: k -> m (Maybe v) Source #
Searches for a value that corresponds to a given key.
Returns Nothing
if the key cannot be found.
update' :: k -> Maybe v -> m () Source #
Updates the value that corresponds to a given key.
Passing Nothing
as the updated value removes the key-value pair from the map.
Instances
Handle (Map' tag k2 v) t m => Map' (tag :: k1) k2 v (EachVia (Map' tag k2 v ': effs) t m) Source # | |
Find (Map' tag k2 v) effs t m => Map' (tag :: k1) k2 v (EachVia (other ': effs) t m) Source # | |
Lift (Map' tag k2 v) t m => Map' (tag :: k1) k2 v (EachVia ('[] :: [Effect]) t m) Source # | |
(Monad m, Ord k2) => Map' (tag :: k1) k2 v (LazyMap k2 v m) Source # | |
(Monad m, Ord k2) => Map' (tag :: k1) k2 v (StrictMap k2 v m) Source # | |
Map' new k3 v m => Map' (tag :: k2) k3 v (Tagger tag new m) Source # | |
Untagged Map Effect
If you don't require disambiguation of multiple map effects (i.e., you only have one map effect in your monadic context), it is recommended to always use the untagged map effect.
Convenience Functions
If you don't require disambiguation of multiple map effects (i.e., you only have one map effect in your monadic context), it is recommended to always use the untagged functions.
delete' :: forall tag k v m. Map' tag k v m => k -> m () Source #
Deletes a key and its corresponding value from the map.
exists' :: forall tag k v m. Map' tag k v m => k -> m Bool Source #
Checks if the map contains a given key.
insert' :: forall tag k v m. Map' tag k v m => k -> v -> m () Source #
Inserts a new key-value pair into the map. If the key is already present in the map, the associated value is replaced with the new value.
:: forall tag k v m. Map' tag k v m | |
=> v | The default value that is assumed if the key is missing. |
-> (v -> v) | The function for updating the value. This function is also applied to the default value if the key is missing. |
-> k | The key whose corresponding value is updated. |
-> m () | The operation produces no value. |
Updates the value that corresponds to a given key. If the key cannot be found, a corresponding default value is assumed.