Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
The Bridge Pattern in OCaml
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2008-03-19 (16:51)
From: Bünzli_Daniel <daniel.buenzli@e...>
Subject: Re: [Caml-list] The Bridge Pattern in OCaml

Le 19 mars 08 à 17:29, Christopher L Conway a écrit :

> 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.