From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id SAA14299 for caml-redistribution; Mon, 15 Feb 1999 18:46:28 +0100 (MET) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id RAA31768 for ; Mon, 15 Feb 1999 17:59:44 +0100 (MET) Received: from heplix4.ikp.physik.tu-darmstadt.de (heplix4.ikp.physik.tu-darmstadt.de [130.83.24.139]) by nez-perce.inria.fr (8.8.7/8.8.7) with ESMTP id RAA08332 for ; Mon, 15 Feb 1999 17:59:43 +0100 (MET) Received: (from ohl@localhost) by heplix4.ikp.physik.tu-darmstadt.de (8.8.8/8.8.8) id RAA10464; Mon, 15 Feb 1999 17:59:41 +0100 Date: Mon, 15 Feb 1999 17:59:41 +0100 Message-Id: <199902151659.RAA10464@heplix4.ikp.physik.tu-darmstadt.de> From: Thorsten Ohl To: caml-list@inria.fr Subject: Non generalizable type of constants? Reply-to: ohl@hep.tu-darmstadt.de Sender: weis OK, maybe I'm really too dumb to use O'Caml, but can some kind soul explain why in module type Ring = sig type t val unit : t end module Group (R : Ring) = struct type 'a t = Unit | Prod of (R.t * 'a) let unit = Unit let atom a = Prod (R.unit, a) end module FreeRing (R : Ring) = struct module M = Group(R) module A = Group(R) type 'a t = 'a M.t A.t let unit_good = A.Prod (R.unit, M.unit) let unit_bad = A.atom (M.unit) end O'Caml infers the types val unit_good : 'a M.t A.t val unit_bad : '_a M.t A.t respectively? As one might guess, I want to make [['a Group.t]] abstract (because I want to hide a more complicated structure), in which case the definition of [[unit_good]] will not work any more. At the same time, I need [[unit]] to have type [['a FreeRing.t]] and not [['_a FreeRing.t]]. The usual tricks for functions with non generalizable argument types don't work. What can one do for constants? Or am I overlooking something obvious? Merci, -Thorsten -- Thorsten Ohl, Physics Department, TU Darmstadt -- ohl@hep.tu-darmstadt.de http://heplix.ikp.physik.tu-darmstadt.de/~ohl/ [<=== PGP public key here]