Generalize and improve std.typecons.scoped