A composable pattern for pure state machiness with effects, meant to be idiomatic in a typical imperative context.