[Haskell] insufficiently laziness@pattern -- more counterintuitive stuff

Duncan Coutts duncan at coutts.uklinux.net
Tue Mar 30 18:13:53 EST 2004


On Tue, 2004-03-30 at 18:01, S. Alexander Jacobson wrote:
> Thanks for the ~ syntax, but my question is really
> why you need it?  What benefit do you get from
> "refutable patterns"?
> 
> Alternatively, would anything break if a future
> Haskell just treated all patterns as irrefutable?

A short pragmatic answer is that "refutable patterns" are stricter and
so more efficient. 

(Oops, I've fallen into the C programmers trap of justifying things by
efficiency first and thinking later)

How about justifying it by saying that they translate directly into case
expressions without any extra let, and so are easier to think about that
way.

Or finally, the "it's what you want most often" argument. For example
out of the whole Prelude+List modules, the only functions that use
irrefutable patterns are the unzip functions.

Duncan



More information about the Haskell mailing list