-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A library for manipulating infinite lists. -- -- This package implements quite a few functions analogous to those from -- Data.List to create and manipulate infinite lists. @package Stream @version 0.1 -- | Streams are infinite lists. Most operations on streams are completely -- analogous to the definition in Data.List. module Data.Stream -- | An infinite sequence. data Stream a Cons :: 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 -- | Apply a function uniformly over all elements of a sequence. map :: (a -> b) -> Stream a -> Stream b intersperse :: a -> Stream a -> Stream a -- | iterate f x function 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 :: [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 :: (c -> (a, c)) -> c -> Stream a -- | take n xs returns the first n -- elements of xs. take :: Int -> Stream a -> [a] drop :: (Num a, Ord a) => a -> Stream a1 -> Stream a1 -- | The splitAt function takes an integer n and a stream -- xs | and returns a pair consisting of the prefix of -- xs of length | n and the remaining stream -- immediately following this prefix. splitAt :: Int -> Stream a -> ([a], Stream a) -- | drop n xs drops the first n elements -- off the front of the sequence xs. -- -- 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. 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. 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. partition :: (a -> Bool) -> Stream a -> (Stream a, Stream 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. (!!) :: Int -> Stream a -> a -- | 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. 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. 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 listToStream converts an infinite list to a stream. Passing -- a finite list will result in an error. listToStream :: [a] -> Stream a -- | The streamToList converts a stream into an infinite list. streamToList :: Stream a -> [a] instance (Show a) => Show (Stream a) instance (Eq a) => Eq (Stream a) instance Monad Stream instance Applicative Stream instance Functor Stream