<br><br><div class="gmail_quote">On Sat, Dec 20, 2008 at 4:28 PM, Maurício <span dir="ltr"><<a href="mailto:briqueabraque@yahoo.com">briqueabraque@yahoo.com</a>></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't the last line of this code allowed?<br>
<br>
f :: (TestClass a) => a -> Integer<br>
f = const 1<br>
a = (f,f)<br>
g = fst a</blockquote><div><br>Yep, monomorphism restriction. a, because it is syntactically not a function, must not be typeclass polymorphic (without a type signature). So it tries to default, and TestClass probably doesn't have any defaults.<br>
<br>Luke<br> </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'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>