> It would be nice if the possible exceptions of a function would be part > of the type. E.g. > > let f1 () = raise Not_found > val f1 : unit -> 'a [ Not_found ] > > let f2 () = try f1 () with Not_found -> () > val f2 : unit -> unit > > let f3 f = try f () with Not_found -> () > val f3: (unit -> 'a [< Not_found | 'B ]) -> 'a [ 'B ] > > and so on. > This is what PML does ... and what is nice is that is does not even require the exception to be garded ... > > Someone would have to write a new type system for that though. > Yes, but this require very little new technology : a function having one type or two as return type is basically the same ... and polymorphic variant are very well suited to be the default practice for exception (as in your f3 example).
The only questions (I think) are - complexity of the algorithm (I think it shoud be OK) - readability of inferred types (one could hide exception types by default ?) Cheers, Christophe > MfG > Goswin > > _______________________________________________ > Caml-list mailing list. Subscription management: > http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list > Archives: http://caml.inria.fr > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs >
signature.asc
Description: OpenPGP digital signature
_______________________________________________ Caml-list mailing list. Subscription management: http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Archives: http://caml.inria.fr Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs