caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* "opening" record types
@ 2007-08-21 13:18 Yitzhak Mandelbaum
  2007-08-21 13:34 ` [Caml-list] " Olivier Andrieu
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Yitzhak Mandelbaum @ 2007-08-21 13:18 UTC (permalink / raw)
  To: caml-list

[-- Attachment #1: Type: text/plain, Size: 1181 bytes --]

Hi,

I'm generally averse to opening modules, as I find it can make it  
hard to figure out where definitions are coming from. Instead, I  
prefer to bind only those pieces of the module that I need, and to do  
so explicitly.  However, there is one instance in which I find myself  
with little choice: record types.  In order to bind the field- 
constructors for a record, you need to copy the entire type from the  
module in which its declared. For example,

module Foo =
struct
   type t = {a: int; b:int}
end

without copying the type:

let y = {Foo.a=3; Foo.b=4}

with copying:

type t = Foo.t =  {a: int; b:int}

let x = {a=3; b=4}

While this is a nuisance to begin with, its even worse if the record  
type is subject to change -- each time it changes, you need to update  
every place where you copied the definition.

Is there any way around this?  That is, is there any way to use the  
field names of a record defined in another module without opening the  
whole module or copying the whole definition of the record.

Cheers,
Yitzhak

--------------------------------------------------
Yitzhak Mandelbaum
AT&T Labs - Research

http://www.research.att.com/~yitzhak



[-- Attachment #2: Type: text/html, Size: 3938 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2007-08-22 19:24 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-21 13:18 "opening" record types Yitzhak Mandelbaum
2007-08-21 13:34 ` [Caml-list] " Olivier Andrieu
2007-08-21 22:19   ` Yaron Minsky
2007-08-21 13:42 ` Christophe TROESTLER
2007-08-21 13:55   ` Daniel de Rauglaudre
2007-08-21 13:47 ` Virgile Prevosto
2007-08-22 16:32 ` Philippe Wang
2007-08-22 19:24   ` Jeremy Yallop

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).