Version française
Home     About     Download     Resources     Contact us    
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: Andreas Rossberg <AndreasRossberg@w...>
Subject: Re: [Caml-list] bizarre type
From: "Julien Verlaguet" <Julien.Verlaguet@pps.jussieu.fr>
>
> # type 'a t=string;;
> type 'a t = string
> # let g (x : 'a) (y : 'a t)=();;
> val g : 'a -> 'a t -> unit = <fun>
> # g 3;;
> - : int t -> unit = <fun>
>
> here we should have int t=string='_a t ...

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

> I strongly disaggree with the fact that the compiler infered the most
> general type in this case.
>
> Because I specified it.
>
> when you write (let f=fun (x : 'a) (y : 'a) -> (x,y)), you force the type
> of x
> and y to be equal.

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.

Cheers,

  - Andreas