@@ -153,6 +153,58 @@ Specifically,
153153* Please use 4 spaces for indentation.
154154* Do not let the code go beyond 80 columns
155155
156+Indent the `where` clause as follows:
157+
158+```
159+f x = ...
160+ where
161+
162+ f1 = ...
163+```
164+
165+In general, we avoid using a prime on the variable names, e.g. we use `step1`
166+instead of `step'`. Numbered indexing is better because it is easier on the
167+eyes and we can represent multiple generations of the variables without adding
168+more characters e.g. we can write `step2` instead of `step''`.
169+
170+Use shorter variable names for shorter scopes, use longer variable names for
171+bigger scopes.
172+
173+Imports:
174+
175+* Import symbols explicitly by names as long as possible
176+* Import qualified is there are too many symbols to be imported
177+
178+### StreamD coding style
179+
180+Some conventions that we follow in the StreamD code are illustrated by the
181+following example:
182+
183+```
184+mapM f (Stream step1 state1) = Stream step state
185+ where
186+
187+ step gst st = do
188+ r <- step1 (adaptState gst) st
189+ case r of
190+ Yield x s -> f x >>= \a -> return $ Yield a s
191+ Skip s -> return $ Skip s
192+ Stop -> return Stop
193+```
194+
195+* For the input streams use numbering for `step` and `state` e.g.
196+ step1/state1. For the ouput stream use `step` and `state`.
197+* For state argument of `step`, use `st`.
198+* For result of executing a `step` use `r` or `res`
199+* For the yielded element use `x`
200+* For the yielded state use `s`
201+
202+In general, the rule is - the shorter the scope of a variable the shorter its
203+name can be. For example, `s` has the shortest scope in the above code, `st`
204+has a bigger scope and `state` has the biggest scope.
205+
206+For better fusion we try to keep a single yield point in the state machine.
207+
156208### Organization
157209
158210Use this simple rule to organize functions in a file: `Define before first