Yes of course, P x is a function, and you can&#39;t pattern match against functions, I knew that. How silly of me, I could have guessed that myself.<div><div><div><div><div><br></div><div><div><div><div><div class="gmail_quote">
On Mon, Mar 9, 2009 at 5:43 PM, Daniel Fischer <span dir="ltr">&lt;<a href="mailto:daniel.is.fischer@web.de">daniel.is.fischer@web.de</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Am Montag, 9. März 2009 17:30 schrieb Peter Verswyvelen:<br>
<div><div></div><div class="h5">&gt; In Haskell, a data constructor can be used partially applied:<br>
&gt; data Pair a b = P a b<br>
&gt;<br>
&gt; f = P 1<br>
&gt;<br>
&gt; however, I cannot do &quot;partial pattern matching&quot;, e.g<br>
&gt;<br>
&gt; firstCoord (P x) = x<br>
&gt;<br>
&gt; does not work.<br>
&gt;<br>
&gt; I guess a very important reason must exist why this is the case?<br>
<br>
</div></div>For one, the type. If x :: a, then P x :: b -&gt; Pair a b, so we&#39;d have<br>
<br>
firstCoord :: (b -&gt; Pair a b) -&gt; a<br>
<br>
But you can pattern-match only on constructors of the appropriate type. P is<br>
not a constructor of (b -&gt; Pair a b) (function types don&#39;t have<br>
constructors), so you can&#39;t match on a partially applied constructor.<br>
</blockquote></div><br></div></div></div></div></div></div></div></div>