| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Mikan.Utils.Map1
Contents
Description
Non-empty maps.
This module is meant to be imported qualified as:
import Mikan.Utils.Map1 (Map1) import Mikan.Utils.Map1 qualified as Map1
Synopsis
- type Map1 = NEMap
- ifNull :: Map k a -> b -> (Map1 k a -> b) -> b
- unlessNull :: Applicative m => Map k a -> (Map1 k a -> m ()) -> m ()
- unlessNullM :: Monad m => m (Map k a) -> (Map1 k a -> m ()) -> m ()
- mapKeysAndValuesMonotonic :: (k -> k) -> (a -> b) -> Map1 k a -> Map1 k b
- module Data.Map.NonEmpty
Documentation
ifNull :: Map k a -> b -> (Map1 k a -> b) -> b Source #
Conditionally apply a function if a map is non-empty.
unlessNull :: Applicative m => Map k a -> (Map1 k a -> m ()) -> m () Source #
A more general type would be Null m => Map k a -> (Map1 k a -> m) -> m
but this type is problematic as we do not have a general
instance Applicative m => Null (m ()).
unlessNullM :: Monad m => m (Map k a) -> (Map1 k a -> m ()) -> m () Source #
Monadic variant of unlessNull.
mapKeysAndValuesMonotonic :: (k -> k) -> (a -> b) -> Map1 k a -> Map1 k b Source #
Map both keys and values where the map is monotonic for the keys.
A function that maps both keys and values while preserving
the map structure is missing in Data.Map.NonEmpty.
We implement it simplistically here
as a combination of mapKeysMonotonic and fmap.
Re-exports
module Data.Map.NonEmpty