WIP: begin refactor, split Infer.hs in half