caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] My wishlist: DRY modules
@ 2004-10-13 22:00 Brian Hurt
  2004-10-13 23:09 ` brogoff
  2004-10-30  1:21 ` Tony Edgin
  0 siblings, 2 replies; 5+ messages in thread
From: Brian Hurt @ 2004-10-13 22:00 UTC (permalink / raw)
  To: Ocaml Mailing List


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


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2004-10-30  1:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-13 22:00 [Caml-list] My wishlist: DRY modules Brian Hurt
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).