| Copyright | © 2022–2026 Jonathan Knowles |
|---|---|
| License | Apache-2.0 |
| Safe Haskell | None |
| Language | Haskell2010 |
Data.MonoidMap.Internal.NonNullMap
Description
Provides the NonNullMap type and related functions.
This module is intended to be imported qualified:
import Data.MonoidMap.Internal.NonNullMap (NonNullMap (..)) import Data.MonoidMap.Internal.NonNullMap qualified as NonNullMap
Synopsis
- newtype NonNullMap k v = NonNullMap (Map k (NonNull v))
- fromMap :: MonoidNull v => Map k v -> NonNullMap k v
- fromMapWith :: MonoidNull v2 => (v1 -> v2) -> Map k v1 -> NonNullMap k v2
- toMap :: NonNullMap k v -> Map k v
- get :: (Ord k, Monoid v) => k -> NonNullMap k v -> v
- adjust :: (Ord k, MonoidNull v) => (v -> v) -> k -> NonNullMap k v -> NonNullMap k v
Type
newtype NonNullMap k v Source #
A map of NonNull values.
Other types with the same representation (such as MonoidMap from the
monoidmap package) can derive instances via this type, without access
to the data constructor of NonNull.
Constructors
| NonNullMap (Map k (NonNull v)) |
Instances
Construction
fromMap :: MonoidNull v => Map k v -> NonNullMap k v Source #
Constructs a NonNullMap from an ordinary Map, removing all
null values.
This function selects which of the implementations in
Data.MonoidMap.Internal.NonNullMap.FromMap is used by the public fromMap
function of the monoidmap package.
fromMapWith :: MonoidNull v2 => (v1 -> v2) -> Map k v1 -> NonNullMap k v2 Source #
Constructs a NonNullMap from an ordinary Map, applying the given
function to all values, and removing all null values.
This function selects which of the implementations in
Data.MonoidMap.Internal.NonNullMap.FromMapWith is used by the public
fromMapWith function of the monoidmap package.
Deconstruction
toMap :: NonNullMap k v -> Map k v Source #
Converts a NonNullMap into an ordinary map.
Lookup
get :: (Ord k, Monoid v) => k -> NonNullMap k v -> v Source #
Gets the value associated with the given key, returning mempty if the
key is not present.
This function selects which of the implementations in
Data.MonoidMap.Internal.NonNullMap.Get is used by the public get
function of the monoidmap package.
Modification
adjust :: (Ord k, MonoidNull v) => (v -> v) -> k -> NonNullMap k v -> NonNullMap k v Source #
Applies the given function to the value associated with the given key (or
to mempty if the key is not present), removing the key if the result is
null.
This function selects which of the implementations in
Data.MonoidMap.Internal.NonNullMap.Adjust is used by the public adjust
function of the monoidmap package.