cardano-strict-containers-0.1.4.0: Various strict container types
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Sequence.Strict

Description

Strict variants of Seq operations.

Synopsis

Documentation

data StrictSeq a where Source #

A newtype wrapper around a Seq, representing a general-purpose finite sequence that is strict in its values.

This strictness is not enforced at the type level, but rather by the construction functions in this module. These functions essentially just wrap the original Data.Sequence functions while forcing the provided value to WHNF.

Bundled Patterns

pattern EmptyStrictSeq a

A bidirectional pattern synonym matching an empty sequence.

pattern (:<|) ∷ a → StrictSeq a → StrictSeq a infixr 5

A bidirectional pattern synonym viewing the front of a non-empty sequence.

pattern (:|>)StrictSeq a → a → StrictSeq a infixl 5

A bidirectional pattern synonym viewing the rear of a non-empty sequence.

Instances

Instances details
Foldable StrictSeq Source # 
Instance details

Defined in Data.Sequence.Strict

Methods

foldMonoid m ⇒ StrictSeq m → m Source #

foldMapMonoid m ⇒ (a → m) → StrictSeq a → m Source #

foldMap'Monoid m ⇒ (a → m) → StrictSeq a → m Source #

foldr ∷ (a → b → b) → b → StrictSeq a → b Source #

foldr' ∷ (a → b → b) → b → StrictSeq a → b Source #

foldl ∷ (b → a → b) → b → StrictSeq a → b Source #

foldl' ∷ (b → a → b) → b → StrictSeq a → b Source #

foldr1 ∷ (a → a → a) → StrictSeq a → a Source #

foldl1 ∷ (a → a → a) → StrictSeq a → a Source #

toListStrictSeq a → [a] Source #

nullStrictSeq a → Bool Source #

lengthStrictSeq a → Int Source #

elemEq a ⇒ a → StrictSeq a → Bool Source #

maximumOrd a ⇒ StrictSeq a → a Source #

minimumOrd a ⇒ StrictSeq a → a Source #

sumNum a ⇒ StrictSeq a → a Source #

productNum a ⇒ StrictSeq a → a Source #

Traversable StrictSeq Source # 
Instance details

Defined in Data.Sequence.Strict

Methods

traverseApplicative f ⇒ (a → f b) → StrictSeq a → f (StrictSeq b) Source #

sequenceAApplicative f ⇒ StrictSeq (f a) → f (StrictSeq a) Source #

mapMMonad m ⇒ (a → m b) → StrictSeq a → m (StrictSeq b) Source #

sequenceMonad m ⇒ StrictSeq (m a) → m (StrictSeq a) Source #

Functor StrictSeq Source # 
Instance details

Defined in Data.Sequence.Strict

Methods

fmap ∷ (a → b) → StrictSeq a → StrictSeq b Source #

(<$) ∷ a → StrictSeq b → StrictSeq a Source #

FromJSON a ⇒ FromJSON (StrictSeq a) Source # 
Instance details

Defined in Data.Sequence.Strict

ToJSON a ⇒ ToJSON (StrictSeq a) Source # 
Instance details

Defined in Data.Sequence.Strict

Monoid (StrictSeq a) Source # 
Instance details

Defined in Data.Sequence.Strict

Semigroup (StrictSeq a) Source # 
Instance details

Defined in Data.Sequence.Strict

Methods

(<>)StrictSeq a → StrictSeq a → StrictSeq a Source #

sconcatNonEmpty (StrictSeq a) → StrictSeq a Source #

stimesIntegral b ⇒ b → StrictSeq a → StrictSeq a Source #

IsList (StrictSeq a) Source # 
Instance details

Defined in Data.Sequence.Strict

Associated Types

type Item (StrictSeq a) Source #

Show a ⇒ Show (StrictSeq a) Source # 
Instance details

Defined in Data.Sequence.Strict

FromCBOR a ⇒ FromCBOR (StrictSeq a) Source # 
Instance details

