/usr/share/doc/libghc-stream-doc/html/Data-Stream.html is in libghc-stream-doc 0.4.6-4build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Data.Stream</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
window.onload = function () {pageLoad();setSynopsis("mini_Data-Stream.html");};
//]]>
</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="src/Data-Stream.html">Source</a></li><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">Stream-0.4.6: A library for manipulating infinite lists.</p></div><div id="content"><div id="module-header"><table class="info"><tr><th>Safe Haskell</th><td>None</td></tr></table><p class="caption">Data.Stream</p></div><div id="table-of-contents"><p class="caption">Contents</p><ul><li><a href="#g:1">The type of streams
</a></li><li><a href="#g:2">Basic functions
</a></li><li><a href="#g:3">Stream transformations
</a></li><li><a href="#g:4">Building streams
</a></li><li><a href="#g:5">Extracting sublists
</a></li><li><a href="#g:6">Sublist predicates
</a></li><li><a href="#g:7">Indexing streams
</a></li><li><a href="#g:8">Zipping and unzipping streams
</a></li><li><a href="#g:9">Functions on streams of characters
</a></li><li><a href="#g:10">Converting to and from an infinite list
</a></li></ul></div><div id="description"><p class="caption">Description</p><div class="doc"><p>Streams are infinite lists. Most operations on streams are
completely analogous to the definition in Data.List.
</p></div></div><div id="synopsis"><p id="control.syn" class="caption expander" onclick="toggleSection('syn')">Synopsis</p><ul id="section.syn" class="hide" onclick="toggleSection('syn')"><li class="src short"><span class="keyword">data</span> <a href="#t:Stream">Stream</a> a = <a href="#v:Cons">Cons</a> a (<a href="Data-Stream.html#t:Stream">Stream</a> a)</li><li class="src short"><a href="#v:-60-:-62-">(<:>)</a> :: a -> <a href="Data-Stream.html#t:Stream">Stream</a> a -> <a href="Data-Stream.html#t:Stream">Stream</a> a</li><li class="src short"><a href="#v:head">head</a> :: <a href="Data-Stream.html#t:Stream">Stream</a> a -> a</li><li class="src short"><a href="#v:tail">tail</a> :: <a href="Data-Stream.html#t:Stream">Stream</a> a -> <a href="Data-Stream.html#t:Stream">Stream</a> a</li><li class="src short"><a href="#v:inits">inits</a> :: <a href="Data-Stream.html#t:Stream">Stream</a> a -> <a href="Data-Stream.html#t:Stream">Stream</a> [a]</li><li class="src short"><a href="#v:tails">tails</a> :: <a href="Data-Stream.html#t:Stream">Stream</a> a -> <a href="Data-Stream.html#t:Stream">Stream</a> (<a href="Data-Stream.html#t:Stream">Stream</a> a)</li><li class="src short"><a href="#v:map">map</a> :: (a -> b) -> <a href="Data-Stream.html#t:Stream">Stream</a> a -> <a href="Data-Stream.html#t:Stream">Stream</a> b</li><li class="src short"><a href="#v:intersperse">intersperse</a> :: a -> <a href="Data-Stream.html#t:Stream">Stream</a> a -> <a href="Data-Stream.html#t:Stream">Stream</a> a</li><li class="src short"><a href="#v:interleave">interleave</a> :: <a href="Data-Stream.html#t:Stream">Stream</a> a -> <a href="Data-Stream.html#t:Stream">Stream</a> a -> <a href="Data-Stream.html#t:Stream">Stream</a> a</li><li class="src short"><a href="#v:scan">scan</a> :: (a -> b -> a) -> a -> <a href="Data-Stream.html#t:Stream">Stream</a> b -> <a href="Data-Stream.html#t:Stream">Stream</a> a</li><li class="src short"><a href="#v:scan-39-">scan'</a> :: (a -> b -> a) -> a -> <a href="Data-Stream.html#t:Stream">Stream</a> b -> <a href="Data-Stream.html#t:Stream">Stream</a> a</li><li class="src short"><a href="#v:scan1">scan1</a> :: (a -> a -> a) -> <a href="Data-Stream.html#t:Stream">Stream</a> a -> <a href="Data-Stream.html#t:Stream">Stream</a> a</li><li class="src short"><a href="#v:scan1-39-">scan1'</a> :: (a -> a -> a) -> <a href="Data-Stream.html#t:Stream">Stream</a> a -> <a href="Data-Stream.html#t:Stream">Stream</a> a</li><li class="src short"><a href="#v:transpose">transpose</a> :: <a href="Data-Stream.html#t:Stream">Stream</a> (<a href="Data-Stream.html#t:Stream">Stream</a> a) -> <a href="Data-Stream.html#t:Stream">Stream</a> (<a href="Data-Stream.html#t:Stream">Stream</a> a)</li><li class="src short"><a href="#v:iterate">iterate</a> :: (a -> a) -> a -> <a href="Data-Stream.html#t:Stream">Stream</a> a</li><li class="src short"><a href="#v:repeat">repeat</a> :: a -> <a href="Data-Stream.html#t:Stream">Stream</a> a</li><li class="src short"><a href="#v:cycle">cycle</a> :: [a] -> <a href="Data-Stream.html#t:Stream">Stream</a> a</li><li class="src short"><a href="#v:unfold">unfold</a> :: (c -> (a, c)) -> c -> <a href="Data-Stream.html#t:Stream">Stream</a> a</li><li class="src short"><a href="#v:take">take</a> :: <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Int.html#t:Int">Int</a> -> <a href="Data-Stream.html#t:Stream">Stream</a> a -> [a]</li><li class="src short"><a href="#v:drop">drop</a> :: <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Int.html#t:Int">Int</a> -> <a href="Data-Stream.html#t:Stream">Stream</a> a -> <a href="Data-Stream.html#t:Stream">Stream</a> a</li><li class="src short"><a href="#v:splitAt">splitAt</a> :: <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Int.html#t:Int">Int</a> -> <a href="Data-Stream.html#t:Stream">Stream</a> a -> ([a], <a href="Data-Stream.html#t:Stream">Stream</a> a)</li><li class="src short"><a href="#v:takeWhile">takeWhile</a> :: (a -> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Bool.html#t:Bool">Bool</a>) -> <a href="Data-Stream.html#t:Stream">Stream</a> a -> [a]</li><li class="src short"><a href="#v:dropWhile">dropWhile</a> :: (a -> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Bool.html#t:Bool">Bool</a>) -> <a href="Data-Stream.html#t:Stream">Stream</a> a -> <a href="Data-Stream.html#t:Stream">Stream</a> a</li><li class="src short"><a href="#v:span">span</a> :: (a -> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Bool.html#t:Bool">Bool</a>) -> <a href="Data-Stream.html#t:Stream">Stream</a> a -> ([a], <a href="Data-Stream.html#t:Stream">Stream</a> a)</li><li class="src short"><a href="#v:break">break</a> :: (a -> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Bool.html#t:Bool">Bool</a>) -> <a href="Data-Stream.html#t:Stream">Stream</a> a -> ([a], <a href="Data-Stream.html#t:Stream">Stream</a> a)</li><li class="src short"><a href="#v:filter">filter</a> :: (a -> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Bool.html#t:Bool">Bool</a>) -> <a href="Data-Stream.html#t:Stream">Stream</a> a -> <a href="Data-Stream.html#t:Stream">Stream</a> a</li><li class="src short"><a href="#v:partition">partition</a> :: (a -> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Bool.html#t:Bool">Bool</a>) -> <a href="Data-Stream.html#t:Stream">Stream</a> a -> (<a href="Data-Stream.html#t:Stream">Stream</a> a, <a href="Data-Stream.html#t:Stream">Stream</a> a)</li><li class="src short"><a href="#v:group">group</a> :: <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Eq.html#t:Eq">Eq</a> a => <a href="Data-Stream.html#t:Stream">Stream</a> a -> <a href="Data-Stream.html#t:Stream">Stream</a> [a]</li><li class="src short"><a href="#v:isPrefixOf">isPrefixOf</a> :: <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Eq.html#t:Eq">Eq</a> a => [a] -> <a href="Data-Stream.html#t:Stream">Stream</a> a -> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:-33--33-">(!!)</a> :: <a href="Data-Stream.html#t:Stream">Stream</a> a -> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Int.html#t:Int">Int</a> -> a</li><li class="src short"><a href="#v:elemIndex">elemIndex</a> :: <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Eq.html#t:Eq">Eq</a> a => a -> <a href="Data-Stream.html#t:Stream">Stream</a> a -> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Int.html#t:Int">Int</a></li><li class="src short"><a href="#v:elemIndices">elemIndices</a> :: <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Eq.html#t:Eq">Eq</a> a => a -> <a href="Data-Stream.html#t:Stream">Stream</a> a -> <a href="Data-Stream.html#t:Stream">Stream</a> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Int.html#t:Int">Int</a></li><li class="src short"><a href="#v:findIndex">findIndex</a> :: (a -> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Bool.html#t:Bool">Bool</a>) -> <a href="Data-Stream.html#t:Stream">Stream</a> a -> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Int.html#t:Int">Int</a></li><li class="src short"><a href="#v:findIndices">findIndices</a> :: (a -> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Bool.html#t:Bool">Bool</a>) -> <a href="Data-Stream.html#t:Stream">Stream</a> a -> <a href="Data-Stream.html#t:Stream">Stream</a> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Int.html#t:Int">Int</a></li><li class="src short"><a href="#v:zip">zip</a> :: <a href="Data-Stream.html#t:Stream">Stream</a> a -> <a href="Data-Stream.html#t:Stream">Stream</a> b -> <a href="Data-Stream.html#t:Stream">Stream</a> (a, b)</li><li class="src short"><a href="#v:zipWith">zipWith</a> :: (a -> b -> c) -> <a href="Data-Stream.html#t:Stream">Stream</a> a -> <a href="Data-Stream.html#t:Stream">Stream</a> b -> <a href="Data-Stream.html#t:Stream">Stream</a> c</li><li class="src short"><a href="#v:unzip">unzip</a> :: <a href="Data-Stream.html#t:Stream">Stream</a> (a, b) -> (<a href="Data-Stream.html#t:Stream">Stream</a> a, <a href="Data-Stream.html#t:Stream">Stream</a> b)</li><li class="src short"><a href="#v:words">words</a> :: <a href="Data-Stream.html#t:Stream">Stream</a> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Char.html#t:Char">Char</a> -> <a href="Data-Stream.html#t:Stream">Stream</a> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-String.html#t:String">String</a></li><li class="src short"><a href="#v:unwords">unwords</a> :: <a href="Data-Stream.html#t:Stream">Stream</a> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-String.html#t:String">String</a> -> <a href="Data-Stream.html#t:Stream">Stream</a> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Char.html#t:Char">Char</a></li><li class="src short"><a href="#v:lines">lines</a> :: <a href="Data-Stream.html#t:Stream">Stream</a> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Char.html#t:Char">Char</a> -> <a href="Data-Stream.html#t:Stream">Stream</a> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-String.html#t:String">String</a></li><li class="src short"><a href="#v:unlines">unlines</a> :: <a href="Data-Stream.html#t:Stream">Stream</a> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-String.html#t:String">String</a> -> <a href="Data-Stream.html#t:Stream">Stream</a> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Char.html#t:Char">Char</a></li><li class="src short"><a href="#v:toList">toList</a> :: <a href="Data-Stream.html#t:Stream">Stream</a> a -> [a]</li><li class="src short"><a href="#v:fromList">fromList</a> :: [a] -> <a href="Data-Stream.html#t:Stream">Stream</a> a</li></ul></div><div id="interface"><h1 id="g:1">The type of streams
</h1><div class="top"><p class="src"><span class="keyword">data</span> <a name="t:Stream" class="def">Stream</a> a <a href="src/Data-Stream.html#Stream" class="link">Source</a></p><div class="doc"><p>An infinite sequence.
</p><p><em>Beware</em>: If you use any function from the <code> Eq </code> or <code> Ord </code>
class to compare two equal streams, these functions will diverge.
</p></div><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a name="v:Cons" class="def">Cons</a> a (<a href="Data-Stream.html#t:Stream">Stream</a> a)</td><td class="doc empty"> </td></tr></table></div><div class="subs instances"><p id="control.i:Stream" class="caption collapser" onclick="toggleSection('i:Stream')">Instances</p><div id="section.i:Stream" class="show"><table><tr><td class="src"><a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Control-Monad.html#t:Monad">Monad</a> <a href="Data-Stream.html#t:Stream">Stream</a></td><td class="doc empty"> </td></tr><tr><td class="src"><a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Control-Monad.html#t:Functor">Functor</a> <a href="Data-Stream.html#t:Stream">Stream</a></td><td class="doc empty"> </td></tr><tr><td class="src"><a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Control-Applicative.html#t:Applicative">Applicative</a> <a href="Data-Stream.html#t:Stream">Stream</a></td><td class="doc empty"> </td></tr><tr><td class="src"><a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Eq.html#t:Eq">Eq</a> a => <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Eq.html#t:Eq">Eq</a> (<a href="Data-Stream.html#t:Stream">Stream</a> a)</td><td class="doc empty"> </td></tr><tr><td class="src"><a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Ord.html#t:Ord">Ord</a> a => <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Ord.html#t:Ord">Ord</a> (<a href="Data-Stream.html#t:Stream">Stream</a> a)</td><td class="doc empty"> </td></tr><tr><td class="src"><a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Text-Show.html#t:Show">Show</a> a => <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Text-Show.html#t:Show">Show</a> (<a href="Data-Stream.html#t:Stream">Stream</a> a)</td><td class="doc"><p>A Show instance for Streams that takes the right associativity into
account and so doesn't put parenthesis around the tail of the Stream.
Note that <code><a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Text-Show.html#v:show">show</a></code> returns an infinite <code><a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-String.html#t:String">String</a></code>.
</p></td></tr><tr><td class="src"><a href="/usr/share/doc/libghc-quickcheck2-doc/html/Test-QuickCheck-Arbitrary.html#t:Arbitrary">Arbitrary</a> a => <a href="/usr/share/doc/libghc-quickcheck2-doc/html/Test-QuickCheck-Arbitrary.html#t:Arbitrary">Arbitrary</a> (<a href="Data-Stream.html#t:Stream">Stream</a> a)</td><td class="doc empty"> </td></tr><tr><td class="src"><a href="/usr/share/doc/libghc-quickcheck2-doc/html/Test-QuickCheck-Arbitrary.html#t:CoArbitrary">CoArbitrary</a> a => <a href="/usr/share/doc/libghc-quickcheck2-doc/html/Test-QuickCheck-Arbitrary.html#t:CoArbitrary">CoArbitrary</a> (<a href="Data-Stream.html#t:Stream">Stream</a> a)</td><td class="doc empty"> </td></tr><tr><td class="src">Serial a => Serial (<a href="Data-Stream.html#t:Stream">Stream</a> a)</td><td class="doc empty"> </td></tr></table></div></div></div><h1 id="g:2">Basic functions
</h1><div class="top"><p class="src"><a name="v:-60-:-62-" class="def">(<:>)</a> :: a -> <a href="Data-Stream.html#t:Stream">Stream</a> a -> <a href="Data-Stream.html#t:Stream">Stream</a> a<a href="src/Data-Stream.html#%3C%3A%3E" class="link">Source</a></p><div class="doc"><p>The <code> <:> </code> operator is an infix version of the <code><a href="Data-Stream.html#v:Cons">Cons</a></code>
constructor.
</p></div></div><div class="top"><p class="src"><a name="v:head" class="def">head</a> :: <a href="Data-Stream.html#t:Stream">Stream</a> a -> a<a href="src/Data-Stream.html#head" class="link">Source</a></p><div class="doc"><p>Extract the first element of the sequence.
</p></div></div><div class="top"><p class="src"><a name="v:tail" class="def">tail</a> :: <a href="Data-Stream.html#t:Stream">Stream</a> a -> <a href="Data-Stream.html#t:Stream">Stream</a> a<a href="src/Data-Stream.html#tail" class="link">Source</a></p><div class="doc"><p>Extract the sequence following the head of the stream.
</p></div></div><div class="top"><p class="src"><a name="v:inits" class="def">inits</a> :: <a href="Data-Stream.html#t:Stream">Stream</a> a -> <a href="Data-Stream.html#t:Stream">Stream</a> [a]<a href="src/Data-Stream.html#inits" class="link">Source</a></p><div class="doc"><p>The <code><a href="Data-Stream.html#v:inits">inits</a></code> function takes a stream <code>xs</code> and returns all the
finite prefixes of <code>xs</code>.
</p><p>Note that this <code><a href="Data-Stream.html#v:inits">inits</a></code> is lazier then <code>Data.List.inits</code>:
</p><pre> inits _|_ = [] ::: _|_
</pre><p>while for <code>Data.List.inits</code>:
</p><pre> inits _|_ = _|_
</pre></div></div><div class="top"><p class="src"><a name="v:tails" class="def">tails</a> :: <a href="Data-Stream.html#t:Stream">Stream</a> a -> <a href="Data-Stream.html#t:Stream">Stream</a> (<a href="Data-Stream.html#t:Stream">Stream</a> a)<a href="src/Data-Stream.html#tails" class="link">Source</a></p><div class="doc"><p>The <code><a href="Data-Stream.html#v:tails">tails</a></code> function takes a stream <code>xs</code> and returns all the
suffixes of <code>xs</code>.
</p></div></div><h1 id="g:3">Stream transformations
</h1><div class="top"><p class="src"><a name="v:map" class="def">map</a> :: (a -> b) -> <a href="Data-Stream.html#t:Stream">Stream</a> a -> <a href="Data-Stream.html#t:Stream">Stream</a> b<a href="src/Data-Stream.html#map" class="link">Source</a></p><div class="doc"><p>Apply a function uniformly over all elements of a sequence.
</p></div></div><div class="top"><p class="src"><a name="v:intersperse" class="def">intersperse</a> :: a -> <a href="Data-Stream.html#t:Stream">Stream</a> a -> <a href="Data-Stream.html#t:Stream">Stream</a> a<a href="src/Data-Stream.html#intersperse" class="link">Source</a></p><div class="doc"><p><code><a href="Data-Stream.html#v:intersperse">intersperse</a></code> <code>y</code> <code>xs</code> creates an alternating stream of
elements from <code>xs</code> and <code>y</code>.
</p></div></div><div class="top"><p class="src"><a name="v:interleave" class="def">interleave</a> :: <a href="Data-Stream.html#t:Stream">Stream</a> a -> <a href="Data-Stream.html#t:Stream">Stream</a> a -> <a href="Data-Stream.html#t:Stream">Stream</a> a<a href="src/Data-Stream.html#interleave" class="link">Source</a></p><div class="doc"><p>Interleave two Streams <code>xs</code> and <code>ys</code>, alternating elements
from each list.
</p><pre> [x1,x2,...] `interleave` [y1,y2,...] == [x1,y1,x2,y2,...]
</pre></div></div><div class="top"><p class="src"><a name="v:scan" class="def">scan</a> :: (a -> b -> a) -> a -> <a href="Data-Stream.html#t:Stream">Stream</a> b -> <a href="Data-Stream.html#t:Stream">Stream</a> a<a href="src/Data-Stream.html#scan" class="link">Source</a></p><div class="doc"><p><code><a href="Data-Stream.html#v:scan">scan</a></code> yields a stream of successive reduced values from:
</p><pre> scan f z [x1, x2, ...] == [z, z `f` x1, (z `f` x1) `f` x2, ...]
</pre></div></div><div class="top"><p class="src"><a name="v:scan-39-" class="def">scan'</a> :: (a -> b -> a) -> a -> <a href="Data-Stream.html#t:Stream">Stream</a> b -> <a href="Data-Stream.html#t:Stream">Stream</a> a<a href="src/Data-Stream.html#scan%27" class="link">Source</a></p><div class="doc"><p><code>scan'</code> is a strict scan.
</p></div></div><div class="top"><p class="src"><a name="v:scan1" class="def">scan1</a> :: (a -> a -> a) -> <a href="Data-Stream.html#t:Stream">Stream</a> a -> <a href="Data-Stream.html#t:Stream">Stream</a> a<a href="src/Data-Stream.html#scan1" class="link">Source</a></p><div class="doc"><p><code><a href="Data-Stream.html#v:scan1">scan1</a></code> is a variant of <code><a href="Data-Stream.html#v:scan">scan</a></code> that has no starting value argument:
</p><pre> scan1 f [x1, x2, ...] == [x1, x1 `f` x2, ...]
</pre></div></div><div class="top"><p class="src"><a name="v:scan1-39-" class="def">scan1'</a> :: (a -> a -> a) -> <a href="Data-Stream.html#t:Stream">Stream</a> a -> <a href="Data-Stream.html#t:Stream">Stream</a> a<a href="src/Data-Stream.html#scan1%27" class="link">Source</a></p><div class="doc"><p><code>scan1'</code> is a strict scan that has no starting value.
</p></div></div><div class="top"><p class="src"><a name="v:transpose" class="def">transpose</a> :: <a href="Data-Stream.html#t:Stream">Stream</a> (<a href="Data-Stream.html#t:Stream">Stream</a> a) -> <a href="Data-Stream.html#t:Stream">Stream</a> (<a href="Data-Stream.html#t:Stream">Stream</a> a)<a href="src/Data-Stream.html#transpose" class="link">Source</a></p><div class="doc"><p><code><a href="Data-Stream.html#v:transpose">transpose</a></code> computes the transposition of a stream of streams.
</p></div></div><h1 id="g:4">Building streams
</h1><div class="top"><p class="src"><a name="v:iterate" class="def">iterate</a> :: (a -> a) -> a -> <a href="Data-Stream.html#t:Stream">Stream</a> a<a href="src/Data-Stream.html#iterate" class="link">Source</a></p><div class="doc"><p><code><a href="Data-Stream.html#v:iterate">iterate</a></code> <code>f</code> <code>x</code> function produces the infinite sequence
of repeated applications of <code>f</code> to <code>x</code>.
</p><pre> iterate f x = [x, f x, f (f x), ..]
</pre></div></div><div class="top"><p class="src"><a name="v:repeat" class="def">repeat</a> :: a -> <a href="Data-Stream.html#t:Stream">Stream</a> a<a href="src/Data-Stream.html#repeat" class="link">Source</a></p><div class="doc"><p><code><a href="Data-Stream.html#v:repeat">repeat</a></code> <code>x</code> returns a constant stream, where all elements are
equal to <code>x</code>.
</p></div></div><div class="top"><p class="src"><a name="v:cycle" class="def">cycle</a> :: [a] -> <a href="Data-Stream.html#t:Stream">Stream</a> a<a href="src/Data-Stream.html#cycle" class="link">Source</a></p><div class="doc"><p><code><a href="Data-Stream.html#v:cycle">cycle</a></code> <code>xs</code> returns the infinite repetition of <code>xs</code>:
</p><pre> cycle [1,2,3] = Cons 1 (Cons 2 (Cons 3 (Cons 1 (Cons 2 ...
</pre></div></div><div class="top"><p class="src"><a name="v:unfold" class="def">unfold</a> :: (c -> (a, c)) -> c -> <a href="Data-Stream.html#t:Stream">Stream</a> a<a href="src/Data-Stream.html#unfold" class="link">Source</a></p><div class="doc"><p>The unfold function is similar to the unfold for lists. Note
there is no base case: all streams must be infinite.
</p></div></div><h1 id="g:5">Extracting sublists
</h1><div class="top"><p class="src"><a name="v:take" class="def">take</a> :: <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Int.html#t:Int">Int</a> -> <a href="Data-Stream.html#t:Stream">Stream</a> a -> [a]<a href="src/Data-Stream.html#take" class="link">Source</a></p><div class="doc"><p><code><a href="Data-Stream.html#v:take">take</a></code> <code>n</code> <code>xs</code> returns the first <code>n</code> elements of <code>xs</code>.
</p><p><em>Beware</em>: passing a negative integer as the first argument will
cause an error.
</p></div></div><div class="top"><p class="src"><a name="v:drop" class="def">drop</a> :: <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Int.html#t:Int">Int</a> -> <a href="Data-Stream.html#t:Stream">Stream</a> a -> <a href="Data-Stream.html#t:Stream">Stream</a> a<a href="src/Data-Stream.html#drop" class="link">Source</a></p><div class="doc"><p><code><a href="Data-Stream.html#v:drop">drop</a></code> <code>n</code> <code>xs</code> drops the first <code>n</code> elements off the front of
the sequence <code>xs</code>.
</p><p><em>Beware</em>: passing a negative integer as the first argument will
cause an error.
</p></div></div><div class="top"><p class="src"><a name="v:splitAt" class="def">splitAt</a> :: <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Int.html#t:Int">Int</a> -> <a href="Data-Stream.html#t:Stream">Stream</a> a -> ([a], <a href="Data-Stream.html#t:Stream">Stream</a> a)<a href="src/Data-Stream.html#splitAt" class="link">Source</a></p><div class="doc"><p>The <code><a href="Data-Stream.html#v:splitAt">splitAt</a></code> function takes an integer <code>n</code> and a stream <code>xs</code>
and returns a pair consisting of the prefix of <code>xs</code> of length
<code>n</code> and the remaining stream immediately following this prefix.
</p><p><em>Beware</em>: passing a negative integer as the first argument will
cause an error.
</p></div></div><div class="top"><p class="src"><a name="v:takeWhile" class="def">takeWhile</a> :: (a -> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Bool.html#t:Bool">Bool</a>) -> <a href="Data-Stream.html#t:Stream">Stream</a> a -> [a]<a href="src/Data-Stream.html#takeWhile" class="link">Source</a></p><div class="doc"><p><code><a href="Data-Stream.html#v:takeWhile">takeWhile</a></code> <code>p</code> <code>xs</code> returns the longest prefix of the stream
<code>xs</code> for which the predicate <code>p</code> holds.
</p></div></div><div class="top"><p class="src"><a name="v:dropWhile" class="def">dropWhile</a> :: (a -> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Bool.html#t:Bool">Bool</a>) -> <a href="Data-Stream.html#t:Stream">Stream</a> a -> <a href="Data-Stream.html#t:Stream">Stream</a> a<a href="src/Data-Stream.html#dropWhile" class="link">Source</a></p><div class="doc"><p><code><a href="Data-Stream.html#v:dropWhile">dropWhile</a></code> <code>p</code> <code>xs</code> returns the suffix remaining after
<code><a href="Data-Stream.html#v:takeWhile">takeWhile</a></code> <code>p</code> <code>xs</code>.
</p><p><em>Beware</em>: this function may diverge if every element of <code>xs</code>
satisfies <code>p</code>, e.g. <code>dropWhile even (repeat 0)</code> will loop.
</p></div></div><div class="top"><p class="src"><a name="v:span" class="def">span</a> :: (a -> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Bool.html#t:Bool">Bool</a>) -> <a href="Data-Stream.html#t:Stream">Stream</a> a -> ([a], <a href="Data-Stream.html#t:Stream">Stream</a> a)<a href="src/Data-Stream.html#span" class="link">Source</a></p><div class="doc"><p><code><a href="Data-Stream.html#v:span">span</a></code> <code>p</code> <code>xs</code> returns the longest prefix of <code>xs</code> that satisfies
<code>p</code>, together with the remainder of the stream.
</p></div></div><div class="top"><p class="src"><a name="v:break" class="def">break</a> :: (a -> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Bool.html#t:Bool">Bool</a>) -> <a href="Data-Stream.html#t:Stream">Stream</a> a -> ([a], <a href="Data-Stream.html#t:Stream">Stream</a> a)<a href="src/Data-Stream.html#break" class="link">Source</a></p><div class="doc"><p>The <code><a href="Data-Stream.html#v:break">break</a></code> <code>p</code> function is equivalent to <code><a href="Data-Stream.html#v:span">span</a></code> <code>not . p</code>.
</p></div></div><div class="top"><p class="src"><a name="v:filter" class="def">filter</a> :: (a -> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Bool.html#t:Bool">Bool</a>) -> <a href="Data-Stream.html#t:Stream">Stream</a> a -> <a href="Data-Stream.html#t:Stream">Stream</a> a<a href="src/Data-Stream.html#filter" class="link">Source</a></p><div class="doc"><p><code><a href="Data-Stream.html#v:filter">filter</a></code> <code>p</code> <code>xs</code>, removes any elements from <code>xs</code> that do not satisfy <code>p</code>.
</p><p><em>Beware</em>: this function may diverge if there is no element of
<code>xs</code> that satisfies <code>p</code>, e.g. <code>filter odd (repeat 0)</code> will loop.
</p></div></div><div class="top"><p class="src"><a name="v:partition" class="def">partition</a> :: (a -> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Bool.html#t:Bool">Bool</a>) -> <a href="Data-Stream.html#t:Stream">Stream</a> a -> (<a href="Data-Stream.html#t:Stream">Stream</a> a, <a href="Data-Stream.html#t:Stream">Stream</a> a)<a href="src/Data-Stream.html#partition" class="link">Source</a></p><div class="doc"><p>The <code><a href="Data-Stream.html#v:partition">partition</a></code> function takes a predicate <code>p</code> and a stream
<code>xs</code>, and returns a pair of streams. The first stream corresponds
to the elements of <code>xs</code> for which <code>p</code> holds; the second stream
corresponds to the elements of <code>xs</code> for which <code>p</code> does not hold.
</p><p><em>Beware</em>: One of the elements of the tuple may be undefined. For
example, <code>fst (partition even (repeat 0)) == repeat 0</code>; on the
other hand <code>snd (partition even (repeat 0))</code> is undefined.
</p></div></div><div class="top"><p class="src"><a name="v:group" class="def">group</a> :: <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Eq.html#t:Eq">Eq</a> a => <a href="Data-Stream.html#t:Stream">Stream</a> a -> <a href="Data-Stream.html#t:Stream">Stream</a> [a]<a href="src/Data-Stream.html#group" class="link">Source</a></p><div class="doc"><p>The <code><a href="Data-Stream.html#v:group">group</a></code> 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,
</p><pre> group $ cycle "Mississippi" = "M" ::: "i" ::: "ss" ::: "i" ::: "ss" ::: "i" ::: "pp" ::: "i" ::: "M" ::: "i" ::: ...
</pre></div></div><h1 id="g:6">Sublist predicates
</h1><div class="top"><p class="src"><a name="v:isPrefixOf" class="def">isPrefixOf</a> :: <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Eq.html#t:Eq">Eq</a> a => [a] -> <a href="Data-Stream.html#t:Stream">Stream</a> a -> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Bool.html#t:Bool">Bool</a><a href="src/Data-Stream.html#isPrefixOf" class="link">Source</a></p><div class="doc"><p>The <code>isPrefix</code> function returns <code>True</code> if the first argument is
a prefix of the second.
</p></div></div><h1 id="g:7">Indexing streams
</h1><div class="top"><p class="src"><a name="v:-33--33-" class="def">(!!)</a> :: <a href="Data-Stream.html#t:Stream">Stream</a> a -> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Int.html#t:Int">Int</a> -> a<a href="src/Data-Stream.html#%21%21" class="link">Source</a></p><div class="doc"><p><code>xs !! n</code> returns the element of the stream <code>xs</code> at index
<code>n</code>. Note that the head of the stream has index 0.
</p><p><em>Beware</em>: passing a negative integer as the first argument will cause
an error.
</p></div></div><div class="top"><p class="src"><a name="v:elemIndex" class="def">elemIndex</a> :: <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Eq.html#t:Eq">Eq</a> a => a -> <a href="Data-Stream.html#t:Stream">Stream</a> a -> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Int.html#t:Int">Int</a><a href="src/Data-Stream.html#elemIndex" class="link">Source</a></p><div class="doc"><p>The <code><a href="Data-Stream.html#v:elemIndex">elemIndex</a></code> function returns the index of the first element
in the given stream which is equal (by <code><a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Eq.html#v:-61--61-">==</a></code>) to the query element,
</p><p><em>Beware</em>: <code><a href="Data-Stream.html#v:elemIndex">elemIndex</a></code> <code>x</code> <code>xs</code> will diverge if none of the elements
of <code>xs</code> equal <code>x</code>.
</p></div></div><div class="top"><p class="src"><a name="v:elemIndices" class="def">elemIndices</a> :: <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Eq.html#t:Eq">Eq</a> a => a -> <a href="Data-Stream.html#t:Stream">Stream</a> a -> <a href="Data-Stream.html#t:Stream">Stream</a> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Int.html#t:Int">Int</a><a href="src/Data-Stream.html#elemIndices" class="link">Source</a></p><div class="doc"><p>The <code><a href="Data-Stream.html#v:elemIndices">elemIndices</a></code> function extends <code><a href="Data-Stream.html#v:elemIndex">elemIndex</a></code>, by returning the
indices of all elements equal to the query element, in ascending order.
</p><p><em>Beware</em>: <code><a href="Data-Stream.html#v:elemIndices">elemIndices</a></code> <code>x</code> <code>xs</code> will diverge if any suffix of
<code>xs</code> does not contain <code>x</code>.
</p></div></div><div class="top"><p class="src"><a name="v:findIndex" class="def">findIndex</a> :: (a -> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Bool.html#t:Bool">Bool</a>) -> <a href="Data-Stream.html#t:Stream">Stream</a> a -> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Int.html#t:Int">Int</a><a href="src/Data-Stream.html#findIndex" class="link">Source</a></p><div class="doc"><p>The <code><a href="Data-Stream.html#v:findIndex">findIndex</a></code> function takes a predicate and a stream and returns
the index of the first element in the stream that satisfies the predicate,
</p><p><em>Beware</em>: <code><a href="Data-Stream.html#v:findIndex">findIndex</a></code> <code>p</code> <code>xs</code> will diverge if none of the elements of
<code>xs</code> satisfy <code>p</code>.
</p></div></div><div class="top"><p class="src"><a name="v:findIndices" class="def">findIndices</a> :: (a -> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Bool.html#t:Bool">Bool</a>) -> <a href="Data-Stream.html#t:Stream">Stream</a> a -> <a href="Data-Stream.html#t:Stream">Stream</a> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Int.html#t:Int">Int</a><a href="src/Data-Stream.html#findIndices" class="link">Source</a></p><div class="doc"><p>The <code><a href="Data-Stream.html#v:findIndices">findIndices</a></code> function extends <code><a href="Data-Stream.html#v:findIndex">findIndex</a></code>, by returning the
indices of all elements satisfying the predicate, in ascending
order.
</p><p><em>Beware</em>: <code><a href="Data-Stream.html#v:findIndices">findIndices</a></code> <code>p</code> <code>xs</code> will diverge if all the elements
of any suffix of <code>xs</code> fails to satisfy <code>p</code>.
</p></div></div><h1 id="g:8">Zipping and unzipping streams
</h1><div class="top"><p class="src"><a name="v:zip" class="def">zip</a> :: <a href="Data-Stream.html#t:Stream">Stream</a> a -> <a href="Data-Stream.html#t:Stream">Stream</a> b -> <a href="Data-Stream.html#t:Stream">Stream</a> (a, b)<a href="src/Data-Stream.html#zip" class="link">Source</a></p><div class="doc"><p>The <code><a href="Data-Stream.html#v:zip">zip</a></code> function takes two streams and returns a list of
corresponding pairs.
</p></div></div><div class="top"><p class="src"><a name="v:zipWith" class="def">zipWith</a> :: (a -> b -> c) -> <a href="Data-Stream.html#t:Stream">Stream</a> a -> <a href="Data-Stream.html#t:Stream">Stream</a> b -> <a href="Data-Stream.html#t:Stream">Stream</a> c<a href="src/Data-Stream.html#zipWith" class="link">Source</a></p><div class="doc"><p>The <code><a href="Data-Stream.html#v:zipWith">zipWith</a></code> function generalizes <code><a href="Data-Stream.html#v:zip">zip</a></code>. Rather than tupling
the functions, the elements are combined using the function
passed as the first argument to <code><a href="Data-Stream.html#v:zipWith">zipWith</a></code>.
</p></div></div><div class="top"><p class="src"><a name="v:unzip" class="def">unzip</a> :: <a href="Data-Stream.html#t:Stream">Stream</a> (a, b) -> (<a href="Data-Stream.html#t:Stream">Stream</a> a, <a href="Data-Stream.html#t:Stream">Stream</a> b)<a href="src/Data-Stream.html#unzip" class="link">Source</a></p><div class="doc"><p>The <code><a href="Data-Stream.html#v:unzip">unzip</a></code> function is the inverse of the <code><a href="Data-Stream.html#v:zip">zip</a></code> function.
</p></div></div><h1 id="g:9">Functions on streams of characters
</h1><div class="top"><p class="src"><a name="v:words" class="def">words</a> :: <a href="Data-Stream.html#t:Stream">Stream</a> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Char.html#t:Char">Char</a> -> <a href="Data-Stream.html#t:Stream">Stream</a> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-String.html#t:String">String</a><a href="src/Data-Stream.html#words" class="link">Source</a></p><div class="doc"><p>The <code><a href="Data-Stream.html#v:words">words</a></code> function breaks a stream of characters into a
stream of words, which were delimited by white space.
</p><p><em>Beware</em>: if the stream of characters <code>xs</code> does not contain white
space, accessing the tail of <code>words xs</code> will loop.
</p></div></div><div class="top"><p class="src"><a name="v:unwords" class="def">unwords</a> :: <a href="Data-Stream.html#t:Stream">Stream</a> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-String.html#t:String">String</a> -> <a href="Data-Stream.html#t:Stream">Stream</a> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Char.html#t:Char">Char</a><a href="src/Data-Stream.html#unwords" class="link">Source</a></p><div class="doc"><p>The <code><a href="Data-Stream.html#v:unwords">unwords</a></code> function is an inverse operation to <code><a href="Data-Stream.html#v:words">words</a></code>. It
joins words with separating spaces.
</p></div></div><div class="top"><p class="src"><a name="v:lines" class="def">lines</a> :: <a href="Data-Stream.html#t:Stream">Stream</a> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Char.html#t:Char">Char</a> -> <a href="Data-Stream.html#t:Stream">Stream</a> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-String.html#t:String">String</a><a href="src/Data-Stream.html#lines" class="link">Source</a></p><div class="doc"><p>The <code><a href="Data-Stream.html#v:lines">lines</a></code> function breaks a stream of characters into a list
of strings at newline characters. The resulting strings do not
contain newlines.
</p><p><em>Beware</em>: if the stream of characters <code>xs</code> does not contain
newline characters, accessing the tail of <code>lines xs</code> will loop.
</p></div></div><div class="top"><p class="src"><a name="v:unlines" class="def">unlines</a> :: <a href="Data-Stream.html#t:Stream">Stream</a> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-String.html#t:String">String</a> -> <a href="Data-Stream.html#t:Stream">Stream</a> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Char.html#t:Char">Char</a><a href="src/Data-Stream.html#unlines" class="link">Source</a></p><div class="doc"><p>The <code><a href="Data-Stream.html#v:unlines">unlines</a></code> function is an inverse operation to <code><a href="Data-Stream.html#v:lines">lines</a></code>. It
joins lines, after appending a terminating newline to each.
</p></div></div><h1 id="g:10">Converting to and from an infinite list
</h1><div class="top"><p class="src"><a name="v:toList" class="def">toList</a> :: <a href="Data-Stream.html#t:Stream">Stream</a> a -> [a]<a href="src/Data-Stream.html#toList" class="link">Source</a></p><div class="doc"><p>The <code><a href="Data-Stream.html#v:toList">toList</a></code> converts a stream into an infinite list.
</p></div></div><div class="top"><p class="src"><a name="v:fromList" class="def">fromList</a> :: [a] -> <a href="Data-Stream.html#t:Stream">Stream</a> a<a href="src/Data-Stream.html#fromList" class="link">Source</a></p><div class="doc"><p>The <code><a href="Data-Stream.html#v:fromList">fromList</a></code> converts an infinite list to a
stream.
</p><p><em>Beware</em>: Passing a finite list, will cause an error.
</p></div></div></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.13.2</p></div></body></html>
|