Generalize withBindings to withState