Rank-2 polymorphism and pattern matching