Copyright | (c) Michael Szvetits 2020 |
---|---|
License | BSD3 (see the file LICENSE) |
Maintainer | typedbyte@qualified.name |
Stability | stable |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
Strict interpretations of the Map'
effect.
If you don't require disambiguation of multiple map effects (i.e., you only have one map effect in your monadic context), you usually need the untagged interpretations.
Synopsis
- data StrictMap k v m a
- clear :: Monad m => StrictMap k v m ()
- lookup :: (Monad m, Ord k) => k -> StrictMap k v m (Maybe v)
- update :: (Monad m, Ord k) => k -> Maybe v -> StrictMap k v m ()
- runMap' :: forall tag k v m a. Monad m => (Map' tag k v `Via` StrictMap k v) m a -> m a
- runMap :: Monad m => (Map k v `Via` StrictMap k v) m a -> m a
Interpreter Implementation
data StrictMap k v m a Source #
The strict interpreter of the map effect. This type implements the
Map'
type class in a strict manner.
When interpreting the effect, you usually don't interact with this type directly, but instead use one of its corresponding interpretation functions.
Instances
lookup :: (Monad m, Ord k) => k -> StrictMap k v m (Maybe v) Source #
Searches for a value that corresponds to a given key.
Returns Nothing
if the key cannot be found.
update :: (Monad m, Ord k) => k -> Maybe v -> StrictMap k 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.
Tagged Interpretations
:: forall tag k v m a. Monad m | |
=> (Map' tag k v `Via` StrictMap k v) m a | The program whose map effect should be handled. |
-> m a | The program with its map effect handled. |
Runs the map effect, initialized with an empty map.