WIP: BaseRecurrent and recurrent_apply_method

The scan related code is a typical boilerplate code
of which we had so much in Groundhog. This commit
introduces a way to get rid of it: a decorator that adds iteration
code to a single-step transition function.
For carrying over the hidden state I guess it's easiest if we make the initial state a shared variable which can be passed to the `updates` argument of `function`. Would we do this by passing a particular state initialization function then?