From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id DEF5ABB84 for ; Sun, 14 Dec 2008 00:37:49 +0100 (CET) X-IronPort-AV: E=Sophos;i="4.36,217,1228086000"; d="scan'208";a="18414056" Received: from discorde.inria.fr ([192.93.2.38]) by mail2-smtp-roc.national.inria.fr with ESMTP; 14 Dec 2008 00:37:49 +0100 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id mBDNbnJa000491 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Sun, 14 Dec 2008 00:37:49 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AiUCAJ/WQ0mB1xBmkWdsb2JhbACTUQEBAQEJCwoHEQW6P4J9g3c X-IronPort-AV: E=Sophos;i="4.36,217,1228086000"; d="scan'208";a="32614299" Received: from treacle.ucs.ed.ac.uk ([129.215.16.102]) by mail4-smtp-sop.national.inria.fr with ESMTP; 14 Dec 2008 00:37:48 +0100 Received: from lmtp2.ucs.ed.ac.uk (lmtp2.ucs.ed.ac.uk [129.215.149.71]) by treacle.ucs.ed.ac.uk (8.13.8/8.13.4) with ESMTP id mBDNbj4u019557; Sat, 13 Dec 2008 23:37:45 GMT Received: from [192.168.1.65] (host81-154-223-74.range81-154.btcentralplus.com [81.154.223.74]) (authenticated bits=0) by lmtp2.ucs.ed.ac.uk (8.13.8/8.13.7) with ESMTP id mBDNbjeY003324 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Sat, 13 Dec 2008 23:37:45 GMT Message-ID: <4944489A.9020808@ed.ac.uk> Date: Sat, 13 Dec 2008 23:43:22 +0000 From: Jeremy Yallop User-Agent: Mozilla-Thunderbird 2.0.0.17 (X11/20081018) MIME-Version: 1.0 To: Christopher L Conway Cc: caml-list@inria.fr Subject: Re: [Caml-list] Immutable cyclic data structures via a References: <49444582.9070004@ed.ac.uk> In-Reply-To: <49444582.9070004@ed.ac.uk> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Edinburgh-Scanned: at treacle.ucs.ed.ac.uk with MIMEDefang 2.60, Sophie, Sophos Anti-Virus, Clam AntiVirus X-Scanned-By: MIMEDefang 2.60 on 129.215.16.102 X-Scanned-By: MIMEDefang 2.52 on 129.215.149.71 Content-Disposition: inline X-Miltered: at discorde with ID 4944474D.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; sig:01 mutable:01 sig:01 node:01 mutable:01 node:01 val:01 val:01 syntax:01 wrote:01 graph:01 graph:01 caml-list:01 immutable:01 cyclic:01 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.