-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Various Haskell 2010 stream comonads -- -- Various Haskell 2010 stream comonads. * Data.Stream.Future -- provides a coinductive anti-causal stream, or non-empty -- ZipList. The comonad provides access to only the tail of the -- stream. Like a conventional ZipList, this is not a -- monad. -- --
--   data Future a = Last a | a :< Future a
--   
-- -- -- --
--   
-- -- -- --
--   data Stream a = a :< Stream a
--   
-- -- -- --
--   
-- -- -- --
--   data Zipper a = !Integer :~ (Integer -> a)
--   
-- -- @package streams @version 3.1 -- | This is an infinite bidirectional zipper module Data.Stream.Infinite.Functional.Zipper data Zipper a (:~) :: !Integer -> !(Integer -> a) -> Zipper a -- | Move the head of the zipper to the right tail :: Zipper a -> Zipper a -- | Move the head of the zipper to the left untail :: Zipper a -> Zipper a -- | intersperse y xs creates an alternating stream of -- elements from xs and y. intersperse :: a -> Zipper a -> Zipper a -- | Interleave two Zippers xs and ys, alternating -- elements from each list. -- --
--   [x1,x2,...] `interleave` [y1,y2,...] == [x1,y1,x2,y2,...]
--   interleave = (<>) 
--   
interleave :: Zipper a -> Zipper a -> Zipper a -- | transpose computes the transposition of a stream of streams. transpose :: Zipper (Zipper a) -> Zipper (Zipper a) take :: Integer -> Zipper a -> [a] -- | drop n xs drops the first n elements off the -- front of the sequence xs. drop :: Integer -> Zipper a -> Zipper a -- | splitAt n xs returns a pair consisting of the prefix -- of xs of length n and the remaining stream -- immediately following this prefix. -- -- Beware: passing a negative integer as the first argument will -- cause an error if you access the taken portion splitAt :: Integer -> Zipper a -> ([a], Zipper a) -- | reverse xs returns the elements of xs in -- reverse order. xs must be finite. reverse :: [a] -> [a] -- | xs !! n returns the element of the stream xs at -- index n. Note that the head of the stream has index 0. -- -- Beware: passing a negative integer as the first argument will -- cause an error. (!!) :: Zipper a -> Integer -> a -- | The unzip function is the inverse of the zip function. unzip :: Zipper (a, b) -> (Zipper a, Zipper b) toSequence :: (Integer -> a) -> Zipper a -- | Extract the focused element head :: Zipper a -> a -- | Cons before the head of the zipper. The head now points to the new -- element (<|) :: a -> Zipper a -> Zipper a -- | Move the head of the zipper one step to the right, returning the value -- we move over. uncons :: Zipper a -> (a, Zipper a) -- | takeWhile p xs returns the longest prefix of the -- stream xs for which the predicate p holds. takeWhile :: (a -> Bool) -> Zipper a -> [a] -- | dropWhile p xs returns the suffix remaining after -- takeWhile p xs. -- -- Beware: this function may diverge if every element of -- xs satisfies p, e.g. dropWhile even (repeat -- 0) will loop. dropWhile :: (a -> Bool) -> Zipper a -> Zipper a -- | span p xs returns the longest prefix of xs -- that satisfies p, together with the remainder of the stream. span :: (a -> Bool) -> Zipper a -> ([a], Zipper a) -- | The break p function is equivalent to span -- not . p. break :: (a -> Bool) -> Zipper a -> ([a], Zipper a) -- | The isPrefix function returns True if the first -- argument is a prefix of the second. isPrefixOf :: Eq a => [a] -> Zipper a -> Bool -- | The findIndex function takes a predicate and a stream and -- returns the index of the first element in the stream that satisfies -- the predicate, -- -- Beware: findIndex p xs will diverge if -- none of the elements of xs satisfy p. findIndex :: (a -> Bool) -> Zipper a -> Integer -- | The elemIndex function returns the index of the first element -- in the given stream which is equal (by ==) to the query -- element, -- -- Beware: elemIndex x xs will diverge if none of -- the elements of xs equal x. elemIndex :: Eq a => a -> Zipper a -> Integer -- | The zip function takes two streams and returns a list of -- corresponding pairs. -- --
--   zip = liftA2 (,)
--   
zip :: Zipper a -> Zipper b -> Zipper (a, b) -- | The zipWith function generalizes zip. Rather than -- tupling the functions, the elements are combined using the function -- passed as the first argument to zipWith. -- --
--   zipWith = liftA2
--   
zipWith :: (a -> b -> c) -> Zipper a -> Zipper b -> Zipper c instance Typeable1 Zipper instance Semigroup (Zipper a) instance Monad Zipper instance Applicative Zipper instance ComonadApply Zipper instance Apply Zipper instance Comonad Zipper instance Extend Zipper instance Functor Zipper -- | Anticausal streams implemented as non-empty skew binary random access -- lists -- -- The Applicative zips streams, the monad diagonalizes module Data.Stream.Infinite.Skew data Stream a -- | O(1) cons (<|) :: a -> Stream a -> Stream a -- | O(log n). (!!) :: Stream a -> Integer -> a -- | O(1) head :: Stream a -> a -- | O(1). tail :: Stream a -> Stream a tails :: Stream a -> Stream (Stream a) -- | O(1). uncons :: Stream a -> (a, Stream a) -- | O(log n). index :: Integer -> Stream a -> a -- | O(log n). drop :: Integer -> Stream a -> Stream a dropWhile :: (a -> Bool) -> Stream a -> Stream a span :: (a -> Bool) -> Stream a -> ([a], Stream a) break :: (a -> Bool) -> Stream a -> ([a], Stream a) split :: (a -> Bool) -> Stream a -> ([a], Stream a) splitW :: (Stream a -> Bool) -> Stream a -> ([a], Stream a) repeat :: a -> Stream a insert :: Ord a => a -> Stream a -> Stream a insertBy :: (a -> a -> Ordering) -> a -> Stream a -> Stream a adjust :: Integer -> (a -> a) -> Stream a -> Stream a update :: Integer -> a -> Stream a -> Stream a fromList :: [a] -> Stream a from :: Num a => a -> Stream a indexed :: Stream a -> Stream (Integer, a) interleave :: Stream a -> Stream a -> Stream a tabulate :: (Integer -> a) -> Stream a instance Show a => Show (Complete a) instance Monad Stream instance Semigroup (Stream a) instance Distributive Stream instance Traversable1 Stream instance Traversable Stream instance Foldable1 Stream instance Foldable Stream instance Alt Stream instance Applicative Stream instance ComonadApply Stream instance Apply Stream instance Comonad Stream instance Extend Stream instance Functor Stream instance Show a => Show (Stream a) instance Traversable1 Complete instance Traversable Complete instance Foldable1 Complete instance Foldable Complete instance Comonad Complete instance Extend Complete instance Functor Complete module Data.Stream.Infinite data Stream a (:>) :: a -> Stream a -> Stream a -- | Extract the first element of the sequence. head :: Stream a -> a -- | Extract the sequence following the head of the stream. tail :: Stream a -> Stream a -- | The inits function takes a stream xs and returns all -- the finite prefixes of xs. -- -- Note that this inits is lazier then Data.List.inits: -- --
--   inits _|_ = [] ::: _|_
--   
-- -- while for Data.List.inits: -- --
--   inits _|_ = _|_
--   
inits :: Stream a -> Stream [a] -- | The tails function takes a stream xs and returns all -- the suffixes of xs. tails :: Stream a -> Stream (Stream a) -- | Map a pure function over a stream map :: (a -> b) -> Stream a -> Stream b -- | intersperse y xs creates an alternating stream of -- elements from xs and y. intersperse :: a -> Stream a -> Stream a -- | Interleave two Streams xs and ys, alternating -- elements from each list. -- --
--   [x1,x2,...] `interleave` [y1,y2,...] == [x1,y1,x2,y2,...]
--   
interleave :: Stream a -> Stream a -> Stream a -- | scanl yields a stream of successive reduced values from: -- --
--   scanl f z [x1, x2, ...] == [z, z `f` x1, (z `f` x1) `f` x2, ...]
--   
scanl :: (a -> b -> a) -> a -> Stream b -> Stream a -- | scanl yields a stream of successive reduced values from: -- --
--   scanl f z [x1, x2, ...] == [z, z `f` x1, (z `f` x1) `f` x2, ...]
--   
scanl' :: (a -> b -> a) -> a -> Stream b -> Stream a -- | scanl1 is a variant of scanl that has no starting value -- argument: -- --
--   scanl1 f [x1, x2, ...] == [x1, x1 `f` x2, ...]
--   
scanl1 :: (a -> a -> a) -> Stream a -> Stream a -- | scanl1' is a strict scanl that has no starting value. scanl1' :: (a -> a -> a) -> Stream a -> Stream a -- | transpose computes the transposition of a stream of streams. transpose :: Stream (Stream a) -> Stream (Stream a) -- | iterate f x produces the infinite sequence of repeated -- applications of f to x. -- --
--   iterate f x = [x, f x, f (f x), ..]
--   
iterate :: (a -> a) -> a -> Stream a -- | repeat x returns a constant stream, where all elements -- are equal to x. repeat :: a -> Stream a -- | cycle xs returns the infinite repetition of -- xs: -- --
--   cycle [1,2,3] = Cons 1 (Cons 2 (Cons 3 (Cons 1 (Cons 2 ...
--   
cycle :: NonEmpty a -> Stream a -- | The unfold function is similar to the unfold for lists. Note there is -- no base case: all streams must be infinite. unfold :: (a -> (b, a)) -> a -> Stream b -- | take n xs returns the first n elements of -- xs. -- -- Beware: passing a negative integer as the first argument will -- cause an error. take :: Int -> Stream a -> [a] -- | drop n xs drops the first n elements off the -- front of the sequence xs. -- -- Beware: passing a negative integer as the first argument will -- cause an error. drop :: Int -> Stream a -> Stream a -- | splitAt n xs returns a pair consisting of the prefix -- of xs of length n and the remaining stream -- immediately following this prefix. -- -- Beware: passing a negative integer as the first argument will -- cause an error. splitAt :: Int -> Stream a -> ([a], Stream a) -- | takeWhile p xs returns the longest prefix of the -- stream xs for which the predicate p holds. takeWhile :: (a -> Bool) -> Stream a -> [a] -- | dropWhile p xs returns the suffix remaining after -- takeWhile p xs. -- -- Beware: this function may diverge if every element of -- xs satisfies p, e.g. dropWhile even (repeat -- 0) will loop. dropWhile :: (a -> Bool) -> Stream a -> Stream a -- | span p xs returns the longest prefix of xs -- that satisfies p, together with the remainder of the stream. span :: (a -> Bool) -> Stream a -> ([a], Stream a) -- | The break p function is equivalent to span -- not . p. break :: (a -> Bool) -> Stream a -> ([a], Stream a) -- | filter p xs, removes any elements from xs -- that do not satisfy p. -- -- Beware: this function may diverge if there is no element of -- xs that satisfies p, e.g. filter odd (repeat -- 0) will loop. filter :: (a -> Bool) -> Stream a -> Stream a -- | The partition function takes a predicate p and a -- stream xs, and returns a pair of streams. The first stream -- corresponds to the elements of xs for which p holds; -- the second stream corresponds to the elements of xs for which -- p does not hold. -- -- Beware: One of the elements of the tuple may be undefined. For -- example, fst (partition even (repeat 0)) == repeat 0; on the -- other hand snd (partition even (repeat 0)) is undefined. partition :: (a -> Bool) -> Stream a -> (Stream a, Stream a) -- | The group function takes a stream and returns a stream of lists -- such that flattening the resulting stream is equal to the argument. -- Moreover, each sublist in the resulting stream contains only equal -- elements. For example, -- --
--   group $ cycle "Mississippi" = "M" ::: "i" ::: "ss" ::: "i" ::: "ss" ::: "i" ::: "pp" ::: "i" ::: "M" ::: "i" ::: ...
--   
group :: Eq a => Stream a -> Stream (NonEmpty a) groupBy :: (a -> a -> Bool) -> Stream a -> Stream (NonEmpty a) -- | The isPrefix function returns True if the first -- argument is a prefix of the second. isPrefixOf :: Eq a => [a] -> Stream a -> Bool -- | xs !! n returns the element of the stream xs at -- index n. Note that the head of the stream has index 0. -- -- Beware: passing a negative integer as the first argument will -- cause an error. (!!) :: Stream a -> Int -> a -- | The elemIndex function returns the index of the first element -- in the given stream which is equal (by ==) to the query -- element, -- -- Beware: elemIndex x xs will diverge if none of -- the elements of xs equal x. elemIndex :: Eq a => a -> Stream a -> Int -- | The elemIndices function extends elemIndex, by returning -- the indices of all elements equal to the query element, in ascending -- order. -- -- Beware: elemIndices x xs will diverge -- if any suffix of xs does not contain x. elemIndices :: Eq a => a -> Stream a -> Stream Int -- | The findIndex function takes a predicate and a stream and -- returns the index of the first element in the stream that satisfies -- the predicate, -- -- Beware: findIndex p xs will diverge if -- none of the elements of xs satisfy p. findIndex :: (a -> Bool) -> Stream a -> Int -- | The findIndices function extends findIndex, by returning -- the indices of all elements satisfying the predicate, in ascending -- order. -- -- Beware: findIndices p xs will diverge -- if all the elements of any suffix of xs fails to satisfy -- p. findIndices :: (a -> Bool) -> Stream a -> Stream Int -- | The zip function takes two streams and returns a list of -- corresponding pairs. zip :: Stream a -> Stream b -> Stream (a, b) -- | The zipWith function generalizes zip. Rather than -- tupling the functions, the elements are combined using the function -- passed as the first argument to zipWith. zipWith :: (a -> b -> c) -> Stream a -> Stream b -> Stream c -- | The unzip function is the inverse of the zip function. unzip :: Stream (a, b) -> (Stream a, Stream b) -- | The words function breaks a stream of characters into a stream -- of words, which were delimited by white space. -- -- Beware: if the stream of characters xs does not -- contain white space, accessing the tail of words xs will -- loop. words :: Stream Char -> Stream String -- | The unwords function is an inverse operation to words. -- It joins words with separating spaces. unwords :: Stream String -> Stream Char -- | The lines function breaks a stream of characters into a list of -- strings at newline characters. The resulting strings do not contain -- newlines. -- -- Beware: if the stream of characters xs does not -- contain newline characters, accessing the tail of lines xs -- will loop. lines :: Stream Char -> Stream String -- | The unlines function is an inverse operation to lines. -- It joins lines, after appending a terminating newline to each. unlines :: Stream String -> Stream Char -- | The fromList converts an infinite list to a stream. -- -- Beware: Passing a finite list, will cause an error. fromList :: [a] -> Stream a instance Typeable1 Stream instance Show a => Show (Stream a) instance Data a => Data (Stream a) instance Monad Stream instance Traversable1 Stream instance Foldable1 Stream instance Traversable Stream instance Foldable Stream instance Applicative Stream instance ComonadApply Stream instance Apply Stream instance Comonad Stream instance Extend Stream instance Distributive Stream instance Functor Stream -- | This library can be used to generate values (for example, new names) -- without the need to thread state. This means that functions that need -- to generate new values only need a supply object as an argument, and -- they do not need to return a new supply object as a result. This -- decreases the number of data-dependencies in a program, which makes it -- easier to exploit parallelism. -- -- The technique for generating new values is based on the paper ''On -- Generating Unique Names'' by Lennart Augustsson, Mikael Rittri, and -- Dan Synek. module Data.Stream.Supply data Supply a newSupply :: (a -> a) -> a -> IO (Supply a) newEnumSupply :: Enum a => IO (Supply a) newNumSupply :: Num a => IO (Supply a) newDupableSupply :: (a -> a) -> a -> IO (Supply a) newDupableEnumSupply :: Enum a => IO (Supply a) newDupableNumSupply :: Num a => IO (Supply a) leftSupply :: Supply a -> Supply a rightSupply :: Supply a -> Supply a split :: Supply a -> Stream (Supply a) splits :: Integral b => Supply a -> b -> Supply a splitSkew :: Supply a -> Stream (Supply a) split2 :: Supply a -> (Supply a, Supply a) split3 :: Supply a -> (Supply a, Supply a, Supply a) split4 :: Supply a -> (Supply a, Supply a, Supply a, Supply a) instance Typeable1 Supply instance Show a => Show (Supply a) instance Read a => Read (Supply a) instance Eq a => Eq (Supply a) instance Ord a => Ord (Supply a) instance Data a => Data (Supply a) instance Traversable1 Supply instance Traversable Supply instance Foldable1 Supply instance Foldable Supply instance Applicative Supply instance Apply Supply instance Comonad Supply instance Extend Supply instance Functor Supply -- | Anticausal streams implemented as non-empty skew binary random access -- lists -- -- The Applicative zips streams, but since these are potentially infinite -- this is stricter than would be desired. You almost always want module Data.Stream.Future.Skew data Future a Last :: !(Complete a) -> Future a (:<) :: !(Complete a) -> Future a -> Future a -- | O(1) cons (<|) :: a -> Future a -> Future a cons :: a -> Future a -> Future a -- | O(log n). length :: Future a -> Int -- | O(1) head :: Future a -> a -- | O(1). tail :: Future a -> Maybe (Future a) tails :: Future a -> Future (Future a) -- | O(log n). last :: Future a -> a -- | O(1). uncons :: Future a -> (a, Maybe (Future a)) -- | O(log n). index :: Int -> Future a -> a -- | O(log n). drop :: Int -> Future a -> Maybe (Future a) dropWhile :: (a -> Bool) -> Future a -> Maybe (Future a) indexed :: Future a -> Future (Int, a) from :: Num a => a -> Future a break :: (a -> Bool) -> Future a -> ([a], Maybe (Future a)) span :: (a -> Bool) -> Future a -> ([a], Maybe (Future a)) split :: (a -> Bool) -> Future a -> ([a], Maybe (Future a)) splitW :: (Future a -> Bool) -> Future a -> ([a], Maybe (Future a)) repeat :: a -> Future a -- | O(log n) replicate :: Int -> a -> Future a insert :: Ord a => a -> Future a -> Future a insertBy :: (a -> a -> Ordering) -> a -> Future a -> Future a update :: Int -> a -> Future a -> Future a adjust :: Int -> (a -> a) -> Future a -> Future a fromList :: [a] -> Future a toFuture :: [a] -> Maybe (Future a) instance Show a => Show (Complete a) instance Traversable1 Future instance Traversable Future instance Foldable1 Future instance Foldable Future instance Alt Future instance Applicative Future instance ComonadApply Future instance Apply Future instance Comonad Future instance Extend Future instance Functor Future instance Show a => Show (Future a) instance Traversable1 Complete instance Traversable Complete instance Foldable1 Complete instance Foldable Complete instance Comonad Complete instance Extend Complete instance Functor Complete module Data.Stream.Future data Future a Last :: a -> Future a (:<) :: a -> Future a -> Future a cons :: a -> Future a -> Future a (<|) :: a -> Future a -> Future a head :: Future a -> a tail :: Future a -> Maybe (Future a) length :: Future a -> Int tails :: Future a -> Future (Future a) map :: (a -> b) -> Future a -> Future b index :: Int -> Future a -> a instance Typeable1 Future instance Eq a => Eq (Future a) instance Ord a => Ord (Future a) instance Show a => Show (Future a) instance Read a => Read (Future a) instance Data a => Data (Future a) instance Applicative Future instance Semigroup (Future a) instance Alt Future instance ComonadApply Future instance Apply Future instance Comonad Future instance Extend Future instance Traversable1 Future instance Foldable1 Future instance Traversable Future instance Foldable Future instance Functor Future