In head&#39;&#39;, what is being compared to Nil?<br><br>The guards of a function are a series of Boolean expressions; but in your example they are of type ConsCell a.&nbsp; The difference is that in a pattern, the structure of the argument is matched; in a guard, an arbitrary expression is evaluated.
<br><br>I have always found the Haskell report instructive in these cases; particularly the transformations into the core language -- in this case see section <a href="http://4.4.3.2">4.4.3.2</a> (<a href="http://haskell.org/onlinereport/decls.html#sect4.4.3.2">
http://haskell.org/onlinereport/decls.html#sect4.4.3.2</a>); this should make it clear why head&#39;&#39; is not valid Haskell.<br><br>cheers,<br>Fraser.<br><br>Guards are really a series of Boolean equations, and the first that evaluates to true 
<br><div class="gmail_quote">On Jan 9, 2008 7:15 PM, Fernando Rodriguez &lt;<a href="mailto:frr149@easyjob.net" target="_blank">
frr149@easyjob.net</a>&gt; wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>Hi,<br><br>I have the following type and function:
<br>
<br>data ConsCell a = Nil | Cons a (ConsCell a) deriving Show<br>head&#39; Nil = Nothing<br>head&#39; (Cons a _) = Just a<br><br>Works fine, however, what&#39;s wrong with the following function?<br><br>head&#39;&#39;<br>

 &nbsp; &nbsp; &nbsp; &nbsp;| Nil = Nothing<br> &nbsp; &nbsp; &nbsp; &nbsp;| Cons a _ = Just a<br><br>Thanks!<br><br><br><br>_______________________________________________<br>Haskell-Cafe mailing list<br><a href="mailto:Haskell-Cafe@haskell.org" target="_blank">
Haskell-Cafe@haskell.org
</a><br><a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br></blockquote></div><br>