chimera-0.2.0.0: Lazy, infinite streams with O(1) indexing.

Copyright(c) 2018 Andrew Lelechenko
LicenseMIT
MaintainerAndrew Lelechenko <andrew.lelechenko@gmail.com>
Safe HaskellNone
LanguageHaskell2010

Data.Chimera

Contents

Description

Lazy, infinite stream with O(1) indexing.

Synopsis

Documentation

data Chimera a Source #

Representation of a lazy infinite stream, offering indexing via index in constant time.

Instances
Functor Chimera Source # 
Instance details

Defined in Data.Chimera

Methods

fmap :: (a -> b) -> Chimera a -> Chimera b #

(<$) :: a -> Chimera b -> Chimera a #

Applicative Chimera Source #

Similar to ZipList.

Instance details

Defined in Data.Chimera

Methods

pure :: a -> Chimera a #

(<*>) :: Chimera (a -> b) -> Chimera a -> Chimera b #

liftA2 :: (a -> b -> c) -> Chimera a -> Chimera b -> Chimera c #

(*>) :: Chimera a -> Chimera b -> Chimera b #

(<*) :: Chimera a -> Chimera b -> Chimera a #

Foldable Chimera Source # 
Instance details

Defined in Data.Chimera

Methods

fold :: Monoid m => Chimera m -> m #

foldMap :: Monoid m => (a -> m) -> Chimera a -> m #

foldr :: (a -> b -> b) -> b -> Chimera a -> b #

foldr' :: (a -> b -> b) -> b -> Chimera a -> b #

foldl :: (b -> a -> b) -> b -> Chimera a -> b #

foldl' :: (b -> a -> b) -> b -> Chimera a -> b #

foldr1 :: (a -> a -> a) -> Chimera a -> a #

foldl1 :: (a -> a -> a) -> Chimera a -> a #

toList :: Chimera a -> [a] #

null :: Chimera a -> Bool #

length :: Chimera a -> Int #

elem :: Eq a => a -> Chimera a -> Bool #

maximum :: Ord a => Chimera a -> a #

minimum :: Ord a => Chimera a -> a #

sum :: Num a => Chimera a -> a #

product :: Num a => Chimera a -> a #

Traversable Chimera Source # 
Instance details

Defined in Data.Chimera

Methods

traverse :: Applicative f => (a -> f b) -> Chimera a -> f (Chimera b) #

sequenceA :: Applicative f => Chimera (f a) -> f (Chimera a) #

mapM :: Monad m => (a -> m b) -> Chimera a -> m (Chimera b) #

sequence :: Monad m => Chimera (m a) -> m (Chimera a) #

index :: Chimera a -> Word -> a Source #

Convert a stream back to a function.

Construction

tabulate :: (Word -> a) -> Chimera a Source #

Create a stream from the function. The function must be well-defined for any value of argument and should not return error / undefined.

tabulateFix :: ((Word -> a) -> Word -> a) -> Chimera a Source #

Create a stream from the unfixed function.

tabulateM :: forall m a. Monad m => (Word -> m a) -> m (Chimera a) Source #

Create a stream from the monadic function.

tabulateFixM :: forall m a. Monad m => ((Word -> m a) -> Word -> m a) -> m (Chimera a) Source #

Create a stream from the unfixed monadic function.

Manipulation

mapWithKey :: (Word -> a -> b) -> Chimera a -> Chimera b Source #

Map over all indices and respective elements in the stream.

traverseWithKey :: forall m a b. Monad m => (Word -> a -> m b) -> Chimera a -> m (Chimera b) Source #

Traverse over all indices and respective elements in the stream.

zipWithKey :: (Word -> a -> b -> c) -> Chimera a -> Chimera b -> Chimera c Source #

Zip two streams with the function, which is provided with an index and respective elements of both streams.

zipWithKeyM :: forall m a b c. Monad m => (Word -> a -> b -> m c) -> Chimera a -> Chimera b -> m (Chimera c) Source #

Zip two streams with the monadic function, which is provided with an index and respective elements of both streams.