The problem of obtaining canonical Hamiltonian structures from the equations of motion, without any knowledge of the action, is studied in the context of the spatially flat Friedmann, ‘Robertson’, and Walker models. Modifications to the Raychaudhuri equation are implemented independently as quadratic and cubic terms of energy density without introducing additional degrees of freedom. Depending on their sign, modifications make gravity repulsive above a curvature scale for matter satisfying strong energy conditions, or more attractive than in the classical theory. The canonical structure of the modified theories is determined by demanding that the total Hamiltonian be a linear combination of gravity and matter Hamiltonians. In the quadratic repulsive case, the modified canonical phase space of gravity is a polymerized phase space with canonical momentum as inverse a trigonometric function of the Hubble rate; the canonical Hamiltonian can be identified with the effective Hamiltonian in loop quantum cosmology. The repulsive cubic modification results in a ‘generalized polymerized’ canonical phase space. Both the repulsive modifications are found to yield singularity avoidance. In contrast, the quadratic and cubic attractive modifications result in a canonical phase space in which canonical momentum is nontrigonometric and singularities persist. Our results hint at connections between the repulsive/attractive nature of modifications to gravity arising from the gravitational sector and polymerized/non polymerized gravitational phase space.