Version française
Home     About     Download     Resources     Contact us    
Browse thread
type of high order functions
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Florent Ouchet <florent.ouchet@i...>
Subject: Re: [Caml-list] type of high order functions
Alexander Bernauer a écrit :
> Why is it that the first example does not compile while the later ones do?
>   
Because type constraints are considered:
 - only for type restriction, not for generalization;
 - after the type inference algorithm is executed.

In your first case, the type inference algorithm gave "f : (int -> 
string) -> int -> string)" after it considered "x" but before it starts 
considering "y" (that step will then fail) and a long time before it 
considers your explicit type constraint.

In your second case, you splitted the statements in 2 blocks, the type 
inference algorithm is called twice (once per block), and this time your 
type constraint was considered before x and y are effectively typed.

-- 
Florent Ouchet
PhD Student
CIS/VDS Team - TIMA Laboratory