Elaborating intersection and union types