[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Juan J. Quintela <quintela@d...> |
| Subject: | Re: Weak types ? |
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?