A non-empty (by construction) set of integers. At least one value
exists in an NEIntSet a at all times.
Functions that take an NEIntSet can safely operate on it with the assumption that it has at least one item.
Functions that return an NEIntSet provide an assurance that the result has at least one item.
Data.IntSet.NonEmpty re-exports the API of Data.IntSet, faithfully reproducing asymptotics, typeclass constraints, and semantics. Functions that ensure that input and output sets are both non-empty (like insert) return NEIntSet, but functions that might potentially return an empty map (like delete) return a IntSet instead.
You can directly construct an NEIntSet with the API from Data.IntSet.NonEmpty; it's more or less the same as constructing a normal IntSet, except you don't have access to empty. There are also a few ways to construct an NEIntSet from a IntSet:
The nonEmptySet smart constructor will convert a
IntSet ainto aMaybe (NEIntSet a), returning Nothing if the original IntSet was empty.You can use the
Data.IntSet.NonEmpty.insertIntSetfamily of functions to insert a value into a IntSet to create a guaranteed NEIntSet.You can use the IsNonEmpty and IsEmpty patterns to "pattern match" on a IntSet to reveal it as either containing a NEIntSet or an empty map.
withNonEmpty offers a continuation-based interface for deconstructing a IntSet and treating it as if it were an NEIntSet.
You can convert an NEIntSet into a IntSet with toSet or IsNonEmpty, essentially "obscuring" the non-empty property from the type.
Instances12IsList, Eq, Data, Ord, Read, Show, …
IsList NEIntSetDefined in nonempty-containers-0.3.6.0 · Data.IntSet.NonEmpty.InternalEq NEIntSetDefined in nonempty-containers-0.3.6.0 · Data.IntSet.NonEmpty.InternalData NEIntSetDefined in nonempty-containers-0.3.6.0 · Data.IntSet.NonEmpty.InternalOrd NEIntSetDefined in nonempty-containers-0.3.6.0 · Data.IntSet.NonEmpty.InternalRead NEIntSetDefined in nonempty-containers-0.3.6.0 · Data.IntSet.NonEmpty.InternalShow NEIntSetDefined in nonempty-containers-0.3.6.0 · Data.IntSet.NonEmpty.InternalSemigroup NEIntSetDefined in nonempty-containers-0.3.6.0 · Data.IntSet.NonEmpty.InternalLeft-biased union
NFData NEIntSetDefined in nonempty-containers-0.3.6.0 · Data.IntSet.NonEmpty.InternalFromJSON NEIntSetDefined in nonempty-containers-0.3.6.0 · Data.IntSet.NonEmpty.InternalToJSON NEIntSetDefined in nonempty-containers-0.3.6.0 · Data.IntSet.NonEmpty.InternalIsNonEmptyList NEIntSetDefined in nonempty-containers-0.3.6.0 · Data.Containers.NonEmpty.Listtype Item NEIntSet = KeyDefined in nonempty-containers-0.3.6.0 · Data.IntSet.NonEmpty.Internal