Non generalizable type of constants?

From: Thorsten Ohl (
Date: Mon Feb 15 1999 - 17:59:41 MET

Date: Mon, 15 Feb 1999 17:59:41 +0100
Message-Id: <>
From: Thorsten Ohl <>
Subject: Non generalizable type of constants?

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) =
        type 'a t = Unit | Prod of (R.t * 'a)
        let unit = Unit
        let atom a = Prod (R.unit, a)
    module FreeRing (R : Ring) =
        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)

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?


Thorsten Ohl, Physics Department, TU Darmstadt -- [<=== PGP public key here]

This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:19 MET