[Haskell-cafe] Vanishing polymorphism
David House
dmhouse at gmail.com
Tue May 8 17:43:39 EDT 2007
On 08/05/07, Matthew Sackman <matthew at wellquite.org> wrote:
> > :t let f r s = (return negate) >>= (\(fn::forall n . (Num n) => n -> n) -> return (fn r, fn s)) in f
>
> <interactive>:1:35:
> Couldn't match expected type `a -> a'
> against inferred type `forall n. (Num n) => n -> n'
> In the pattern: fn :: forall n. (Num n) => n -> n
> In a lambda abstraction:
> \ (fn :: forall n. (Num n) => n -> n) -> return (fn r, fn s)
> In the second argument of `(>>=)', namely
> `(\ (fn :: forall n. (Num n) => n -> n) -> return (fn r, fn s))'
>
> I.e. why does the polymorphism get destroyed?
Here fn is bound by a lambda abstraction, and is therefore
monomorphic. I can't find anything in the Report about that, but that
is how it works. It might be how a H-M type system works in general,
I'm not sure.
--
-David House, dmhouse at gmail.com
More information about the Haskell-Cafe
mailing list