[Haskell-cafe] Is this related to monomorphism restriction?
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:
> 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.
> 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?
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe