From: Peng Zang <peng.zang@gmail.com>
To: Christophe Raffalli <christophe.raffalli@univ-savoie.fr>
Cc: caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] on objects, equality and playing nicely with the stdlib
Date: Thu, 29 May 2008 09:25:11 -0400 [thread overview]
Message-ID: <200805290925.14135.peng.zang@gmail.com> (raw)
In-Reply-To: <483E65A0.3060405@univ-savoie.fr>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Thursday 29 May 2008 04:13:20 am Christophe Raffalli wrote:
> Via Custom block (section 18.9.1 of the manual), you could create a functor
> with the following shape (I did not check my syntax):
>
> module type Quotient =
> type t
> type qt
> val class : t -> qt
> val get_representent : qt -> t
> end
>
> module type Equivalence =
> type t
> val compare : t -> t -> int
> end
>
> module Make_Quotient (R : Equivalence) : Quotient with type t = R.t
>
> Such that (class x) builds a custom block with
> the given compare as comparison function ...
> You can add hash and serialization to the Equivalence type too ...
>
> It is a pity we have to do that from C, this should be the default way
> to bridge the gap between polymorphic comparison and specific comparison.
> (and PML will provide a buildin class constructor in the near future).
>
> Hope this helps,
> Christophe
This is very interesting. I've never read that part of the manual. It's
probably too much overhead for me, so I'll resort to cut + paste first and
see how it goes. Thanks,
Peng
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.7 (GNU/Linux)
iD8DBQFIPq66fIRcEFL/JewRAh2mAKCjCBE3OLYeAudddf5qCoF5jtKmLgCfTRWP
Q5xoPoXccaD512zj99mDs7Q=
=X2pn
-----END PGP SIGNATURE-----
prev parent reply other threads:[~2008-05-29 13:25 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-29 4:50 Peng Zang
2008-05-29 7:13 ` [Caml-list] " Jon Harrop
2008-05-29 8:13 ` Christophe Raffalli
2008-05-29 13:25 ` Peng Zang [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=200805290925.14135.peng.zang@gmail.com \
--to=peng.zang@gmail.com \
--cc=caml-list@inria.fr \
--cc=christophe.raffalli@univ-savoie.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