raz-0.1.0.0: Random Access Zippers

Data.Raz.Core.Sequence

Synopsis

# Construction

cons :: MonadRandom m => a -> Tree a -> m (Tree a) Source #

snoc :: MonadRandom m => Tree a -> a -> m (Tree a) Source #

append :: MonadRandom m => Tree a -> Tree a -> m (Tree a) Source #

# Repetition

replicate :: MonadRandom m => Int -> a -> m (Tree a) Source #

# Sublists

tails :: MonadRandom m => Tree a -> m (Tree (Tree a)) Source #

O(n*log n). The sequence of suffixes of a sequence.

tailsWith :: MonadRandom m => (Tree a -> m b) -> Tree a -> m (Tree b) Source #

A generalization of tails where the suffixes are passed to a monadic continuation, recording their results.

tailsWith' :: Applicative m => (Tree a -> m b) -> Tree a -> m (Tree b) Source #

O(n*log n). The sequence of non-empty suffixes of a sequence.

The underlying tree structure is reused to represent the overall sequence, as well as every suffix, which might exacerbate worst case situations.

# Sequential searches

takeWhileL :: (a -> Bool) -> Tree a -> Tree a Source #

takeWhileR :: (a -> Bool) -> Tree a -> Tree a Source #

dropWhileL :: (a -> Bool) -> Tree a -> Tree a Source #

dropWhileR :: (a -> Bool) -> Tree a -> Tree a Source #

spanL :: (a -> Bool) -> Tree a -> (Tree a, Tree a) Source #

spanR :: (a -> Bool) -> Tree a -> (Tree a, Tree a) Source #

breakL :: (a -> Bool) -> Tree a -> (Tree a, Tree a) Source #

breakR :: (a -> Bool) -> Tree a -> (Tree a, Tree a) Source #

partition :: (a -> Bool) -> Tree a -> (Tree a, Tree a) Source #

partition' :: (a -> Bool) -> Tree a -> (TList a, TList a) Source #

partition'' :: (a -> Bool) -> Lev -> Tree a -> (TList a, TList a) -> (TList a, TList a) Source #

filter :: (a -> Bool) -> Tree a -> Tree a Source #

# Indexing

lookup :: Int -> Tree a -> Maybe a Source #

log(n). The element at the specified position, counting from 0.

(!?) :: Tree a -> Int -> Maybe a Source #

index :: Tree a -> Int -> a Source #

adjust :: (a -> a) -> Int -> Tree a -> Tree a Source #

adjust' :: (a -> a) -> Int -> Tree a -> Tree a Source #

update :: Int -> a -> Tree a -> Tree a Source #

checked :: Int -> (Tree a -> b) -> b -> Tree a -> b Source #

Helper function for checking bounds.

take :: Int -> Tree a -> Tree a Source #

drop :: Int -> Tree a -> Tree a Source #

insertAt :: MonadRandom m => Int -> a -> Tree a -> m (Tree a) Source #

deleteAt :: Int -> Tree a -> Tree a Source #

splitAt :: Int -> Tree a -> (Tree a, Tree a) Source #

## Indexing with predicates

elemIndexL :: Eq a => a -> Tree a -> Maybe Int Source #

elemIndicesL :: Eq a => a -> Tree a -> [Int] Source #

elemIndexR :: Eq a => a -> Tree a -> Maybe Int Source #

elemIndicesR :: Eq a => a -> Tree a -> [Int] Source #

findIndexL :: (a -> Bool) -> Tree a -> Maybe Int Source #

findIndicesL :: (a -> Bool) -> Tree a -> [Int] Source #

findIndicesL' :: Int -> (a -> Bool) -> Tree a -> [Int] -> [Int] Source #

findIndexR :: (a -> Bool) -> Tree a -> Maybe Int Source #

findIndicesR :: (a -> Bool) -> Tree a -> [Int] Source #

findIndicesR' :: Int -> (a -> Bool) -> Tree a -> [Int] -> [Int] Source #

# Transformations

mapWithIndex :: (Int -> a -> b) -> Tree a -> Tree b Source #

mapWithIndex' :: (Int -> a -> b) -> Int -> Tree a -> Tree b Source #

traverseWithIndex :: Applicative f => (Int -> a -> f b) -> Tree a -> f (Tree b) Source #

traverseWithIndex' :: Applicative f => (Int -> a -> f b) -> Int -> Tree a -> f (Tree b) Source #

# Zips

zip :: Tree a -> Tree b -> Tree (a, b) Source #

zipWith :: (a -> b -> c) -> Tree a -> Tree b -> Tree c Source #

zipWith' :: (a -> b -> c) -> TList a -> TList b -> TList c -> TList c Source #

# Helpers

ap :: Tree (a -> b) -> Tree a -> Tree b Source #

A hacky implementation of the Applicative product.