Stateful apply

* add stateful apply
* add its implementation to fakedb
* simple test that generates an index
* fix names in generated json

I also added a state literal. Does this need to be added a to-json converter?