caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Virgile Prevosto <virgile.prevosto@m4x.org>
To: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] type troubles with functors
Date: Wed, 22 Jun 2005 09:50:26 +0200	[thread overview]
Message-ID: <20050622095026.4dc5bcf0@mpiat2305> (raw)
In-Reply-To: <20050622064836.GA27983@pulp.anu.edu.au>

Le 06/22/2005, à 04:48:36 PM, Pietro Abate a écrit:
> module type OrderedType = sig
>       type t
>       val compare : t -> t -> int
> end
> 
> 
> module type S = sig
>       type elt
>       type t
>       type set
>       val to_list : t -> elt list
>       val to_set : t -> set
> end
> 
> module Make (Ord : OrderedType) : S = struct

I guess it might be useful to have as signature
'S with type elt = Ord.t', otherwise the elements of the sets would be
abstract as well.
Another solution for the module type would be to export explicitely the
set module -with another type constraint stating that it manipulate
elements of the same type as S itself:

module type S = sig
    type elt
    module EltSet: Set.S with type elt = elt
    type t
    val to_list : t -> elt list
    val to_set: t -> EltSet.t
end

This way, you'll have access directly to all the functions provided in
Set.S, while with the above signature, you must write them explicitely
in the signature S in order to use them (but this also allows you to
restrict the operations that are allowed on values of EltSet.t, which is
not the case when exposing the whole module).



-- 
E tutto per oggi, a la prossima volta
Virgile


      reply	other threads:[~2005-06-22  7:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-22  4:53 Scott Duckworth
2005-06-22  6:48 ` [Caml-list] " Pietro Abate
2005-06-22  7:50   ` Virgile Prevosto [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=20050622095026.4dc5bcf0@mpiat2305 \
    --to=virgile.prevosto@m4x.org \
    --cc=caml-list@yquem.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;
as well as URLs for NNTP newsgroup(s).