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.3 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 mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id 37817BBCA for ; Wed, 19 Mar 2008 19:06:02 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Aq8BAG/y4EdA6ba9kmdsb2JhbACRAwEBAQEJAwkJFJJPhko X-IronPort-AV: E=Sophos;i="4.25,525,1199660400"; d="scan'208";a="10458346" Received: from nf-out-0910.google.com ([64.233.182.189]) by mail3-smtp-sop.national.inria.fr with ESMTP; 19 Mar 2008 19:06:01 +0100 Received: by nf-out-0910.google.com with SMTP id e27so306946nfd.13 for ; Wed, 19 Mar 2008 11:06:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:sender:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; bh=hwd8RQBQEMJtvl/UHkfs9fu8A9J0h7cfo3rJmMd/AGw=; b=iMJPDLm+qAnhapsjJ8s7UH9wDjVL4ZBqtHrDEAL/xrBkjQY0JrC86JFkMz/acCZJJzX2Lwnh9BXEHQjqkylWfi8jWWo8dKfLsF9B7m5vUoMLf1lAxhphXT7nLMQnck8v8MQV4kKrdIZonq6ghZy27Tor0wTs92hwd67RPVDCWQQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=message-id:date:from:sender:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; b=qG5c84t/fBs9S3qPibkakuYklnVcw0jbDZm66I4JGnZhoK6c4fDsiPTl10JYeMLM/FAb/aVMcvhVOP6PFKjPtf4zJXjGOF9mUvOmwUXj2kB8K22J5bl4ldDurPxJ5kbG7g8RTu/DpjhRrpBWMNYm5Q/IutB1MfwSCpwAqQOuvwU= Received: by 10.78.118.5 with SMTP id q5mr1679501huc.62.1205949961009; Wed, 19 Mar 2008 11:06:01 -0700 (PDT) Received: by 10.78.156.14 with HTTP; Wed, 19 Mar 2008 11:06:00 -0700 (PDT) Message-ID: <4a051d930803191106v74fa5de3j92530c3bf15ea9d5@mail.gmail.com> Date: Wed, 19 Mar 2008 14:06:00 -0400 From: "Christopher L Conway" Sender: christopherleeconway@gmail.com To: "Caml Mailing List" Subject: Re: [Caml-list] The Bridge Pattern in OCaml In-Reply-To: <4a051d930803191044t1a1e9cb6h65ddbbda24cd7e1d@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <4a051d930803190929q60d31012kb6c9d2b03a2d2ca6@mail.gmail.com> <0A1AD394-2F3B-488E-926B-1839C7C321E6@erratique.ch> <4a051d930803191044t1a1e9cb6h65ddbbda24cd7e1d@mail.gmail.com> X-Google-Sender-Auth: c020a08b9d2393ae X-Spam: no; 0.00; ocaml:01 existential:01 ocaml's:01 existential:01 bunzli:01 buenzli:01 ocaml:01 datatype:01 beginner's:01 bug:01 eternal:98 beginners:01 wrote:01 wrote:01 abstract:01 I'll also note that this is the second time a question I posted to the list has been answered with "use existential types" [1] (aside: to my eternal shame, these two questions are basically the same and I should have seen the connection...) but there is no accessible reference I can find via Google that explains what OCaml's "existential types" are, what they do, and how a non-type-theorist would go about using them. I would write this myself, but I'm clearly not qualified. (This is no knock on your contribution Daniel. It's just that scratching one's head over clever code is no substitute for a tutorial.) Are people here using this language feature in the real world? If so, how? Regards, Chris [1] http://caml.inria.fr/pub/ml-archives/caml-list/2007/05/1f28b525af6b5cd4= 46b5ccecf8ae5685.en.html On Wed, Mar 19, 2008 at 1:44 PM, Christopher L Conway wrote: > Daniel, > > This is very clever! But I might do better to just use objects... > > Considering how stylized the declarations are in your example (i.e., > type 'a t, type 'a t_scope =3D { bind_t : 'b . 'a t -> 'b }, etc.), I > wonder if one couldn't devise some syntactic sugar? > > Chris > > > > On Wed, Mar 19, 2008 at 12:51 PM, B=FCnzli Daniel > wrote: > > > > Le 19 mars 08 =E0 17:29, Christopher L Conway a =E9crit : > > > > > > > In short, the Bridge Pattern is applicable when a client needs acce= ss > > > to operations F, G which can be provided by a variety of underlying > > > implementations X, Y, or Z. If the specific implementation isn't > > > important, you create an interface B (a "bridge") with operations F > > > and G, and write both the client and the implementations to the > > > interface B. The client should then be able to access X, Y, or Z > > > interchangeably, e.g., by taking the implementation as an argument = at > > > initialization. > > > > You need existential types. They can be encoded in ocaml, see here [1= ] > > the abstract counter datatype that does just what you describe above. > > > > Best, > > > > Daniel > > > > [1] http://caml.inria.fr/pub/ml-archives/caml-list/2004/01/5273286711= 0697f55650778d883ae5e9.en.html > > > > _______________________________________________ > > 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 > > > > >