caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jacques Garrigue <garrigue@math.nagoya-u.ac.jp>
To: colanderman@gmail.com
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Sparse structure
Date: Sat, 09 Jul 2005 08:29:36 +0900 (JST)	[thread overview]
Message-ID: <20050709.082936.35468277.garrigue@math.nagoya-u.ac.jp> (raw)
In-Reply-To: <875c7e0705070806297630f98d@mail.gmail.com>

From: Chris King <colanderman@gmail.com>

> > module Int = struct type t = int let compare : int -> int -> int = compare end
> > module M = Map.Make(Int)
> > type +'a elt
> > type 'a map = 'a elt M.t
> 
> Thanks, that works great!  I'm curious though, what is the purpose of
> the elt type?  Is it to enforce the use of the map type instead of
> M.t?

Not exactly. [map] is only an abbreviation, used to shorten types in
the rest of the code. [elt] is more fundamental: it both hides the
contents of the map, by being abstract (so you can only access them
through Obj.magic), and has a type parameter which will be used to
enforce the relation between key and data type.

By the way, I've started experimenting with a camlp4 syntax extension
for that, and it seems to works nicely. I'll post it when it gets
cleaner.

Jacques Garrigue


      reply	other threads:[~2005-07-08 23:29 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-07-07 19:27 Chris King
     [not found] ` <1120765639.9384.42.camel@titania>
2005-07-07 20:04   ` [Caml-list] " Chris King
     [not found] ` <87r7eamlv9.fsf@linux-france.org>
2005-07-07 20:16   ` Chris King
2005-07-08  0:57 ` Jacques Garrigue
2005-07-08 13:29   ` Chris King
2005-07-08 23:29     ` Jacques Garrigue [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=20050709.082936.35468277.garrigue@math.nagoya-u.ac.jp \
    --to=garrigue@math.nagoya-u.ac.jp \
    --cc=caml-list@inria.fr \
    --cc=colanderman@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).