Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
bizarre type
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Julien Verlaguet <Julien.Verlaguet@p...>
Subject: Re: [Caml-list] bizarre type

> Well, since '_a t = int t the compiler can freely choose either for
> printing. Or bool t, for that matter.


> Yes, but that's not what you did in the other example. You wrote (x : 'a
> t) - and because of the way t was defined this was as good as writing (x :
> string) and hence did not induce any additional constraint.

Ok, I have to aggree.

In fact it prevents me from writting this :

type 'a marshalled=string

let make (x : 'a)=(Marshal.to_string x [] : 'a marshalled);;

And then do all type of operations in a type safe way on strings.

I have to aggree though that I wrote 'a t=string and therefore one should
be able to exchange them.

The only tiny thing that disturbs me is that in my previous example :

let g (x : 'a t) (y : 'a)

the type of y depends on the 'a present in 'a t.
It is odd. But I have to admit it's correct.

Thanks for your help.