From: Jeremy Yallop <jeremy.yallop@ed.ac.uk>
To: Christopher L Conway <cconway@cs.nyu.edu>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Immutable cyclic data structures via a
Date: Sat, 13 Dec 2008 23:43:22 +0000 [thread overview]
Message-ID: <4944489A.9020808@ed.ac.uk> (raw)
In-Reply-To: <49444582.9070004@ed.ac.uk>
Jeremy Yallop wrote:
> module Graph :
> sig
> module Mutable :
> sig
> type node = { mutable outgoing : edge list }
> and edge = { from : node ; to_ : node }
> end
>
> module Immutable :
> sig
> type node = private { mutable outgoing : edge list }
> and edge = { from : node ; to_ : node }
> end
>
> module Freeze :
> sig
> val node : Mutable.node -> Immutable.node
> val edge : Mutable.edge -> Immutable.edge
> end
> end =
I should also mention a drawback of this approach, which is that
"private" may be stronger than you need. Values of private record type
can be neither updated *nor created*; outside the Graph module you
cannot construct fresh values of Immutable.node, or even use "functional
update" (i.e. "with" syntax) to construct new values from existing
Immutable.node values.
Jeremy.
--
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.
next prev parent reply other threads:[~2008-12-13 23:37 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-13 21:45 Christopher L Conway
2008-12-13 23:30 ` [Caml-list] " Jeremy Yallop
2008-12-13 23:43 ` Jeremy Yallop [this message]
2008-12-14 1:47 ` Edgar Friendly
2008-12-14 9:10 ` Francois Pottier
2008-12-14 14:29 ` blue storm
2008-12-14 20:06 ` Richard Jones
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=4944489A.9020808@ed.ac.uk \
--to=jeremy.yallop@ed.ac.uk \
--cc=caml-list@inria.fr \
--cc=cconway@cs.nyu.edu \
/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