Typing problem

From: jean-marc alliot (alliot@recherche.enac.fr)
Date: Thu Feb 10 2000 - 14:49:23 MET

  • Next message: Pierre Weis: "Re: Typing problem"

    We recently found a quite annoying problem with the typing system in
    ocaml 2.99, and Jacques Garrigue explained it to us very kindly. Other
    people might be be interested however.

    The problem is summarized in the following code:

    First let's define two types:
    type t1 = (?l:int -> unit -> unit)
    type t = Toto of t1

    Then the function:
    let f1 g =
      g l:3 ();
      (Toto g);;

    This function doesn't compile and the compiler error message is somewhat
    cryptic at first sight:
    File "toto.ml", line 11, characters 8-9:
    This expression has type int -> unit -> 'a but is here used with type
      t1 = ?l:int -> unit -> unit

    To make it compile, you have to type explicitly g with:
    let f2 (g : t1) =
      g l:3 ();
      (Toto g);;

    We would very much like to see this clearly documented in ocaml 2.99
    reference manual, as it is a serious change in the behavior of the
    typing system. Determinism is lost, as typing f1 would succeed if typing
    was done in reverse order (from last line to first line).
    Perhaps also a different error message from the compiler would help in
    detecting such problems.

    P Brisset
    JM Alliot



    This archive was generated by hypermail 2b29 : Fri Feb 11 2000 - 10:37:12 MET