@@ -29,13 +29,14 @@ module Streamly.Streams
2929 , newEmptySVar
3030
3131 -- * Construction
32+ , nil
33+ , cons
34+ , (.:)
3235 , streamBuild
3336 , fromCallback
3437 , fromSVar
3538
3639 -- * Elimination
37− , cons
38− , nil
3940 , streamFold
4041 , runStreaming
4142 , toSVar
@@ -111,13 +112,38 @@ class Streaming t where
111112-- Constructing a stream
112113------------------------------------------------------------------------------
113114
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
118+
119+infixr 5 `cons`
120+
121+-- | Constructs a stream by adding a pure value at the head of an existing
122+-- stream, just like ':' constructs lists. For example:
123+--
124+-- @
125+-- > let stream = 1 \`cons` 2 \`cons` 3 \`cons` nil
126+-- > (toList . serially) stream
127+-- [1,2,3]
128+-- @
115129cons :: (Streaming t) => a -> t m a -> t m a
116130cons a r = fromStream $ scons a (Just (toStream r))
117131
118−-- | An empty stream.
119−nil :: Streaming t => t m a
120−nil = fromStream snil
132+infixr 5 .:
133+
134+-- | Operator equivalent of 'cons' so that you can construct a stream of pure
135+-- values more succinctly like this:
136+--
137+-- @
138+-- > let stream = 1 .: 2 .: 3 .: nil
139+-- > (toList . serially) stream
140+-- [1,2,3]
141+-- @
142+--
143+-- '.:' constructs a stream just like ':' constructs a list.
144+--
145+(.:) :: (Streaming t) => a -> t m a -> t m a
146+(.:) = cons
121147
122148-- | Build a stream from its church encoding. The function passed maps
123149-- directly to the underlying representation of the stream type. The second