Browse thread
Sparse structure
-
Chris King
- Chris King
- Chris King
-
Jacques Garrigue
-
Chris King
- Jacques Garrigue
-
Chris King
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Jacques Garrigue <garrigue@m...> |
| Subject: | Re: [Caml-list] Sparse structure |
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