To: Pierre CASTERAN <Pierre.Casteran@labri.u-bordeaux.fr>
Subject: Re: Weak types ?
From: "Juan J. Quintela" <quintela@dc.fi.udc.es>
Date: 05 Feb 1998 17:05:23 +0100
In-Reply-To: Pierre CASTERAN's message of Tue, 3 Feb 1998 16:46:22 +0100 (MET)
Pierre CASTERAN <Pierre.Casteran@labri.u-bordeaux.fr> wrote:
> let toto =
> let id x = x
> in id id;;
> (*
> val toto : '_a -> '_a = <fun>
> ^ ^
>
> why not " 'a " ?
>
> *)
Hi,
I really dont remember the reason, but I remember one solution,
to put explicity the varibles in the binbidng, i. e.:
# let toto y =
let id x = x
in (id id) y;;
val toto : 'a -> 'a = <fun>
Now it works with the normal values:
# toto 5;;
- : int = 5
# toto true;;
- : bool = true
But the identity function returns again the extrange type variables:
# toto (fun z -> z);;
- : '_a -> '_a = <fun>
You can solve this again using the same technique:
# let f y = (toto (fun z -> z)) y;;
val f : 'a -> 'a = <fun>
I remember some mail (I think in this list) about this matter. It turs
to be problem with the eta reduction but I don't remind the details, I
remember the solution, to put the varibles in the bindings.
I hope this helps.
Cheers, Juan.
PS. Someone knows the details for this behaviour?
This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:13 MET