EdisonCore-1.3.1: A library of efficent, purely-functional data structures (Core Implementations)

CopyrightCopyright (c) 1998-1999, 2008 Chris Okasaki
LicenseMIT; see COPYRIGHT file for terms and conditions
Maintainerrobdockins AT fastmail DOT fm
Stabilitystable
PortabilityGHC, Hugs (MPTC and FD)
Safe HaskellNone
LanguageHaskell2010

Data.Edison.Seq.RevSeq

Contents

Description

This module defines a sequence adaptor Rev s. If s is a sequence type constructor, then Rev s is a sequence type constructor that is identical to s, except that it is kept in the opposite order. Also keeps explicit track of the size of the sequence, similar to the Sized adaptor in Data.Edison.Seq.SizedSeq.

This module is most useful when s is a sequence type that offers fast access to the front but slow access to the rear, and your application needs the opposite (i.e., fast access to the rear but slow access to the front).

All time complexities are determined by the underlying sequence, except that the complexities for accessing the left and right sides of the sequence are exchanged, and size becomes O( 1 ).

Synopsis

Rev Sequence Type

data Rev s a Source

Instances

Sequence s => Monad (Rev s) Source 
Sequence s => Functor (Rev s) Source 
Sequence s => Applicative (Rev s) Source 
Sequence s => Sequence (Rev s) Source 
Sequence s => Alternative (Rev s) Source 
Sequence s => MonadPlus (Rev s) Source 
Eq (s a) => Eq (Rev s a) Source 
(Sequence s, Ord a, Eq (s a)) => Ord (Rev s a) Source 
(Sequence s, Read (s a)) => Read (Rev s a) Source 
(Sequence s, Show (s a)) => Show (Rev s a) Source 
(Sequence s, Arbitrary (s a)) => Arbitrary (Rev s a) Source 
(Sequence s, CoArbitrary (s a)) => CoArbitrary (Rev s a) Source 
Sequence s => Monoid (Rev s a) Source 

Sequence Operations

empty :: Sequence s => Rev s a Source

singleton :: Sequence s => a -> Rev s a Source

lcons :: Sequence s => a -> Rev s a -> Rev s a Source

rcons :: Sequence s => a -> Rev s a -> Rev s a Source

append :: Sequence s => Rev s a -> Rev s a -> Rev s a Source

lview :: (Sequence s, Monad m) => Rev s a -> m (a, Rev s a) Source

lhead :: Sequence s => Rev s a -> a Source

ltail :: Sequence s => Rev s a -> Rev s a Source

rview :: (Sequence s, Monad m) => Rev s a -> m (a, Rev s a) Source

rhead :: Sequence s => Rev s a -> a Source

rtail :: Sequence s => Rev s a -> Rev s a Source

lheadM :: (Sequence s, Monad m) => Rev s a -> m a Source

ltailM :: (Sequence s, Monad m) => Rev s a -> m (Rev s a) Source

rheadM :: (Sequence s, Monad m) => Rev s a -> m a Source

rtailM :: (Sequence s, Monad m) => Rev s a -> m (Rev s a) Source

null :: Sequence s => Rev s a -> Bool Source

size :: Sequence s => Rev s a -> Int Source

concat :: Sequence s => Rev s (Rev s a) -> Rev s a Source

reverse :: Sequence s => Rev s a -> Rev s a Source

reverseOnto :: Sequence s => Rev s a -> Rev s a -> Rev s a Source

fromList :: Sequence s => [a] -> Rev s a Source

toList :: Sequence s => Rev s a -> [a] Source

map :: Sequence s => (a -> b) -> Rev s a -> Rev s b Source

concatMap :: Sequence s => (a -> Rev s b) -> Rev s a -> Rev s b Source

fold :: Sequence s => (a -> b -> b) -> b -> Rev s a -> b Source

fold' :: Sequence s => (a -> b -> b) -> b -> Rev s a -> b Source

fold1 :: Sequence s => (a -> a -> a) -> Rev s a -> a Source

fold1' :: Sequence s => (a -> a -> a) -> Rev s a -> a Source

foldr :: Sequence s => (a -> b -> b) -> b -> Rev s a -> b Source

foldr' :: Sequence s => (a -> b -> b) -> b -> Rev s a -> b Source

