Data.Sequence.NonEmpty
- Package
- purescript-sequences
- Repository
- hdgarrood/purescript-sequences
This module contains a type, Seq
, much like that from Data.Sequence
,
but which is guaranteed to contain at least one element.
This module is intended to be imported qualified, to avoid name clashes or ambiguity. For example:
import Data.Sequence.NonEmpty as NonEmpty
#Seq Source
#fromFoldable1 Source
fromFoldable1 :: forall f. Foldable1 f => f ~> Seq
Probably O(n), but depends on the Foldable1 instance. Unfold a non-empty sequence from any Foldable1.
Note that we cannot provide a fromFoldable
, because the argument could
be empty.
#toUnfoldable Source
toUnfoldable :: forall f. Functor f => Unfoldable f => Seq ~> f
Probably O(n), but depends on the Unfoldable instance. Turn a Seq
into
any Unfoldable
.
#toUnfoldable1 Source
toUnfoldable1 :: forall f. Functor f => Unfoldable1 f => Seq ~> f
Probably O(n), but depends on the Unfoldable instance. Turn a Seq
into
any Unfoldable1
.
#splitAt Source
splitAt :: forall a. Int -> Seq a -> Tuple (Seq a) (Seq a)
O(log(min(i,n-i))). Split the sequence into two (possibly empty) subsequences. The first subsequence will have i elements (unless there are not that many in the whole sequence, in which case the first element is the same sequence, unchanged).