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 mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 983F6BBCA for ; Wed, 19 Mar 2008 17:51:26 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ap4BAMzh4EdA6ba/mGdsb2JhbACRAwEBAQEBCAUHCRSSM4ZJ X-IronPort-AV: E=Sophos;i="4.25,525,1199660400"; d="scan'208";a="23963903" Received: from nf-out-0910.google.com ([64.233.182.191]) by mail4-smtp-sop.national.inria.fr with ESMTP; 19 Mar 2008 17:51:20 +0100 Received: by nf-out-0910.google.com with SMTP id e27so282967nfd.13 for ; Wed, 19 Mar 2008 09:51:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:from:to:in-reply-to:content-type:content-transfer-encoding:mime-version:subject:date:references:x-mailer:sender; bh=osQMJx4HyNMloALyAO8VUUIz1PoQXvDq09pZkM6lps4=; b=F5lRwV1CLQeHnthp4SWvPslqjtSRNZOYKZzsmD/Ib03fOQug6rJ5Fj8htdTxKj9ItcpQMxMI2yrHOwi6nb0VgMog4PprrwOGmB3MC/wNzrVOznZ5kOQ8fEFUKCsdBJAIjlKD12idHi6q9L7ykZzeRcPhu20lvC5byycR8omSPoU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=message-id:from:to:in-reply-to:content-type:content-transfer-encoding:mime-version:subject:date:references:x-mailer:sender; b=CvIQUIxlMtZGJjzZ/GiOuiiaTVcetvDp1Eb4GXBy89/7AN3w2qHzhSqYvvrhwrwHVmPSdqvqqtpG/BNVIiBrRCE3nSvPWNWzjp3KdZLDBxDVKqkKUZRqw7qAUJY2UpgFpxHt0yirDRk2YsA2OXl9axJC2ByJzMAOsGANoAT2H0k= Received: by 10.78.201.10 with SMTP id y10mr1491802huf.34.1205945478984; Wed, 19 Mar 2008 09:51:18 -0700 (PDT) Received: from ?192.168.3.139? ( [85.2.75.94]) by mx.google.com with ESMTPS id u26sm615531mug.17.2008.03.19.09.51.18 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 19 Mar 2008 09:51:18 -0700 (PDT) Message-Id: <0A1AD394-2F3B-488E-926B-1839C7C321E6@erratique.ch> From: =?ISO-8859-1?Q?B=FCnzli_Daniel?= To: Caml Mailing List In-Reply-To: <4a051d930803190929q60d31012kb6c9d2b03a2d2ca6@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed; delsp=yes Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Apple Message framework v919.2) Subject: Re: [Caml-list] The Bridge Pattern in OCaml Date: Wed, 19 Mar 2008 17:51:34 +0100 References: <4a051d930803190929q60d31012kb6c9d2b03a2d2ca6@mail.gmail.com> X-Mailer: Apple Mail (2.919.2) Sender: =?ISO-8859-1?Q?Daniel=20B=FCnzli?= X-Spam: no; 0.00; bunzli:01 buenzli:01 ocaml:01 existential:01 ocaml:01 datatype:01 abstract:01 caml-list:01 caml-list:01 short:01 caml:02 argument:02 pattern:04 pattern:04 daniel:04 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] =20= 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/52732867110697f5565= 0778d883ae5e9.en.html