A non-empty (by construction) map from integer keys to values a. At
least one key-value pair exists in an NEIntMap v at all times.
Functions that take an NEIntMap can safely operate on it with the assumption that it has at least one key-value pair.
Functions that return an NEIntMap provide an assurance that the result has at least one key-value pair.
Data.IntMap.NonEmpty re-exports the API of Data.IntMap, faithfully reproducing asymptotics, typeclass constraints, and semantics. Functions that ensure that input and output maps are both non-empty (like insert) return NEIntMap, but functions that might potentially return an empty map (like delete) return a IntMap instead.
You can directly construct an NEIntMap with the API from
Data.IntMap.NonEmpty; it's more or less the same as constructing a normal
IntMap, except you don't have access to Data.IntMap.empty. There are also
a few ways to construct an NEIntMap from a IntMap:
The nonEmptyMap smart constructor will convert a
IntMap k ainto aMaybe (NEIntMap k a), returning Nothing if the original IntMap was empty.You can use the
Data.IntMap.NonEmpty.insertIntMapfamily of functions to insert a value into a IntMap to create a guaranteed NEIntMap.You can use the IsNonEmpty and IsEmpty patterns to "pattern match" on a IntMap to reveal it as either containing a NEIntMap or an empty map.
withNonEmpty offers a continuation-based interface for deconstructing a IntMap and treating it as if it were an NEIntMap.
You can convert an NEIntMap into a IntMap with toMap or IsNonEmpty, essentially "obscuring" the non-empty property from the type.
Instances27Functor, Foldable, Traversable, Foldable1, Eq1, Ord1, …
Functor NEIntMapDefined in nonempty-containers-0.3.6.0 · Data.IntMap.NonEmpty.InternalFoldable NEIntMapDefined in nonempty-containers-0.3.6.0 · Data.IntMap.NonEmpty.InternalTraversable NEIntMapDefined in nonempty-containers-0.3.6.0 · Data.IntMap.NonEmpty.InternalFoldable1 NEIntMapDefined in nonempty-containers-0.3.6.0 · Data.IntMap.NonEmpty.InternalEq1 NEIntMapDefined in nonempty-containers-0.3.6.0 · Data.IntMap.NonEmpty.InternalOrd1 NEIntMapDefined in nonempty-containers-0.3.6.0 · Data.IntMap.NonEmpty.InternalRead1 NEIntMapDefined in nonempty-containers-0.3.6.0 · Data.IntMap.NonEmpty.InternalShow1 NEIntMapDefined in nonempty-containers-0.3.6.0 · Data.IntMap.NonEmpty.InternalComonad NEIntMapDefined in nonempty-containers-0.3.6.0 · Data.IntMap.NonEmpty.InternalAlt NEIntMapDefined in nonempty-containers-0.3.6.0 · Data.IntMap.NonEmpty.InternalTraversable1 NEIntMapDefined in nonempty-containers-0.3.6.0 · Data.IntMap.NonEmpty.InternalInvariant NEIntMapDefined in nonempty-containers-0.3.6.0 · Data.IntMap.NonEmpty.InternalFoldableWithIndex Int NEIntMapDefined in nonempty-containers-0.3.6.0 · Data.IntMap.NonEmpty.InternalFunctorWithIndex Int NEIntMapDefined in nonempty-containers-0.3.6.0 · Data.IntMap.NonEmpty.InternalTraversableWithIndex Int NEIntMapDefined in nonempty-containers-0.3.6.0 · Data.IntMap.NonEmpty.InternalIsList (NEIntMap a)Defined in nonempty-containers-0.3.6.0 · Data.IntMap.NonEmpty.InternalEq a => Eq (NEIntMap a)Defined in nonempty-containers-0.3.6.0 · Data.IntMap.NonEmpty.InternalData a => Data (NEIntMap a)Defined in nonempty-containers-0.3.6.0 · Data.IntMap.NonEmpty.InternalOrd a => Ord (NEIntMap a)Defined in nonempty-containers-0.3.6.0 · Data.IntMap.NonEmpty.InternalRead e => Read (NEIntMap e)Defined in nonempty-containers-0.3.6.0 · Data.IntMap.NonEmpty.InternalShow a => Show (NEIntMap a)Defined in nonempty-containers-0.3.6.0 · Data.IntMap.NonEmpty.InternalSemigroup (NEIntMap a)Defined in nonempty-containers-0.3.6.0 · Data.IntMap.NonEmpty.InternalLeft-biased union
NFData a => NFData (NEIntMap a)Defined in nonempty-containers-0.3.6.0 · Data.IntMap.NonEmpty.InternalFromJSON a => FromJSON (NEIntMap a)Defined in nonempty-containers-0.3.6.0 · Data.IntMap.NonEmpty.InternalToJSON a => ToJSON (NEIntMap a)Defined in nonempty-containers-0.3.6.0 · Data.IntMap.NonEmpty.InternalIsNonEmptyList (NEIntMap a)Defined in nonempty-containers-0.3.6.0 · Data.Containers.NonEmpty.Listtype Item (NEIntMap a) = (Key, a)Defined in nonempty-containers-0.3.6.0 · Data.IntMap.NonEmpty.Internal