[Haskell-cafe] Solved but strange error in type inference
Brandon Allbery
allbery.b at gmail.com
Wed Jan 4 14:53:13 CET 2012
On Wed, Jan 4, 2012 at 08:41, Yves Parès <limestrael at gmail.com> wrote:
> Would you try:
>
> f :: a -> a
> f x = undefined :: a
>
> And tell me if it works? IMO it doesn't.
It won't; a will be a new type variable unrelated to the one in the
signature, in the absence of ScopedTypeVariables and an explicit forall in
the signature.
As I understand it, without ScopedTypeVariables the scope of type variables
in the signature is exactly the signature; with ScopedTypeVariables *and*
an explicit forall, the scope includes the equation.
Also, I should mention that the extensions-free way to do this kind of
thing is judicious use of asTypeOf.
--
brandon s allbery allbery.b at gmail.com
wandering unix systems administrator (available) (412) 475-9364 vm/sms
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20120104/63475d28/attachment.htm>
More information about the Haskell-Cafe
mailing list