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 #

Instances

Monad Stream # 

Methods

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

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

return :: a -> Stream a #

fail :: String -> Stream a #

Functor Stream # 

Methods

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

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

Applicative Stream # 

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 # 

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 # 

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 # 

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 # 

Associated Types

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

Methods

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

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

Comonad Stream # 

Methods

extract :: Stream a -> a #

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

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

ComonadApply Stream # 

Methods

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

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

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

Traversable1 Stream # 

Methods

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

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

Alt Stream # 

Methods

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

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

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

Apply Stream # 

Methods

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

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

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

Extend Stream # 

Methods

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

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

Foldable1 Stream # 

Methods

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

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

toNonEmpty :: Stream a -> NonEmpty a #

Show a => Show (Stream a) # 

Methods

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

show :: Stream a -> String #

showList :: [Stream a] -> ShowS #

Semigroup (Stream a) # 

Methods

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

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

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

type Rep Stream # 

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

O(1) cons

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

O(log n).

tail :: Stream a -> Stream a #

O(1).

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

O(1).

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

O(log n).

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

O(n).

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

O(n)

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

O(n)

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

(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) #

(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 #

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

O(n)

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

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

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

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

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

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