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
Type inference inside exceptions ?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2006-10-10 (10:28)
From: Diego Olivier FERNANDEZ PONS <diego.fernandez_pons@e...>
Subject: Re: [Caml-list] Type inference inside exceptions ?
Quoting "ketty ." <>:

>> I would like the type-checker to infer the type inside exceptions (or
>> at least to help me in the "guess a type and test" loop).
> I'd like it to infer the types of record-fields as well :)


type ('a, 'b, 'c) environment = {
     mutable solutions : 'a;
     mutable backtracks : 'b;
     mutable objective : 'c

let min_card = fun env ... -> ...

# val min_card :
   (int list list, int, int) environment ->
   int -> int list -> int list -> int list * int list continuation list =

The typechecker inferred the type of your record-fields.

Polymorphic exceptions are forbidden because they could break the type  
system, leading to a ['a -> 'b] type. That is why I asked for "type  
inference" or any kind of useful help and not for "polymorphic  
exceptions". I would accept the compiler to deny the use of the  
exception if it is not monomorphic.

         Diego Olivier