infer generic type parameters upon construction (closes #2044)