Flow analysis of typed higher-order programs