[Haskell-cafe] conflicting variable definitions in pattern

Conor McBride conor at strictlypositive.org
Fri May 15 08:19:04 EDT 2009

On 15 May 2009, at 12:07, Lennart Augustsson wrote:

> In the original language design the Haskell committee considered
> allowing multiple occurrences of the same variable in a pattern (with
> the suggested equality tests), but it was rejected in favour of
> simplicity.

Simplicity for whom, is the question? My point is
only that there's no technical horror to the proposal.
It's just that, given guards, the benefit (in simplicity
of program comprehension) of nonlinear patterns over
explicit == is noticeable but hardly spectacular.

Rumblings about funny termination behaviour, equality
for functions, and the complexity of unification (which
isn't the proposal anyway) are wide of the mark. This
is just an ordinary cost-versus-benefit issue. My guess
is that if this feature were already in, few would be
campaigning to remove it. (By all means step up and say
why!) As it's not in, it has to compete with other
priorities: I'm mildly positive about nonlinear
patterns, but there are more important concerns.

Frankly, the worst consequence I've had from Haskell's
pattern linearity was just my father's derision. He
quite naturally complained that his programs had lost
some of their simplicity.

All the best


More information about the Haskell-Cafe mailing list