bricks-internal-0.0.0.4: ...

Bricks.Internal.Seq

Synopsis

# Documentation

data Seq a :: * -> * #

General-purpose finite sequences.

Instances

(<|) :: a -> Seq a -> Seq a infixr 5 #

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

(|>) :: Seq a -> a -> Seq a infixl 5 #

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

adjust :: (a -> a) -> Int -> Seq a -> Seq a #

O(log(min(i,n-i))). Update the element at the specified position. If the position is out of range, the original sequence is returned. adjust can lead to poor performance and even memory leaks, because it does not force the new value before installing it in the sequence. adjust' should usually be preferred.

adjustLast :: (a -> a) -> Seq a -> Seq a Source #

>>> adjustLast (+ 1) (fromList [1, 2, 3])
fromList [1,2,4]

>>> adjustLast (+ 1) empty
fromList []


append :: Seq a -> Seq a -> Seq a Source #

Alias for ><.

concat :: Foldable f => f (Seq a) -> Seq a Source #

fold specialized for Seq.

concatMap :: Foldable f => (a -> Seq b) -> f a -> Seq b Source #

Like concatMap, but for Seq.

dropWhileL :: (a -> Bool) -> Seq a -> Seq a #

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

dropWhileR :: (a -> Bool) -> Seq a -> Seq a #

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)).

empty :: Seq a #

O(1). The empty sequence.

filter :: (a -> Bool) -> Seq a -> Seq a #

O(n). The filter function takes a predicate p and a sequence xs and returns a sequence of those elements which satisfy the predicate.

fromList :: [a] -> Seq a #

O(n). Create a sequence from a finite list of elements. There is a function toList in the opposite direction for all instances of the Foldable class, including Seq.

intersperse :: a -> Seq a -> Seq a Source #

Like intersperse, but for Seq.

length :: Seq a -> Int #

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

map :: (a -> b) -> Seq a -> Seq b Source #

Specialization of fmap.

minimum :: Ord a => Seq a -> Maybe a Source #

>>> minimum (fromList [1,2,3])
Just 1

>>> minimum empty
Nothing


maximum :: Ord a => Seq a -> Maybe a Source #

>>> maximum (fromList [1,2,3])
Just 3

>>> maximum empty
Nothing


null :: Seq a -> Bool #

O(1). Is this the empty sequence?

toList :: Seq a -> [a] Source #

Specialization of toList for Seq.

trimWhile :: (a -> Bool) -> Seq a -> Seq a Source #

singleton :: a -> Seq a #

O(1). A singleton sequence.