Pattern guards
Yitzchak Gale
gale at sefer.org
Sun Oct 1 05:29:11 EDT 2006
Sebastian Sylvan wrote:
> I would argue that most Haskell programmers
> would *never* write the various snippets of code
> demonstrated in this thread in your way,
I agree, too. I am not advocating that people should
write code exactly that way in real life. My construction
is meant to be a proof that pattern guards do not
provide any significant simplification even in the worst
case.
In real life, the monadic approach usually leads to a
significant simplification. I find that whenever I feel an
urge to use a pattern guard, it is a sure sign that I
have landed in the wrong monad. I step back and
look again at my overall design, and the result is
invariably much better code. And the urge goes
away.
> Adding syntactic sugar is cheap, as long as the
> core concepts are small and elegant.
The graveyard is littered with the remains of
programming languages that took that approach and
met an ignoble end.
The entire language must remain small and elegant -
not just the individual pieces of new syntax that
are bolted on.
Feature-creep is what eventually kills every
programming language. Since Haskell is already a
mature language as it first becomes adapted for
general use, we need to be especially vigilant.
-Yitz
More information about the Haskell-prime
mailing list