[Haskell-cafe] Is this related to monomorphism restriction?

Luke Palmer lrpalmer at gmail.com
Sat Dec 20 18:36:57 EST 2008


On Sat, Dec 20, 2008 at 4:28 PM, Maurí­cio <briqueabraque at yahoo.com> wrote:

> Hi,
>
> Why isn't the last line of this code allowed?
>
> f :: (TestClass a) => a -> Integer
> f = const 1
> a = (f,f)
> g = fst a


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.

Luke


>
>
> The only thing I can think about is monomorphism
> restriction, but it's allowed (or even the third
> line would not be accepted). Is there something
> I could read to understand that?
>
> Thanks,
> Maurício
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081220/1b014896/attachment.htm


More information about the Haskell-Cafe mailing list