<div dir="ltr">On Tue, Apr 10, 2012 at 20:53, <span dir="ltr"><<a href="mailto:j.romildo@gmail.com">j.romildo@gmail.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On Tue, Apr 10, 2012 at 02:16:15PM -0700, Tim Perry wrote:<br>
> I believe that "f 0 = ..." is a guard and the guard is pattern matching on<br>
> the constructor. Despite the fact that you don't have an instance of "f _ =<br>
> ....", the compiler needs an Eq instance to determine if it should run the<br>
> "f 0" version of the function.<br>
><br>
> Does that make sense? Hopefully someone with a better grasp of the topic<br>
> will fill in the details.<br>
<br>
</div>I think you are using the wrong terms. The given examples does not make<br>
any use of guards. Guards are boolean expressions attached to the right<br>
</blockquote><div><br></div><div>It is using guards; you don't see them, because it's quietly translated by the compiler in the same way that `do` blocks are translated into applications of (>>=) and (>>) operators.</div>
<div><br></div><div>The reason for this is that numeric literals aren't actually literals; they are applications of the `fromInteger` function. This is true even in patterns; therefore they can't actually be matched as patterns but are translated into guards.</div>
<div><br></div></div>-- <br>brandon s allbery <a href="mailto:allbery.b@gmail.com" target="_blank">allbery.b@gmail.com</a><br>wandering unix systems administrator (available) (412) 475-9364 vm/sms<br>
<br>
</div>