caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Tom _ <tom7ca@yahoo.com>
To: caml-list@inria.fr
Cc: Brian Rogoff <bpr@best.com>
Subject: Re: [Caml-list] classes vs modules
Date: Sun, 27 May 2001 16:52:52 -0700 (PDT)	[thread overview]
Message-ID: <20010527235252.69384.qmail@web11906.mail.yahoo.com> (raw)
In-Reply-To: <Pine.BSF.4.21.0105271331380.656-100000@shell5.ba.best.com>

> You can do this now if you make a PolySet module by
> copying the
> "monomorphic" implementation from the stdlib,
> changing elt and t to 
> 'a elt and 'a t and, using that instead of Set,
> something like:
> 
> let f (cmp : 'a -> 'a -> bool) =
>   let module SomeSet =
>     PolySet.Make 
>       (struct type 'a t = 'a let compare =
> Pervasives.compare end) in
>   ()

Thanks; that's very useful to know, and it seems
to be working.  I think it might be useful to feature
the ability to have polymorphic types in modules
a little more prominently in the documentation.
Maybe some of the standard modules could take
advantage of this more (it would require some
changes to their interfaces, I suppose).

The type signatures I get out of my module after
converting it are a little odd looking:

    type 'a t = 'a
    type 'a tree = Empty | Node of ...
    val insert :
	('a t t t -> 'a t t -> bool) -> 
	'a t t t -> 'a t tree -> 'a tree
    ...

Is there any useful information in the different
number of t's?  They should all be equivalent, right?

BTW, I opted for just passing the "lt" function
as explicit arguments to all the functions in the
module that need them.  That seems like the most
general approach, although it means some extra
arguments and it doesn't guarantee consistency,
as people might pass incompatible versions of "lt"
to different calls; a more convenient interface can
then be wrapped around that, maybe in a different
module

Cheers,
Tom.


__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/
-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr


  parent reply	other threads:[~2001-05-27 23:52 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-05-27 13:31 Tom _
2001-05-27 16:14 ` Markus Mottl
2001-05-27 20:54   ` Brian Rogoff
2001-05-27 23:13     ` Markus Mottl
2001-05-27 23:52     ` Tom _ [this message]
2001-05-28  4:15       ` Brian Rogoff
2001-05-28  8:34       ` Andreas Rossberg
2001-05-28  8:24   ` Andreas Rossberg

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=20010527235252.69384.qmail@web11906.mail.yahoo.com \
    --to=tom7ca@yahoo.com \
    --cc=bpr@best.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;
as well as URLs for NNTP newsgroup(s).