From: "Paul A. Steckler" <steck@stecksoft.com>
To: caml-list@inria.fr
Subject: [Caml-list] Default value in module
Date: Tue, 12 Sep 2017 16:00:00 -0400 [thread overview]
Message-ID: <CAMSKV5eBE9WhE3xiKA4oBVf1Ek_4AqzkTMNaXLEM=_bmHay3Kg@mail.gmail.com> (raw)
I found myself wanting to define several modules that implement a
module type, where all the implementations but one use the same value
of an item in the type. Essentially, I wanted a default value in the
module type, which I can override if needed. Maybe there's a way to do
this already.
If not, the type could look like:
--
module type Foo =
sig
val ?x : int = 42
end
--
and instances could be:
--
module Bar1 : Foo =
struct
let x = 17
end
module Bar2 : Foo =
struct
end
--
Is this a reasonable idea?
More precisely, I wanted to take an existing module type, add an item
to it, and then edit just the instance with the non-default value. As
it was, I had to edit all the instances. I could have used the class
system to do something similar, but that would have required changing
even more code.
-- Paul
next reply other threads:[~2017-09-12 20:00 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-12 20:00 Paul A. Steckler [this message]
2017-09-12 21:17 ` SP
2017-09-12 21:21 ` Yotam Barnoy
2017-09-12 21:29 ` Paul A. Steckler
2017-09-13 18:56 ` Martin Jambon
[not found] ` <21484041-b7ed-33f0-4434-6817a82289fe@lexifi.com>
2017-09-12 21:49 ` Paul A. Steckler
2017-09-13 18:57 ` Martin Jambon
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='CAMSKV5eBE9WhE3xiKA4oBVf1Ek_4AqzkTMNaXLEM=_bmHay3Kg@mail.gmail.com' \
--to=steck@stecksoft.com \
--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