A non-empty difference list is a pair of a head element and a (possibly empty) difference list.
Just as DList is a representation of a list, so is DNonEmpty a
representation of a NonEmpty. DNonEmpty supports \mathcal{O}(1)
append and snoc operations, making it useful for replacing frequent
applications of <> on NonEmpty (which is implemented with ++),
especially if those uses are left-nested (e.g. (a <> b)
<> c ).
Unlike DList, DNonEmpty is not an abstract type: its constructor is
exported. An alternative definition of DNonEmpty is:
newtype DNonEmpty a = DNonEmpty ([a] -> NonEmpty a)
This type would need to be abstract to avoid producing DNonEmpty values that
are not isomorphic to NonEmpty values. However, this type would also require
some functions (such as map) to be implemented with fromNonEmpty (and thus
++), which could introduce efficiencies.
Instances13Monad, Functor, Applicative, Foldable, IsList, Eq, …
Monad DNonEmptyDefined in dlist-1.0 · Data.DList.DNonEmpty.InternalFunctor DNonEmptyDefined in dlist-1.0 · Data.DList.DNonEmpty.InternalApplicative DNonEmptyDefined in dlist-1.0 · Data.DList.DNonEmpty.InternalFoldable DNonEmptyDefined in dlist-1.0 · Data.DList.DNonEmpty.InternalIsList (DNonEmpty a)Defined in dlist-1.0 · Data.DList.DNonEmpty.InternalEq a => Eq (DNonEmpty a)Defined in dlist-1.0 · Data.DList.DNonEmpty.InternalOrd a => Ord (DNonEmpty a)Defined in dlist-1.0 · Data.DList.DNonEmpty.InternalRead a => Read (DNonEmpty a)Defined in dlist-1.0 · Data.DList.DNonEmpty.InternalShow a => Show (DNonEmpty a)Defined in dlist-1.0 · Data.DList.DNonEmpty.Internala ~ Char => IsString (DNonEmpty a)Defined in dlist-1.0 · Data.DList.DNonEmpty.InternalSemigroup (DNonEmpty a)Defined in dlist-1.0 · Data.DList.DNonEmpty.InternalNFData a => NFData (DNonEmpty a)Defined in dlist-1.0 · Data.DList.DNonEmpty.Internaltype Item (DNonEmpty a) = aDefined in dlist-1.0 · Data.DList.DNonEmpty.Internal