You're probably trying to use functors ( http://caml.inria.fr/pub/docs/manual-ocaml/manual004.html#toc15 ). Though your example code isn't doing anything in particular. On 14 February 2012 00:33, Andre Nathan wrote: > Hello > > I have some code that behaves like the following. > > module M = struct > type ('a, 'b) ops = { > bar_of_foo : 'a -> 'b; > foo_of_bar : 'b -> 'a > } > > let foo ops x = ops.bar_of_foo x > let bar ops x = ops.foo_of_bar x > end > > type foo = A | B > type bar = C | D > > let ops = { > M.bar_of_foo = (function A -> C | B -> D); > M.foo_of_bar = (function C -> A | D -> B) > } > > let () = > match M.foo ops A with > | C -> () > | D -> () > > The idea is to parametrize the behavior of some module M on two types and > a set of operations involving these two types, with the catch that I want > to keep the ability to pattern-match on the possible values of these types > in the code that handles the return values from the functions exported by M. > > With the scheme above I can do this, but passing a table of functions > around doesn't look very nice. Is there any way I can use functors to do > what this code does, while still being able to use pattern-matching? Would > I have to resort to objects to be able to do this? > > Thanks in advance, > Andre > > -- > Caml-list mailing list. Subscription management and archives: > https://sympa-roc.inria.fr/**wws/info/caml-list > Beginner's list: http://groups.yahoo.com/group/**ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-**bugs > >