Implement basic type inference