foldl :: Sequence s => (b -> a -> b) -> b -> Rev s a -> b Source

foldl' :: Sequence s => (b -> a -> b) -> b -> Rev s a -> b Source

foldr1 :: Sequence s => (a -> a -> a) -> Rev s a -> a Source

foldr1' :: Sequence s => (a -> a -> a) -> Rev s a -> a Source

foldl1 :: Sequence s => (a -> a -> a) -> Rev s a -> a Source

foldl1' :: Sequence s => (a -> a -> a) -> Rev s a -> a Source

reducer :: Sequence s => (a -> a -> a) -> a -> Rev s a -> a Source

reducer' :: Sequence s => (a -> a -> a) -> a -> Rev s a -> a Source

reducel :: Sequence s => (a -> a -> a) -> a -> Rev s a -> a Source

reducel' :: Sequence s => (a -> a -> a) -> a -> Rev s a -> a Source

reduce1 :: Sequence s => (a -> a -> a) -> Rev s a -> a Source

reduce1' :: Sequence s => (a -> a -> a) -> Rev s a -> a Source

copy :: Sequence s => Int -> a -> Rev s a Source

inBounds :: Sequence s => Int -> Rev s a -> Bool Source

lookup :: Sequence s => Int -> Rev s a -> a Source

lookupM :: (Sequence s, Monad m) => Int -> Rev s a -> m a Source

lookupWithDefault :: Sequence s => a -> Int -> Rev s a -> a Source

update :: Sequence s => Int -> a -> Rev s a -> Rev s a Source

adjust :: Sequence s => (a -> a) -> Int -> Rev s a -> Rev s a Source

mapWithIndex :: Sequence s => (Int -> a -> b) -> Rev s a -> Rev s b Source

foldrWithIndex :: Sequence s => (Int -> a -> b -> b) -> b -> Rev s a -> b Source

foldrWithIndex' :: Sequence s => (Int -> a -> b -> b) -> b -> Rev s a -> b Source

foldlWithIndex :: Sequence s => (b -> Int -> a -> b) -> b -> Rev s a -> b Source

foldlWithIndex' :: Sequence s => (b -> Int -> a -> b) -> b -> Rev s a -> b Source

take :: Sequence s => Int -> Rev s a -> Rev s a Source

drop :: Sequence s => Int -> Rev s a -> Rev s a Source

splitAt :: Sequence s => Int -> Rev s a -> (Rev s a, Rev s a) Source

subseq :: Sequence s => Int -> Int -> Rev s a -> Rev s a Source

filter :: Sequence s => (a -> Bool) -> Rev s a -> Rev s a Source

partition :: Sequence s => (a -> Bool) -> Rev s a -> (Rev s a, Rev s a) Source

takeWhile :: Sequence s => (a -> Bool) -> Rev s a -> Rev s a Source

dropWhile :: Sequence s => (a -> Bool) -> Rev s a -> Rev s a Source

splitWhile :: Sequence s => (a -> Bool) -> Rev s a -> (Rev s a, Rev s a) Source

zip :: Sequence s => Rev s a -> Rev s b -> Rev s (a, b) Source

zip3 :: Sequence s => Rev s a -> Rev s b -> Rev s c -> Rev s (a, b, c) Source

zipWith :: Sequence s => (a -> b -> c) -> Rev s a -> Rev s b -> Rev s c Source

zipWith3 :: Sequence s => (a -> b -> c -> d) -> Rev s a -> Rev s b -> Rev s c -> Rev s d Source

unzip :: Sequence s => Rev s (a, b) -> (Rev s a, Rev s b) Source

unzip3 :: Sequence s => Rev s (a, b, c) -> (Rev s a, Rev s b, Rev s c) Source

unzipWith :: Sequence s => (a -> b) -> (a -> c) -> Rev s a -> (Rev s b, Rev s c) Source

unzipWith3 :: Sequence s => (a -> b) -> (a -> c) -> (a -> d) -> Rev s a -> (Rev s b, Rev s c, Rev s d) Source

strict :: Sequence s => Rev s a -> Rev s a Source

strictWith :: Sequence s => (a -> b) -> Rev s a -> Rev s a Source

Unit testing

Documentation

Other supported operations

fromSeq :: Sequence s => s a -> Rev s a Source

toSeq :: Sequence s => Rev s a -> s a Source