Got type inference almost entirely working