Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Tony Edgin <edgin@slingshot.co.nz>
To: Brian Hurt <bhurt@spnz.org>, Ocaml Mailing List <caml-list@inria.fr>
Subject: Re: [Caml-list] My wishlist: DRY modules
Date: Sat, 30 Oct 2004 14:21:26 +1300	[thread overview]
Message-ID: <200410301421.27004.edgin@slingshot.co.nz> (raw)
In-Reply-To: <Pine.LNX.4.44.0410131650430.4934-100000@localhost.localdomain>

This is a reply to an old email, but it reflects something I just learned.

On Thu, 14 Oct 2004 11:00, Brian Hurt wrote:
> 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

One partial solution would be to do the following in your foo.ml file.

module type T = Foo.T
module type S = Foo.S

module Make(Arg: T) = struct
	type t = Arg.s
	let doit = ...
	let orelse = ...
end

;;

cheers.

-- 
Tony Edgin
CARP


      parent reply	other threads:[~2004-10-30  1:22 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-10-13 22:00 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 message]

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=200410301421.27004.edgin@slingshot.co.nz \
    --to=edgin@slingshot.co.nz \
    --cc=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