Defined in Data.Sequence.Strict

ToCBOR a ⇒ ToCBOR (StrictSeq a) Source # 
Instance details

Defined in Data.Sequence.Strict

Methods

toCBORStrictSeq a → Encoding Source #

encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy (StrictSeq a) → Size Source #

encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [StrictSeq a] → Size Source #

NFData a ⇒ NFData (StrictSeq a) Source # 
Instance details

Defined in Data.Sequence.Strict

Methods

rnfStrictSeq a → () Source #

Eq a ⇒ Eq (StrictSeq a) Source # 
Instance details

Defined in Data.Sequence.Strict

Methods

(==)StrictSeq a → StrictSeq a → Bool Source #

(/=)StrictSeq a → StrictSeq a → Bool Source #

Ord a ⇒ Ord (StrictSeq a) Source # 
Instance details

Defined in Data.Sequence.Strict

NoThunks a ⇒ NoThunks (StrictSeq a) Source #

Instance for StrictSeq checks elements only

The internal fingertree in Seq might have thunks, which is essential for its asymptotic complexity.

Instance details

Defined in Data.Sequence.Strict

Serialise a ⇒ Serialise (StrictSeq a) Source # 
Instance details

Defined in Data.Sequence.Strict

type Item (StrictSeq a) Source # 
Instance details

Defined in Data.Sequence.Strict

type Item (StrictSeq a) = a

forceToStrictSeq a → StrictSeq a Source #

Convert a Seq into a StrictSeq by forcing each element to WHNF.

Construction

emptyStrictSeq a Source #

\( O(1) \). The empty sequence.

singleton ∷ a → StrictSeq a Source #

\( O(1) \). A singleton sequence.

(<|) ∷ a → StrictSeq a → StrictSeq a infixr 5 Source #

\( O(1) \). Add an element to the left end of a sequence. Mnemonic: a triangle with the single element at the pointy end.

(|>)StrictSeq a → a → StrictSeq a infixl 5 Source #

\( O(1) \). Add an element to the right end of a sequence. Mnemonic: a triangle with the single element at the pointy end.

(><)StrictSeq a → StrictSeq a → StrictSeq a infixr 5 Source #

\( O(\log(\min(n_1,n_2))) \). Concatenate two sequences.

fromList ∷ [a] → StrictSeq a Source #

Deconstruction

Additional functions for deconstructing sequences are available via the Foldable instance of Seq.

Queries

nullStrictSeq a → Bool Source #

\( O(1) \). Is this the empty sequence?

lengthStrictSeq a → Int Source #

\( O(1) \). The number of elements in the sequence.

Scans

scanl ∷ (a → b → a) → a → StrictSeq b → StrictSeq a Source #

scanl is similar to foldl, but returns a sequence of reduced values from the left:

scanl f z (fromList [x1, x2, ...]) = fromList [z, z `f` x1, (z `f` x1) `f` x2, ...]

Sublists

Sequential searches

takeWhileL ∷ (a → Bool) → StrictSeq a → StrictSeq a Source #

\( O(i) \) where \( i \) is the prefix length. takeWhileL, applied to a predicate p and a sequence xs, returns the longest prefix (possibly empty) of xs of elements that satisfy p.

takeWhileR ∷ (a → Bool) → StrictSeq a → StrictSeq a Source #

\( O(i) \) where \( i \) is the suffix length. takeWhileR, applied to a predicate p and a sequence xs, returns the longest suffix (possibly empty) of xs of elements that satisfy p.

takeWhileR p xs is equivalent to reverse (takeWhileL p (reverse xs)).

dropWhileL ∷ (a → Bool) → StrictSeq a → StrictSeq a Source #

\( O(i) \) where \( i \) is the prefix length. dropWhileL p xs returns the suffix remaining after takeWhileL p xs.

dropWhileR ∷ (a → Bool) → StrictSeq a → StrictSeq a Source #

