@@ -29,13 +29,14 @@ module Streamly.Streams
29 , newEmptySVar
29 , newEmptySVar
31 -- * Construction
31 -- * Construction
32 , streamBuild
35 , streamBuild
33 , fromCallback
36 , fromCallback
34 , fromSVar
37 , fromSVar
36 -- * Elimination
39 -- * Elimination
39 , streamFold
40 , streamFold
40 , runStreaming
41 , runStreaming
@@ -111,13 +112,38 @@ class Streaming t where
111-- Constructing a stream
112-- Constructing a stream
112------------------------------------------------------------------------------
113------------------------------------------------------------------------------
114−-- | Add an element a the head of a stream.
115+-- | Represesnts an empty stream just like @[]@ represents and empty list.
116+nil :: Streaming t => t m a
117+nil = fromStream snil
121+-- | Constructs a stream by adding a pure value at the head of an existing
122+-- stream, just like ':' constructs lists. For example:
125+-- > let stream = 1 \`cons` 2 \`cons` 3 \`cons` nil
126+-- > (toList . serially) stream
115cons :: (Streaming t) => a -> t m a -> t m a
129cons :: (Streaming t) => a -> t m a -> t m a
116cons a r = fromStream $ scons a (Just (toStream r))
130cons a r = fromStream $ scons a (Just (toStream r))
118−-- | An empty stream.
132+infixr 5 .:
134+-- | Operator equivalent of 'cons' so that you can construct a stream of pure
135+-- values more succinctly like this:
138+-- > let stream = 1 .: 2 .: 3 .: nil
139+-- > (toList . serially) stream
143+-- '.:' constructs a stream just like ':' constructs a list.
119−nil :: Streaming t => t m a
145+(.:) :: (Streaming t) => a -> t m a -> t m a
120−nil = fromStream snil
146+(.:) = cons
122-- | Build a stream from its church encoding. The function passed maps
148-- | Build a stream from its church encoding. The function passed maps
123-- directly to the underlying representation of the stream type. The second
149-- directly to the underlying representation of the stream type. The second