parameterized over input type and factored out representation parameters