From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 7984CBB84 for ; Wed, 10 May 2006 18:17:19 +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 k4AGHImB005962 for ; Wed, 10 May 2006 18:17:19 +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 SAA21085 for ; Wed, 10 May 2006 18:17:18 +0200 (MET DST) Received: from hugh.cs.washington.edu (hugh.cs.washington.edu [128.208.2.43]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id k4AGHGbr031629 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Wed, 10 May 2006 18:17:17 +0200 Received: from [128.208.2.33] (gerald.cs.washington.edu [128.208.2.33]) by hugh.cs.washington.edu (8.13.6/8.13.5/1.5) with ESMTP id k4AGHD1H001496; Wed, 10 May 2006 09:17:13 -0700 (envelope-from djg@cs.washington.edu) Message-ID: <44621204.4020601@cs.washington.edu> Date: Wed, 10 May 2006 09:17:08 -0700 From: Dan Grossman User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Geoffrey Alan Washburn Cc: caml-list@inria.fr Subject: Re: [Caml-list] Re: OO design References: <53c655920605050235k64e70333je8df813239ea3c53@mail.gmail.com> <20060508.121743.65190532.garrigue@math.nagoya-u.ac.jp> <200605082329.36911.David.Teller@ens-lyon.org> <445FB9C7.4040703@cs.washington.edu> <446152CB.5010605@cis.upenn.edu> In-Reply-To: <446152CB.5010605@cis.upenn.edu> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Miltered: at nez-perce with ID 4462120E.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 4462120C.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; val:01 val:01 enforces:01 monadic:01 monadic:01 ocaml:01 runtime:01 beginner's:01 ocaml:01 beginners:01 bug:01 wrote:01 wrote:01 writes:01 caml-list:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 I totally agree -- effects limit the class of protocols you can enforce, but I believe (please correct me if I've missed a dirty trick) the "simple stuff" still works fine. For example: type read; type write; type 'a file; val open_r : string -> read file; val open_w : string -> write file; val write : write file -> char -> unit; val read : read file -> char; val close : 'a file -> unit; It enforces that you don't confuse your reads and writes, but *not* that you don't use a file after you close it. A monadic approach (where each operation would return a "new" file) or linearity appears necessary for the latter. --Dan Geoffrey Alan Washburn wrote: > Dan Grossman wrote: > >> Phantom types are a programming idiom that can often pull off this >> sort of thing. > > > Maybe I'm just not smart enough, but I can't seem to think of a way > to do this in an effectful language without getting bitten by aliasing. > In a purely functional setting, a monadic approach seems plausible, but > if you can create a "ref" anywhere, as in OCaml, it seems > straightforward to subvert any uses of phantom types for implementing > protocols. I suppose one could look at it from the angle that phantom > types make it harder for cooperative users to make mistakes, but I can't > see how they can prevent the need for runtime checks. > > _______________________________________________ > Caml-list mailing list. Subscription management: > http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list > Archives: http://caml.inria.fr > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs