<br><br><div class="gmail_quote">On Sat, Dec 20, 2008 at 4:28 PM, Maurí­cio <span dir="ltr">&lt;<a href="mailto:briqueabraque@yahoo.com">briqueabraque@yahoo.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi,<br>
<br>
Why isn&#39;t the last line of this code allowed?<br>
<br>
f :: (TestClass a) =&gt; a -&gt; Integer<br>
f = const 1<br>
a = (f,f)<br>
g = fst a</blockquote><div><br>Yep, monomorphism restriction.&nbsp; a, because it is syntactically not a function, must not be typeclass polymorphic (without a type signature).&nbsp; So it tries to default, and TestClass probably doesn&#39;t have any defaults.<br>
<br>Luke<br>&nbsp;</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
<br>
The only thing I can think about is monomorphism<br>
restriction, but it&#39;s allowed (or even the third<br>
line would not be accepted). Is there something<br>
I could read to understand that?<br>
<br>
Thanks,<br>
Maurício<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>