caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Yaron Minsky <yminsky@janestreet.com>
To: Jesper Louis Andersen <jesper.louis.andersen@gmail.com>
Cc: "Gabriel Scherer" <gabriel.scherer@gmail.com>,
	"Sébastien Hinderer" <Sebastien.Hinderer@inria.fr>,
	"caml users" <caml-list@inria.fr>
Subject: Re: [Caml-list] polymorphic sets?
Date: Tue, 29 Sep 2015 10:52:08 -0400	[thread overview]
Message-ID: <CACLX4jSCF7wGQ-oiKJc7sXZX6MJA8zvvMvoZVfcsFV-3B6VYJQ@mail.gmail.com> (raw)
In-Reply-To: <CAGrdgiX5mKThdAymhc1LzyQxZw8nQJmGdOhZBu45XUT_BFVi8g@mail.gmail.com>

Core_kernel's maps and sets solve this problem, and address Gabriel's
concern as well, by providing type witnesses that distinguish maps
built with different comparators.  There's an introduction to the use
of these modules here:

<https://realworldocaml.org/v1/en/html/maps-and-hash-tables.html>

and you can see the current APIs here:

<https://github.com/janestreet/core_kernel/blob/master/src/core_map.mli>

Sets are handled similarly.For sure, better inlining (as is coming in
Flambda!) can make this approach better.

y

On Tue, Sep 29, 2015 at 9:56 AM, Jesper Louis Andersen
<jesper.louis.andersen@gmail.com> wrote:
>
> On Tue, Sep 29, 2015 at 2:58 PM, Gabriel Scherer <gabriel.scherer@gmail.com>
> wrote:
>>
>> Note that the polymorphic sets (or maps) are less statically-safe than
>> their functorized counterpart, because they are parametrized over their
>> comparison function at creation time
>
>
> The only point in time I've had troubles is when you have a map where its
> values and keys range over a type that can recursively contain that map of
> the same type. This required a polymorphic compare (from Core) to pull off.
>
>
> --
> J.

  reply	other threads:[~2015-09-29 14:52 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-29 12:43 Sébastien Hinderer
2015-09-29 12:58 ` Gabriel Scherer
2015-09-29 13:35   ` Simon Cruanes
2015-09-29 13:56   ` Jesper Louis Andersen
2015-09-29 14:52     ` Yaron Minsky [this message]
2015-09-29 15:13       ` Gabriel Scherer

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=CACLX4jSCF7wGQ-oiKJc7sXZX6MJA8zvvMvoZVfcsFV-3B6VYJQ@mail.gmail.com \
    --to=yminsky@janestreet.com \
    --cc=Sebastien.Hinderer@inria.fr \
    --cc=caml-list@inria.fr \
    --cc=gabriel.scherer@gmail.com \
    --cc=jesper.louis.andersen@gmail.com \
    /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).