From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 3B56EBCAE for ; Sat, 9 Jul 2005 01:29:47 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j68NTkhl002241 for ; Sat, 9 Jul 2005 01:29:46 +0200 Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id BAA09068 for ; Sat, 9 Jul 2005 01:29:46 +0200 (MET DST) Received: from kurims.kurims.kyoto-u.ac.jp (kurims.kurims.kyoto-u.ac.jp [130.54.16.1]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j68NTi6v004474 for ; Sat, 9 Jul 2005 01:29:45 +0200 Received: from localhost (suiren [130.54.16.25]) by kurims.kurims.kyoto-u.ac.jp (8.13.1/8.13.1) with ESMTP id j68NTdKr009020; Sat, 9 Jul 2005 08:29:39 +0900 (JST) Date: Sat, 09 Jul 2005 08:29:36 +0900 (JST) Message-Id: <20050709.082936.35468277.garrigue@math.nagoya-u.ac.jp> To: colanderman@gmail.com Cc: caml-list@inria.fr Subject: Re: [Caml-list] Sparse structure From: Jacques Garrigue In-Reply-To: <875c7e0705070806297630f98d@mail.gmail.com> References: <875c7e0705070712273e4231a9@mail.gmail.com> <20050708.095744.108119733.garrigue@math.nagoya-u.ac.jp> <875c7e0705070806297630f98d@mail.gmail.com> X-Mailer: Mew version 4.2 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Miltered: at nez-perce with ID 42CF0C6A.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 42CF0C68.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 struct:01 elt:01 elt:01 abbreviation:01 syntax:01 abstract:01 int:01 int:01 jacques:01 jacques:01 data:02 parameter:02 types:02 seems:03 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.2 X-Spam-Level: From: Chris King > > 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