Haskell Language Tuples (Pairs, Triples, ...) Strictness of matching a tuple


Example

The pattern (p1, p2) is strict in the outermost tuple constructor, which can lead to unexpected strictness behaviour. For example, the following expression diverges (using Data.Function.fix):

fix $ \(x, y) -> (1, 2)

since the match on (x, y) is strict in the tuple constructor. However, the following expression, using an irrefutable pattern, evaluates to (1, 2) as expected:

fix $ \ ~(x, y) -> (1, 2)