ENH: I never thought that using the state monad would be so natural…