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 mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id E0643BBCA for ; Wed, 19 Mar 2008 18:44:59 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ap4BAIPt4EfY7zq/mGdsb2JhbACRAwEBAQEBCAMJCRaSV4ZJ X-IronPort-AV: E=Sophos;i="4.25,525,1199660400"; d="scan'208";a="23965801" Received: from gv-out-0910.google.com ([216.239.58.191]) by mail4-smtp-sop.national.inria.fr with ESMTP; 19 Mar 2008 18:44:59 +0100 Received: by gv-out-0910.google.com with SMTP id l14so215142gvf.4 for ; Wed, 19 Mar 2008 10:44:59 -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:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; bh=3BCj95cioRfti3/8iTIZe2ZaaU0HRrlAFlXNB60csKI=; b=o8MKcYv+geoQYnAPsoJ7qw527ue1Pcg2LOrmk3PrC62OZrN8m19VlfRs4sMs/gwH4cRMe2urwPutF2Tx5RagzuIhwEf6iXdnb8jI1Rir0NgPfjSocd5lz9cPT1RiJ/w3C+NQNR3+pYqNHb3tJR1Uxa3KX2Xlynd//KsyvGbRcro= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; b=KjSgjy4ta0I8XsxoO4zDxKhGHKfPtArZjx61panCioW40n7pa8A8ZOoVKs4siW2UXsrvhC7gMPf2GAxTMT8SVtFDmni0G4kMIOhzLm5CVlXPGg0gUdClAyr89ZOHwN1UyDNlcxRNv/gtISR6XZA/qPint0FeFC3m2dDZztdL/eE= Received: by 10.142.73.8 with SMTP id v8mr491864wfa.68.1205948698007; Wed, 19 Mar 2008 10:44:58 -0700 (PDT) Received: by 10.142.170.20 with HTTP; Wed, 19 Mar 2008 10:44:57 -0700 (PDT) Message-ID: <4a051d930803191044t1a1e9cb6h65ddbbda24cd7e1d@mail.gmail.com> Date: Wed, 19 Mar 2008 13:44:57 -0400 From: "Christopher L Conway" Sender: christopherleeconway@gmail.com To: "=?ISO-8859-1?Q?B=FCnzli_Daniel?=" Subject: Re: [Caml-list] The Bridge Pattern in OCaml Cc: "Caml Mailing List" In-Reply-To: <0A1AD394-2F3B-488E-926B-1839C7C321E6@erratique.ch> 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> X-Google-Sender-Auth: 30d71b70e0e5a684 X-Spam: no; 0.00; ocaml:01 bunzli:01 buenzli:01 existential:01 ocaml:01 datatype:01 beginner's:01 bug:01 beginners:01 wrote:01 abstract:01 syntactic:01 caml-list:01 caml-list:01 short:01 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 access > > 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/5273286711069= 7f55650778d883ae5e9.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 > >