~ patterns

Ben Rudiak-Gould Benjamin.Rudiak-Gould at cl.cam.ac.uk
Tue Jan 31 16:50:24 EST 2006

John Hughes wrote:
> Quick, when I write do (x,y)<-e... is that pair matched strictly, like
> case, or lazily, like let? If strictly, then why? There's no choice to be
> made here, so why not wait until x or y is used before matching?

The choice of whether to invoke fail can't be postponed. Admittedly fail 
will never be called in this case, but I think legislating special behavior 
for such cases would be a bad idea. What would (x,[]) <- e mean?

> If only pattern matching was *always*
> strict, unless a ~ appeared, then the language would be more regular and
> easier to learn.

But then (let 1=2 in "Whee!") wouldn't work properly any more. :-)

-- Ben

More information about the Haskell-prime mailing list