From: Brian Hurt <bhurt@spnz.org>
To: Ocaml Mailing List <caml-list@inria.fr>
Subject: [Caml-list] My wishlist: DRY modules
Date: Wed, 13 Oct 2004 17:00:12 -0500 (CDT) [thread overview]
Message-ID: <Pine.LNX.4.44.0410131650430.4934-100000@localhost.localdomain> (raw)
I'm doing some work with modules, and I'm learning some of their
annoyances. Number one is having to repeat module type definitions. For
example, say you have a file foo. In foo.mli, you have:
module type T = sig
type s
val needed : ...
end
module type S = sig
type t
val doit : ...
val orelse : ...
end
module Make(Arg: T) : S with type t = Arg.s
So far, so good, but now in foo.ml you need to replicate the definitions
of *both* T and S:
module type T = sig
type s
val needed : ...
end
module type S = sig
type t
val doit : ...
val orelse : ...
end
module Make(Arg: T) = struct
type t = Arg.s
let doit = ...
let orelse = ...
end
Now, if you know your module signatures when you start, this isn't that
big of a problem- it's a cut and paste. Unfortunately, if you don't know
your module signatures at the begining, to add or subtract or change a
type or val you need to update the signature in *three* different places.
I wish you didn't have to repeat the module definitions in the module
file *if* you have a .mli file.
The subject line, BTW, comes from the Pragmatic Programmer book's DRY
principle- Don't Repeat Yourself.
--
"Usenet is like a herd of performing elephants with diarrhea -- massive,
difficult to redirect, awe-inspiring, entertaining, and a source of
mind-boggling amounts of excrement when you least expect it."
- Gene Spafford
Brian
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
next reply other threads:[~2004-10-13 21:51 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-10-13 22:00 Brian Hurt [this message]
2004-10-13 23:09 ` brogoff
2004-10-14 0:21 ` skaller
2004-10-14 1:38 ` Jacques Garrigue
2004-10-30 1:21 ` Tony Edgin
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=Pine.LNX.4.44.0410131650430.4934-100000@localhost.localdomain \
--to=bhurt@spnz.org \
--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