From: Thorsten Ohl <ohl@hep.tu-darmstadt.de>
To: caml-list@inria.fr
Subject: Non generalizable type of constants?
Date: Mon, 15 Feb 1999 17:59:41 +0100 [thread overview]
Message-ID: <199902151659.RAA10464@heplix4.ikp.physik.tu-darmstadt.de> (raw)
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]
next reply other threads:[~1999-02-15 17:46 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-02-15 16:59 Thorsten Ohl [this message]
1999-02-15 17:45 ` Pierre Weis
1999-02-15 18:04 ` Thorsten Ohl
1999-02-16 7:16 ` Pierre Weis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=199902151659.RAA10464@heplix4.ikp.physik.tu-darmstadt.de \
--to=ohl@hep.tu-darmstadt.de \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox