<div dir="auto">I firmly believe that making pattern matches in let and where clauses lazy by default was a mistake in the Haskell Report. It's inconsistent with how pattern matching works elsewhere in the language, and also makes a strange distinction between outer and inner pattern matches. Unfortunately, it's way too late to fix that mistake.</div><div class="gmail_extra"><br><div class="gmail_quote">On Feb 24, 2017 12:09 AM, "Harendra Kumar" <<a href="mailto:harendra.kumar@gmail.com">harendra.kumar@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">CCing the list. I guess you intended to cc but forgot.<div><br><div class="gmail_extra"><div class="gmail_quote">On 24 February 2017 at 09:27,  <span dir="ltr"><<a href="mailto:ok@cs.otago.ac.nz" target="_blank">ok@cs.otago.ac.nz</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">In Erlang, the equivalent of a let fails.<br>
1> 1=2.<br>
** exception error: no match of right hand side value 2<br>
<br>
In SML, the equivalent of a let fails.<br>
- val 1 = 1;<br>
- val 1 = 2;<br>
<br>
uncaught exception Bind [nonexhaustive binding failure]<br>
  raised at: stdIn:2.5-2.10<br>
<br>
The problem is not that let 1 = 2 ... is *legal* but that<br>
- the compiler is  *silent* about it<br>
- the runtime is *silent* about it.<br>
Compiling the little program<br>
<br>
  main = let 1 = 2 in print "hi"<br>
<br>
I expected that the compiler would be silent but that<br>
there would be some sort of "matched failed" error at<br>
run time.  Silly me.<br>
<br>
<br>
The thing is, it is not just bindings that bind no variables<br>
that act as if they were not there.<br>
<br>
  main = let [x] = [1,2] in print "hi"<br>
<br>
also compiles silently and runs without error.  Change it to<br>
<br>
  main = let [x] = [1,2] in print ("hi" ++ show x)<br>
<br>
and you get a runtime error<br>
<br>
<object>: <source>: Irrefutable pattern failed for pattern [x].<br>
<br>
I wish the compiler would report an error something like<br>
<br>
"<location>: possibly failing match deleted<br>
             because it binds no live variables"<br>
<br>
<br>
<br>
</blockquote></div><br></div></div></div>
<br>______________________________<wbr>_________________<br>
Haskell-Cafe mailing list<br>
To (un)subscribe, modify options or view archives go to:<br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-<wbr>bin/mailman/listinfo/haskell-<wbr>cafe</a><br>
Only members subscribed via the mailman list are allowed to post.<br></blockquote></div></div>