Add parametric types

Definitely. Hence the comment `// TODO: make this not hacky` :)

I didn't want to put a lot of time into this until @martint decided how it should work