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=AWL 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 5E6E3BB84 for ; Sun, 22 Jun 2008 01:48:57 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ag4CAMMwXUjAXQIniGdsb2JhbACSaQEBAQ8gmnE X-IronPort-AV: E=Sophos;i="4.27,684,1204498800"; d="scan'208";a="12395435" Received: from concorde.inria.fr ([192.93.2.39]) by mail2-smtp-roc.national.inria.fr with ESMTP; 22 Jun 2008 01:48:53 +0200 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id m5LNmrvd012563 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Sun, 22 Jun 2008 01:48:53 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ag4CAMMwXUjCpx6wiGdsb2JhbACSaQEBAQ8gmnE X-IronPort-AV: E=Sophos;i="4.27,684,1204498800"; d="scan'208";a="14226025" Received: from smtpmin.univ-orleans.fr (HELO min.univ-orleans.fr) ([194.167.30.176]) by mail1-smtp-roc.national.inria.fr with ESMTP; 22 Jun 2008 01:48:52 +0200 Received: from smtps.univ-orleans.fr (localhost [127.0.0.1]) by min.univ-orleans.fr (Postfix) with ESMTP id 0AF2B12B42C; Sun, 22 Jun 2008 01:48:52 +0200 (CEST) Received: from [192.168.0.12] (ras75-4-82-235-58-110.fbx.proxad.net [82.235.58.110]) by smtps.univ-orleans.fr (Postfix) with ESMTP id 0C04136E60; Sun, 22 Jun 2008 01:48:56 +0200 (CEST) Subject: Re: [Caml-list] Polymorphic variant as a witness? From: David Teller To: Christophe TROESTLER Cc: caml-list@inria.fr In-Reply-To: <20080622.012752.1098181329612502108.Christophe.Troestler+ocaml@umh.ac.be> References: <1214089919.6190.13.camel@Blefuscu> <20080622.012752.1098181329612502108.Christophe.Troestler+ocaml@umh.ac.be> Content-Type: text/plain Date: Sun, 22 Jun 2008 01:52:11 +0200 Message-Id: <1214092331.6190.31.camel@Blefuscu> Mime-Version: 1.0 X-Mailer: Evolution 2.12.1 Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 485D9365.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; univ-orleans:01 0200,:01 christophe:01 troestler:01 0200,:01 mutable:01 camlp:01 ocaml's:01 camlp:01 semantics:01 foo:01 ocaml's:01 monads:01 variants:01 ocaml:01 On Sun, 2008-06-22 at 01:27 +0200, Christophe TROESTLER wrote: > On Sun, 22 Jun 2008 01:11:59 +0200, David Teller wrote: > > > > I could have a value (let's call it "witness") with type > > [> ] ref > > Why do you want it to be mutable? Because I know how to change the type of a reference to a polymorphic variant (the touching) -- but not the type of an immutable polymorphic variant. > > which I could "touch" into becoming > > [> `A] ref > > Are you expecting to write [touch `A witness] so [witness] becomes of > type [[> `A] ref]? If you can do with an immutable [witness], then > you can write a macro to that effet (use: [let witness' = TOUCH `A > witness]). What exactly is your purpose? Say you are developing a Camlp4-based DSL in which * file access may only be performed by some construction -- let's call it FILE * network access may only be performed by some construction -- let's call it NET. I'd like to take advantage of OCaml's type system to tell me if file access and/or network access have taken place. Now, since I'm implementing FILE and NET from within Camlp4, I can give them whichever semantics I want. For instance, FILE could mean [touch `File witness; foo] and NET could mean [touch `Net witness; bar]. If I write a program containing FILE, OCaml's type system will have inferred that the type of [witness] is [[> `File]]. Which would be great for me. Now I know I could do that with monads. I could also implement a type system for the DSL. I'm just wondering if polymorphic variants could provide an alternative. Because if they can, it may have direct applications to exception management for OCaml. > Regards, > C. Cheers, David -- David Teller Security of Distributed Systems http://www.univ-orleans.fr/lifo/Members/David.Teller Angry researcher: French Universities need reforms, but the LRU act brings liquidations.