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
Tools module for the Standard Lib
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-12-05 (16:39)
From: Tom Hawkins <tom@c...>
Subject: Tools module for the Standard Lib
Recently I've been reorganizing my build process for Confluence -- it's 
a hardware design language implemented in OCaml.

A few days ago a Confluence user made an interesting suggestion: why not 
use OCaml to build OCaml applications?  He then proceeded to write an 
OCaml script to generate the lexers and parsers, compile the interfaces 
and implementations, then link everything together.

Extrapolating on this idea, it would be advantageous to have a "Tools" 
module in the standard library to provide an interface to ocamlc, 
ocamlopt, ocamllex, ocamlyacc, ocamldep, and all the other tools.  Such 
a module would provide first-class ADTs for data that is currently 
represented in files: .ml, .mli, .mll, .cmi, .cmx, etc.  For example:

   let my_ml = Tools.ml_of_file "" in  (* or ... *)
   let gen_ml = Tools.ml_of_string "print_string \"hello!\"" in

With such a framework, the complexity of the build process is 
encapsulated in a program.  After your process is complete, write out 
the final executable:

   Tools.output_exe some_channel my_compiled_application

Just an idea.