A non-empty (by construction) map from keys k to values a. At
least one key-value pair exists in an NEMap k v at all times.
Functions that take an NEMap can safely operate on it with the assumption that it has at least one key-value pair.
Functions that return an NEMap provide an assurance that the result has at least one key-value pair.
Data.Map.NonEmpty re-exports the API of Data.Map, faithfully reproducing asymptotics, typeclass constraints, and semantics. Functions that ensure that input and output maps are both non-empty (like insert) return NEMap, but functions that might potentially return an empty map (like delete) return a Map instead.
You can directly construct an NEMap with the API from
Data.Map.NonEmpty; it's more or less the same as constructing a normal
Map, except you don't have access to Data.Map.empty. There are also
a few ways to construct an NEMap from a Map:
The nonEmptyMap smart constructor will convert a
Map k ainto aMaybe (NEMap k a), returning Nothing if the original Map was empty.You can use the insertMap family of functions to insert a value into a Map to create a guaranteed NEMap.
You can use the IsNonEmpty and IsEmpty patterns to "pattern match" on a Map to reveal it as either containing a NEMap or an empty map.
withNonEmpty offers a continuation-based interface for deconstructing a Map and treating it as if it were an NEMap.
You can convert an NEMap into a Map with toMap or IsNonEmpty, essentially "obscuring" the non-empty property from the type.
Instances30Eq2, Ord2, Show2, FoldableWithIndex, FunctorWithIndex, TraversableWithIndex, …
Eq2 NEMapDefined in nonempty-containers-0.3.6.0 · Data.Map.NonEmpty.InternalOrd2 NEMapDefined in nonempty-containers-0.3.6.0 · Data.Map.NonEmpty.InternalShow2 NEMapDefined in nonempty-containers-0.3.6.0 · Data.Map.NonEmpty.InternalFoldableWithIndex k (NEMap k)Defined in nonempty-containers-0.3.6.0 · Data.Map.NonEmpty.InternalFunctorWithIndex k (NEMap k)Defined in nonempty-containers-0.3.6.0 · Data.Map.NonEmpty.InternalTraversableWithIndex k (NEMap k)Defined in nonempty-containers-0.3.6.0 · Data.Map.NonEmpty.InternalFunctor (NEMap k)Defined in nonempty-containers-0.3.6.0 · Data.Map.NonEmpty.InternalFoldable (NEMap k)Defined in nonempty-containers-0.3.6.0 · Data.Map.NonEmpty.InternalTraversable (NEMap k)Defined in nonempty-containers-0.3.6.0 · Data.Map.NonEmpty.InternalTraverses elements in order of ascending keys
Foldable1 (NEMap k)Defined in nonempty-containers-0.3.6.0 · Data.Map.NonEmpty.InternalTraverses elements in order of ascending keys
Eq k => Eq1 (NEMap k)Defined in nonempty-containers-0.3.6.0 · Data.Map.NonEmpty.InternalOrd k => Ord1 (NEMap k)Defined in nonempty-containers-0.3.6.0 · Data.Map.NonEmpty.Internal(Ord k, Read k) => Read1 (NEMap k)Defined in nonempty-containers-0.3.6.0 · Data.Map.NonEmpty.InternalShow k => Show1 (NEMap k)Defined in nonempty-containers-0.3.6.0 · Data.Map.NonEmpty.InternalComonad (NEMap k)Defined in nonempty-containers-0.3.6.0 · Data.Map.NonEmpty.InternalOrd k => Alt (NEMap k)Defined in nonempty-containers-0.3.6.0 · Data.Map.NonEmpty.InternalTraversable1 (NEMap k)Defined in nonempty-containers-0.3.6.0 · Data.Map.NonEmpty.InternalTraverses elements in order of ascending keys
Invariant (NEMap k)Defined in nonempty-containers-0.3.6.0 · Data.Map.NonEmpty.InternalOrd k => IsList (NEMap k a)Defined in nonempty-containers-0.3.6.0 · Data.Map.NonEmpty.Internal(Eq k, Eq a) => Eq (NEMap k a)Defined in nonempty-containers-0.3.6.0 · Data.Map.NonEmpty.Internal(Data k, Data a, Ord k) => Data (NEMap k a)Defined in nonempty-containers-0.3.6.0 · Data.Map.NonEmpty.Internal(Ord k, Ord a) => Ord (NEMap k a)Defined in nonempty-containers-0.3.6.0 · Data.Map.NonEmpty.Internal(Ord k, Read k, Read e) => Read (NEMap k e)Defined in nonempty-containers-0.3.6.0 · Data.Map.NonEmpty.Internal(Show k, Show a) => Show (NEMap k a)Defined in nonempty-containers-0.3.6.0 · Data.Map.NonEmpty.InternalOrd k => Semigroup (NEMap k a)Defined in nonempty-containers-0.3.6.0 · Data.Map.NonEmpty.InternalLeft-biased union
(NFData k, NFData a) => NFData (NEMap k a)Defined in nonempty-containers-0.3.6.0 · Data.Map.NonEmpty.Internal(FromJSONKey k, Ord k, FromJSON a) => FromJSON (NEMap k a)Defined in nonempty-containers-0.3.6.0 · Data.Map.NonEmpty.Internal(ToJSONKey k, ToJSON a) => ToJSON (NEMap k a)Defined in nonempty-containers-0.3.6.0 · Data.Map.NonEmpty.InternalOrd k => IsNonEmptyList (NEMap k a)Defined in nonempty-containers-0.3.6.0 · Data.Containers.NonEmpty.Listtype Item (NEMap k a) = (k, a)Defined in nonempty-containers-0.3.6.0 · Data.Map.NonEmpty.Internal