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
How to define submodules
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jozef Kosoru <zyzstar@u...>
Subject: How to define submodules

I'm trying to split my project files into several directories but I
can't figure out how to do it right.

Let's assume the following directory structure:


and let's define the content of above files as:

~~~ Kernel/Parser/ ~~~
 let init () = print_string "hello world\n";;

~~~ ~~~
 Kernel.Parser.Pdf.init ();;


OK, and then I want to compile it (within a root directory):

	$ ocamlc -c Kernel/Parser/
	$ ocamlc -I . Kernel/Parser/pdf.cmo -o app

	File "", line 1, characters 0-22:
	Unbound value Kernel.Parser.Pdf.init

Is this supposed to work somehow?
I know that most ocaml programs use a bit cumbersome approach and they
define long file names to emulate submodules. Eg.


~~~ ~~~
 Kernel_Parser_Pdf.init ();;


And then:

	$ ocamlc -c Kernel/Parser/ 
	$ ocamlc -I . -I Kernel/Parser/ \
		Kernel/Parser/kernel_Parser_Pdf.cmo \ -o app

but that is rather inelegant.

But ANT project [1] uses this nice syntax. For
instance, there are files:


and calls:

	let pages = Engine.Evaluate.evaluate ast ...

is it some kind of language extension? I've noticed ANT uses a revised
OCaml syntax but there is no such a thing mentioned in its documentation

Thank you for any advice. Regards,


jozef kosoru