On Fri, 5 Nov 2004 11:49:41 +0900, Nicolas Cannasse <

warplayer@...> wrote:

>

>

> > results in f not being fully polymorphic, but

> > val example1 : 'a -> 'b -> 'c -> 'a * 'b * 'c = <fun>

> > let f = fun x -> example1 1 2 x;;

> > val f : 'a -> int * int * 'a = <fun>

> >

> > Does. It seems to me that I should be able to return a (fun x- >

> > blah), and have it be as polymorphic as possible. (not should in the

> > 'right thing' sense, but should in the 'actual way it works' sense,

> > based on my very poor knowledge of ocaml types and '_a).

>

> The monomorphic types '_a and others are needed in order to ensure type

> safety.

> for example :

>

> let id x = x

> let f = ref id

Thanks... that's the example I needed to fit this in my head.

I'm still slightly bothered by the fragility with which '_a is

introduced or not.

# let f a b = (a,b);;

val f : 'a -> 'b -> 'a * 'b = <fun>

# let g = f 1;;

val g : '_a -> int * '_a = <fun>

# let g = fun x -> f 1 x;;

val g : 'a -> int * 'a = <fun>

# let g = ignore 5; fun x -> f 1 x;;

val g : '_a -> int * '_a = <fun>

# let g = if true then fun x -> f 1 x else fun x -> f 1 x;;

val g : 'a -> int * 'a = <fun>

I cannot figure out when I will get a '_a and when I will not.

--

Seth Fogarty sfogarty@[gmail.com|rice.edu|livejournal]

Neep-neep at large AIM: Sorrath

"I know there are people in this world who do not love their fellow

human beings - and I hate people like that" --Tom Lehrer.