State Monad and supporting macros