From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p83AcJ1w025119 for ; Sat, 3 Sep 2011 12:38:19 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AioCAGADYk5V2gB5hWdsb2JhbABCqQABAQEKCwsbJoFGAQEFJyAkDhALRhQoIYgIpwiNfQ6GXASkPQ X-IronPort-AV: E=Sophos;i="4.68,324,1312149600"; d="scan'208";a="107571289" Received: from emailfrontal2.citycable.ch ([85.218.0.121]) by mail4-smtp-sop.national.inria.fr with SMTP; 03 Sep 2011 12:37:53 +0200 X-Alinto-smtpauth-localdomain: Yes Received: from seldon (unknown [85.218.93.239]) (Authenticated sender: guillaume.yziquel@citycable.ch) by emailfrontal2.citycable.ch (Postfix) with ESMTPA id AA71520C158; Sat, 3 Sep 2011 12:37:46 +0200 (CEST) Received: from yziquel by seldon with local (Exim 4.72) (envelope-from ) id 1Qznan-0002OC-QX; Sat, 03 Sep 2011 12:36:53 +0200 Date: Sat, 3 Sep 2011 12:36:53 +0200 From: Guillaume Yziquel To: Goswin von Brederlow Cc: caml-list@inria.fr Message-ID: <20110903103653.GX15100@localhost> References: <87ty8uc5ph.fsf@frosties.localnet> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <87ty8uc5ph.fsf@frosties.localnet> User-Agent: Mutt/1.5.20 (2009-06-14) Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by walapai.inria.fr id p83AcJ1w025119 Subject: Re: [Caml-list] Odd failure to infer types Le Saturday 03 Sep 2011 à 11:53:30 (+0200), Goswin von Brederlow a écrit : > Hi, > > I'm implementing a solver for the game Atomix. If you don't know it then > don't worry. It isn't relevant. > > I split things up into submodules and now one of the submodules does not > infere the right types: > > File "Atomix.ml", line 168, characters 11-876: > Error: The type of this module, > sig > type dir = NORTH | SOUTH | WEST | EAST > val max_moves : int > val cache : (string, unit) Hashtbl.t > val states : > ('_a list * (char * int * int) array * string) list array > val string_of_dir : dir -> string > val print : > (int * int * dir) list * (char * int * int) array * string -> unit > val num_states : int > end, contains type variables that cannot be generalized > > I believe this is wrong. In S.num_states the call to "print state" > fixates the type for state and the "states.(d) <- state::states.(d);" > should then fixate the missing '_a in the type for states. > > Anyone know why? It also seems quite wrong to me. You should perhaps file a bug into Mantis if no typing expert answers. Did you try adding type annotations one at a time near the call to print and the states.(d) assignment in your anonymous List.fold-ing function? To check precisely what the type inferencer gets right and what it gets wrong? I'd be curious to know whether annotating state in "states.(d) <- state::states.(d)" solves your problem. Since it's here that the '_a in the type of states should be fixated. -- Guillaume Yziquel