Many things become much simpler once you switch from procedural to declarative programming. The downside is that in many cases you'll need to write an interpreter for the declarations and very often it's more complex than it appears. Of course, if there's a known design of the interpreter (state machine, etc.) things become much simpler.