Factor out constraintToDecls

(if you like that better. Might repeat work in various places, though.)