Version française
Home     About     Download     Resources     Contact us    
Browse thread
Defining a family of functors
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Mauricio Fernandez <mfp@a...>
Subject: Re: [Caml-list] Defining a family of functors
On Thu, Jan 29, 2009 at 10:40:50AM -0000, David Allsopp wrote:
> > > On the other hand, it was pointed to me that Alain already wrote a
> > > compiler patch implementing first-class modules.
> > 
> > That's right.
> 
> I have two questions - the first of which will probably demonstrate my lack
> of skill with the OCaml module system.
> 
> 1. Does first-class modules, as with first-class functions mean that you can
> pass them around in code? For example, I have a web-app where all of the
> stuff which has to access databases is put into a single module with a known
> signature DB. I then have two modules MSSQLDriver and PGSQLDriver which
> implement the database functions for two different back-ends and have in
> DB.ml
> 
> module DB = MSSQLDriver
> include DB
> 
> So when I build for Postgres, I just change the module statement and
> recompile. Would first class modules allow me to read the back-end
> configuration from a config file and write something like:
> 
> module DB = if Config.driver = `MSSQL then MSSQLDriver else PGSQLDriver
> 
> Or is it about something totally different? :o)

See this page:

http://ocaml.janestreet.com/?q=node/29#comment-77

-- 
Mauricio Fernandez  -   http://eigenclass.org