[Haskell-cafe] ambiguous types although 'asTypeOf'
Andrea Vezzosi
sanzhiyan at gmail.com
Tue Dec 25 13:50:24 EST 2007
As i understand it, the monomorphism restriction applies to "constrained
type variables", but c :: forall a. a, so it remains polymorphic and each of
its uses can be instantiated to a different type.
2007/12/25, Henning Thielemann <lemming at henning-thielemann.de>:
>
>
> I thought I understand monomorphism restriction. But it seems, I don't. I
> have boilt down my problem to the following test. Don't try to make any
> sense of it, it is just the smallest code I could come up with.
>
>
> test :: (Integral a, RealFrac a) => a
> test =
> let c = undefined
> in asTypeOf (round c) c
>
>
> When compiling I get:
>
> Compiling StorableInstance ( src/StorableInstance.hs, interpreted )
>
> src/StorableInstance.hs:38:17:
> Warning: Defaulting the following constraint(s) to type `Double'
> `RealFrac a' arising from use of `round' at
> src/StorableInstance.hs:38:17-21
> In the first argument of `asTypeOf', namely `(round c)'
> In the definition of `test1': test1 = let c = undefined in
> asTypeOf (round c) c
> _______________________________________________
> 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/20071225/bd374564/attachment.htm
More information about the Haskell-Cafe
mailing list