Version française
Home     About     Download     Resources     Contact us    
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: -- (:)
From: Christopher L Conway <cconway@c...>
Subject: Re: [Caml-list] The Bridge Pattern in OCaml
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/1f28b525af6b5cd446b5ccecf8ae5685.en.html

On Wed, Mar 19, 2008 at 1:44 PM, Christopher L Conway
<cconway@cs.nyu.edu> 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 = { 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ünzli Daniel
>  <daniel.buenzli@erratique.ch> wrote:
>  >
>  >  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.
>  >
>  >  Best,
>  >
>  >  Daniel
>  >
>  >  [1] http://caml.inria.fr/pub/ml-archives/caml-list/2004/01/52732867110697f55650778d883ae5e9.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
>  >
>  >
>