streams-3.3: Various Haskell 2010 stream comonads

Copyright(C) 2011 Edward Kmett
LicenseBSD-style (see the file LICENSE)
MaintainerEdward Kmett <ekmett@gmail.com>
Stabilityprovisional
Portabilityportable
Safe HaskellTrustworthy
LanguageHaskell98

Data.Stream.Infinite.Skew

Description

Anticausal streams implemented as non-empty skew binary random access lists

The Applicative zips streams, the monad diagonalizes

Synopsis

Documentation

data Stream a Source #

Instances

Monad Stream Source # 

Methods

(>>=) :: Stream a -> (a -> Stream b) -> Stream b #

(>>) :: Stream a -> Stream b -> Stream b #

return :: a -> Stream a #

fail :: String -> Stream a #

Functor Stream Source # 

Methods

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

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

Applicative Stream Source # 

Methods

pure :: a -> Stream a #

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

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

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

Foldable Stream Source # 

Methods

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

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

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

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

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

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

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

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

toList :: Stream a -> [a] #

null :: Stream a -> Bool #

length :: Stream a -> Int #

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

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

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

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

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

Traversable Stream Source # 

Methods

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

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

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

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

Distributive Stream Source # 

Methods

distribute :: Functor f => f (Stream a) -> Stream (f a) #

collect :: Functor f => (a -> Stream b) -> f a -> Stream (f b) #

distributeM :: Monad m => m (Stream a) -> Stream (m a) #

collectM :: Monad m => (a -> Stream b) -> m a -> Stream (m b) #

Representable Stream Source # 

Associated Types

type Rep (Stream :: * -> *) :: * #

Methods

tabulate :: (Rep Stream -> a) -> Stream a #

index :: Stream a -> Rep Stream -> a #

Comonad Stream Source # 

Methods

extract :: Stream a -> a #

duplicate :: Stream a -> Stream (Stream a) #

extend :: (Stream a -> b) -> Stream a -> Stream b #

ComonadApply Stream Source # 

Methods

(<@>) :: Stream (a -> b) -> Stream a -> Stream b #

(@>) :: Stream a -> Stream b -> Stream b #

(<@) :: Stream a -> Stream b -> Stream a #

Traversable1 Stream Source # 

Methods

traverse1 :: Apply f => (a -> f b) -> Stream a -> f (Stream b) #

sequence1 :: Apply f => Stream (f b) -> f (Stream b) #

Alt Stream Source # 

Methods

(<!>) :: Stream a -> Stream a -> Stream a #

some :: Applicative Stream => Stream a -> Stream [a] #

many :: Applicative Stream => Stream a -> Stream [a] #

Apply Stream Source # 

Methods

(<.>) :: Stream (a -> b) -> Stream a -> Stream b #

(.>) :: Stream a -> Stream b -> Stream b #

(<.) :: Stream a -> Stream b -> Stream a #

Extend Stream Source # 

Methods

duplicated :: Stream a -> Stream (Stream a) #

extended :: (Stream a -> b) -> Stream a -> Stream b #

Foldable1 Stream Source # 

Methods

fold1 :: Semigroup m => Stream m -> m #

foldMap1 :: Semigroup m => (a -> m) -> Stream a -> m #

Show a => Show (Stream a) Source # 

Methods

showsPrec :: Int -> Stream a -> ShowS #

show :: Stream a -> String #

showList :: [Stream a] -> ShowS #

Semigroup (Stream a) Source # 

Methods

(<>) :: Stream a -> Stream a -> Stream a #

sconcat :: NonEmpty (Stream a) -> Stream a #

stimes :: Integral b => b -> Stream a -> Stream a #

type Rep Stream Source # 

(<|) :: a -> Stream a -> Stream a infixr 5 Source #

O(1) cons

(!!) :: Stream a -> Integer -> a Source #

O(log n).

tail :: Stream a -> Stream a Source #

O(1).

uncons :: Stream a -> (a, Stream a) Source #

O(1).

drop :: Integer -> Stream a -> Stream a Source #

O(log n).

dropWhile :: (a -> Bool) -> Stream a -> Stream a Source #

O(n).

span :: (a -> Bool) -> Stream a -> ([a], Stream a) Source #

O(n)

break :: (a -> Bool) -> Stream a -> ([a], Stream a) Source #

O(n)

split :: (a -> Bool) -> Stream a -> ([a], Stream a) Source #

(O(n), O(log n)) split at _some_ edge where function goes from False to True. best used with a monotonic function

splitW :: (Stream a -> Bool) -> Stream a -> ([a], Stream a) Source #

(O(n), O(log n)) split at _some_ edge where function goes from False to True. best used with a monotonic function

splitW p xs = (map extract &&& fmap (fmap extract)) . split p . duplicate

repeat :: a -> Stream a Source #

insert :: Ord a => a -> Stream a -> Stream a Source #

O(n)

insertBy :: (a -> a -> Ordering) -> a -> Stream a -> Stream a Source #

O(n). Finds the split in O(log n), but then has to recons

adjust :: Integer -> (a -> a) -> Stream a -> Stream a Source #

O(log n) Change the value of the nth entry in the future

update :: Integer -> a -> Stream a -> Stream a Source #

from :: Num a => a -> Stream a Source #