A general-purpose non-empty (by construction) finite sequence type.
Non-emptiness means that:
Functions that take an NESeq can safely operate on it with the assumption that it has at least value.
Functions that return an NESeq provide an assurance that the result has at least one value.
Data.Sequence.NonEmpty re-exports the API of Data.Sequence, faithfully reproducing asymptotics, typeclass constraints, and semantics. Functions that ensure that input and output maps are both non-empty (like <|) return NESeq, but functions that might potentially return an empty map (like tail) return a Seq instead.
You can directly construct an NESeq with the API from
Data.Sequence.NonEmpty; it's more or less the same as constructing
a normal Seq, except you don't have access to Data.Seq.empty. There
are also a few ways to construct an NESeq from a Seq:
The nonEmptySeq smart constructor will convert a
Seq ainto aMaybe (NESeq a), returning Nothing if the original Seq was empty.You can use :<||, :||>, and insertSeqAt to insert a value into a Seq to create a guaranteed NESeq.
You can use the IsNonEmpty and IsEmpty patterns to "pattern match" on a Seq to reveal it as either containing a NESeq or an empty sequence.
withNonEmpty offers a continuation-based interface for deconstructing a Seq and treating it as if it were an NESeq.
You can convert an NESeq into a Seq with toSeq or IsNonEmpty, essentially "obscuring" the non-empty property from the type.
Instances34Monad, Functor, MonadFix, Applicative, Foldable, Traversable, …
Monad NESeqDefined in nonempty-containers-0.3.6.0 · Data.Sequence.NonEmpty.InternalFunctor NESeqDefined in nonempty-containers-0.3.6.0 · Data.Sequence.NonEmpty.InternalMonadFix NESeqDefined in nonempty-containers-0.3.6.0 · Data.Sequence.NonEmpty.InternalApplicative NESeqDefined in nonempty-containers-0.3.6.0 · Data.Sequence.NonEmpty.InternalFoldable NESeqDefined in nonempty-containers-0.3.6.0 · Data.Sequence.NonEmpty.InternalTraversable NESeqDefined in nonempty-containers-0.3.6.0 · Data.Sequence.NonEmpty.InternalMonadZip NESeqDefined in nonempty-containers-0.3.6.0 · Data.Sequence.NonEmpty.InternalmzipWith = zipWithmunzip = unzipFoldable1 NESeqDefined in nonempty-containers-0.3.6.0 · Data.Sequence.NonEmpty.InternalEq1 NESeqDefined in nonempty-containers-0.3.6.0 · Data.Sequence.NonEmpty.InternalOrd1 NESeqDefined in nonempty-containers-0.3.6.0 · Data.Sequence.NonEmpty.InternalRead1 NESeqDefined in nonempty-containers-0.3.6.0 · Data.Sequence.NonEmpty.InternalShow1 NESeqDefined in nonempty-containers-0.3.6.0 · Data.Sequence.NonEmpty.InternalComonad NESeqDefined in nonempty-containers-0.3.6.0 · Data.Sequence.NonEmpty.InternalAlt NESeqDefined in nonempty-containers-0.3.6.0 · Data.Sequence.NonEmpty.InternalApply NESeqDefined in nonempty-containers-0.3.6.0 · Data.Sequence.NonEmpty.InternalBind NESeqDefined in nonempty-containers-0.3.6.0 · Data.Sequence.NonEmpty.InternalExtend NESeqDefined in nonempty-containers-0.3.6.0 · Data.Sequence.NonEmpty.InternalTraversable1 NESeqDefined in nonempty-containers-0.3.6.0 · Data.Sequence.NonEmpty.InternalInvariant NESeqDefined in nonempty-containers-0.3.6.0 · Data.Sequence.NonEmpty.InternalFoldableWithIndex Int NESeqDefined in nonempty-containers-0.3.6.0 · Data.Sequence.NonEmpty.InternalFunctorWithIndex Int NESeqDefined in nonempty-containers-0.3.6.0 · Data.Sequence.NonEmpty.InternalTraversableWithIndex Int NESeqDefined in nonempty-containers-0.3.6.0 · Data.Sequence.NonEmpty.InternalIsList (NESeq a)Defined in nonempty-containers-0.3.6.0 · Data.Sequence.NonEmpty.InternalEq a => Eq (NESeq a)Defined in nonempty-containers-0.3.6.0 · Data.Sequence.NonEmpty.InternalData a => Data (NESeq a)Defined in nonempty-containers-0.3.6.0 · Data.Sequence.NonEmpty.InternalOrd a => Ord (NESeq a)Defined in nonempty-containers-0.3.6.0 · Data.Sequence.NonEmpty.InternalRead a => Read (NESeq a)Defined in nonempty-containers-0.3.6.0 · Data.Sequence.NonEmpty.InternalShow a => Show (NESeq a)Defined in nonempty-containers-0.3.6.0 · Data.Sequence.NonEmpty.InternalSemigroup (NESeq a)Defined in nonempty-containers-0.3.6.0 · Data.Sequence.NonEmpty.InternalNFData a => NFData (NESeq a)Defined in nonempty-containers-0.3.6.0 · Data.Sequence.NonEmpty.InternalFromJSON a => FromJSON (NESeq a)Defined in nonempty-containers-0.3.6.0 · Data.Sequence.NonEmpty.InternalToJSON a => ToJSON (NESeq a)Defined in nonempty-containers-0.3.6.0 · Data.Sequence.NonEmpty.InternalIsNonEmptyList (NESeq a)Defined in nonempty-containers-0.3.6.0 · Data.Containers.NonEmpty.Listtype Item (NESeq a) = aDefined in nonempty-containers-0.3.6.0 · Data.Sequence.NonEmpty.Internal