\( O(i) \) where \( i \) is the suffix length. dropWhileR p xs returns the prefix remaining after takeWhileR p xs.

dropWhileR p xs is equivalent to reverse (dropWhileL p (reverse xs)).

spanl ∷ (a → Bool) → StrictSeq a → (StrictSeq a, StrictSeq a) Source #

\( O(i) \) where \( i \) is the prefix length. spanl, applied to a predicate p and a sequence xs, returns a pair whose first element is the longest prefix (possibly empty) of xs of elements that satisfy p and the second element is the remainder of the sequence.

spanr ∷ (a → Bool) → StrictSeq a → (StrictSeq a, StrictSeq a) Source #

\( O(i) \) where \( i \) is the suffix length. spanr, applied to a predicate p and a sequence xs, returns a pair whose first element is the longest suffix (possibly empty) of xs of elements that satisfy p and the second element is the remainder of the sequence.

Indexing

lookupIntStrictSeq a → Maybe a Source #

\( O(\log(\min(i,n-i))) \). The element at the specified position, counting from 0. If the specified position is negative or at least the length of the sequence, lookup returns Nothing.

0 <= i < length xs ==> lookup i xs == Just (toList xs !! i)
i < 0 || i >= length xs ==> lookup i xs = Nothing

Unlike index, this can be used to retrieve an element without forcing it. For example, to insert the fifth element of a sequence xs into a Map m at key k, you could use

case lookup 5 xs of
  Nothing -> m
  Just x -> insert k x m

(!?)StrictSeq a → IntMaybe a Source #

\( O(\log(\min(i,n-i))) \). A flipped, infix version of lookup.

takeIntStrictSeq a → StrictSeq a Source #

\( O(\log(\min(i,n-i))) \). The first i elements of a sequence. If i is negative, take i s yields the empty sequence. If the sequence contains fewer than i elements, the whole sequence is returned.

takeLastIntStrictSeq a → StrictSeq a Source #

Take the last n elements

Returns the entire sequence if it has fewer than n elements.

Inherits asymptotic complexity from drop.

dropIntStrictSeq a → StrictSeq a Source #

\( O(\log(\min(i,n-i))) \). Elements of a sequence after the first i. If i is negative, drop i s yields the whole sequence. If the sequence contains fewer than i elements, the empty sequence is returned.

dropLastIntStrictSeq a → StrictSeq a Source #

Drop the last n elements

Returns the Empty sequence if it has fewer than n elements.

Inherits asymptotic complexity from take.

splitAtIntStrictSeq a → (StrictSeq a, StrictSeq a) Source #

\( O(\log(\min(i,n-i))) \). Split a sequence at a given position. splitAt i s = (take i s, drop i s).

splitAtEndIntStrictSeq a → (StrictSeq a, StrictSeq a) Source #

Split at the given position counting from the end of the sequence.

Inherits asymptotic complexity from splitAt.

Indexing with predicates

findIndexL ∷ (a → Bool) → StrictSeq a → Maybe Int Source #

findIndexL p xs finds the index of the leftmost element that satisfies p, if any exist.

findIndicesL ∷ (a → Bool) → StrictSeq a → [Int] Source #

findIndicesL p finds all indices of elements that satisfy p, in ascending order.

findIndexR ∷ (a → Bool) → StrictSeq a → Maybe Int Source #

findIndexR p xs finds the index of the rightmost element that satisfies p, if any exist.

findIndicesR ∷ (a → Bool) → StrictSeq a → [Int] Source #

findIndicesR p finds all indices of elements that satisfy p, in descending order.

Zips and unzips

zipStrictSeq a → StrictSeq b → StrictSeq (a, b) Source #

zipWith ∷ (a → b → c) → StrictSeq a → StrictSeq b → StrictSeq c Source #

unzipStrictSeq (a, b) → (StrictSeq a, StrictSeq b) Source #

unzipWith ∷ (a → (b, c)) → StrictSeq a → (StrictSeq b, StrictSeq c) Source #