[Caml-list] OCamlBuild question
Hi everyone, I'm trying to write a OCamlBuild plug-in to automatically generate the .mli corresponding to a .mlpack (for documentation purposes). I've written a [rule] which lets me depend a .mli on the corresponding .mlpack . From this .mlpack, I can obtain the list of modules involved in the construction of the pack. Now, I only have to 1. find the corresponding source .mli files 2. find the corresponding .mli.depends files 3. do a topological sort and create the destination .mli . Part 3 is no problem. On the other hand, I haven't been able to progress much with parts 1 and 2. Part 2 requires waiting until the corresponding .mli.depends have been created, but * neither [~insert:`bottom] nor [~insert:(`after foo)] seem to help here * attempting to [build] an ad-hoc list of files somehow extracted from the mlpack only gives me dependency errors * attempting [Solve.solve_target] doesn't seem to help any further. As for part 1, it requires the ability to find which source .ml / .mli correspond to a given module. I can only assume OCamlBuild offers some kind of API for this purpose, because I'd rather avoid folding through the whole tree, resolving [include] directives myself to find a .ml or a .mli which may be the right file. Does anyone have suggestions? Thanks, David -- David Teller-Rajchenbach Security of Distributed Systems http://www.univ-orleans.fr/lifo/Members/David.Teller Angry researcher: French Universities need reforms, but the LRU act brings liquidations. ___ 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
[Caml-list] Re: OCamlBuild question
Excerpts from david.teller's message of Tue Sep 30 09:27:11 +0200 2008: > Hi everyone, > I'm trying to write a OCamlBuild plug-in to automatically generate > the .mli corresponding to a .mlpack (for documentation purposes). > > I've written a [rule] which lets me depend a .mli on the > corresponding .mlpack . From this .mlpack, I can obtain the list of > modules involved in the construction of the pack. Now, I only have to > 1. find the corresponding source .mli files > 2. find the corresponding .mli.depends files > 3. do a topological sort and create the destination .mli . > > Part 3 is no problem. On the other hand, I haven't been able to progress > much with parts 1 and 2. > > Part 2 requires waiting until the corresponding .mli.depends have been > created, but > * neither [~insert:`bottom] nor [~insert:(`after foo)] seem to help here > * attempting to [build] an ad-hoc list of files somehow extracted from > the mlpack only gives me dependency errors > * attempting [Solve.solve_target] doesn't seem to help any further. If you need (depend) on files that you statically know then the ~deps argument is fine (~deps:["%.mli.depends"; "%.mli"]). If you need files that you only know dynamically then the 'build' argument function is for that purpose. > As for part 1, it requires the ability to find which source .ml / .mli > correspond to a given module. I can only assume OCamlBuild offers some > kind of API for this purpose, because I'd rather avoid folding through > the whole tree, resolving [include] directives myself to find a .ml or > a .mli which may be the right file. Yes the function is called expand_module it takes 3 arguments, the include directories, the module name, the extensions. Example: let include_dirs = Pathname.include_dirs_of (Pathname.dirname mlpack) in build (expand_module include_dirs module_name ["mli"; "mli.depends"]) Have a look to the ocamlbuild/ocaml_tools.ml file for a similar function (import_mlypack). -- Nicolas Pouillard aka Ertai signature.asc Description: PGP signature ___ 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
[Caml-list] Random number generator
Hello! Do You maybe have any idea how good is the standard RNG from random.ml module? I know that it's quite fast but what about the quality of generated numbers? I've tried implementing various random number generators for the whole yesterday but I couldn't bypass ocaml's int limitations. Almost everything bases on unsigned integers (0..2^32-1) so despiting the fact my range is half of that (using Int32) I'm having troubles when integer overflows... I would like to implement combined MWC (multiple with carry) algorithm based on 2 x 16bit mwc's. I'ts very easy (at last in c/c++ where i can use unsigned ints), fast and according to what I've read it's generating very nice random numbers. It goes like this: z = w= some seeds (big numbers) z = 36969 * (z & 65535) + (z >> 16) w = 18000 * (w & 65535) + (w >> 16) return ( (z << 16) + (w & 65535) ) // combining two 16 bit numbers to one 32 bit but i cant think of anything by myself, i mean i could use some "abs" or something but i doubt it wouldn't ruin the whole algorithm. P.S. some time ago I promised that I will keep you informed how my ray- tracer will do, here it is: http://neos1.blogspot.com ___ 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
Re: [Caml-list] Random number generator
It apparently [1] passed the die hard test so it should be pretty solid. Now here comes the warning: one can only prove that PRNG are bad, withstanding the test of time is the best hint fir quality. Random numbers are a tricky subject; if you are using them for your ray tracer a low-discrepancy sequence[2] might prove a better match. Till [1]http://groups.google.com/group/fa.caml/browse_thread/thread/eb5ba7eef6e43066 [2]http://en.wikipedia.org/wiki/Low-discrepancy_sequence On Tue, Sep 30, 2008 at 2:17 PM, Michał C <[EMAIL PROTECTED]> wrote: > Hello! > > Do You maybe have any idea how good is the standard RNG from random.ml > module? I know that it's quite fast but what about the quality of generated > numbers? > > I've tried implementing various random number generators for the whole > yesterday but I couldn't bypass ocaml's int limitations. Almost everything > bases on unsigned integers (0..2^32-1) so despiting the fact my range is > half of that (using Int32) I'm having troubles when integer overflows... > > I would like to implement combined MWC (multiple with carry) algorithm based > on 2 x 16bit mwc's. I'ts very easy (at last in c/c++ where i can use > unsigned ints), fast and according to what I've read it's generating very > nice random numbers. > > It goes like this: > > z = w= some seeds (big numbers) > > z = 36969 * (z & 65535) + (z >> 16) > w = 18000 * (w & 65535) + (w >> 16) > return ( (z << 16) + (w & 65535) ) // combining two 16 bit > numbers to one 32 bit > > > but i cant think of anything by myself, i mean i could use some "abs" or > something but i doubt it wouldn't ruin the whole algorithm. > > P.S. > some time ago I promised that I will keep you informed how my ray-tracer > will do, here it is: > http://neos1.blogspot.com > > ___ > 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 > -- http://till-varoquaux.blogspot.com/ ___ 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
[Caml-list] Re: OCamlBuild question
Merci, avec ces explications, je suis enfin arrivé à faire fonctionner [build]. Maintenant, reste un problème tout bête : j'arrive à écrire le contenu de mon .mli dans _build mais pour des raisons qui m'échappent, celui-ci est effacé avant la fin de la compilation. J'ai essayé de l'ouvrir avec [open_out] et avec [with_output_file], avec le même résultat. C'est assez frustrant. Des idées ? Merci, David On Tue, 2008-09-30 at 12:40 +0200, Nicolas Pouillard wrote: > If you need (depend) on files that you statically know then the ~deps argument > is fine (~deps:["%.mli.depends"; "%.mli"]). If you need files that you only > know dynamically then the 'build' argument function is for that purpose. > > > As for part 1, it requires the ability to find which source .ml / .mli > > correspond to a given module. I can only assume OCamlBuild offers some > > kind of API for this purpose, because I'd rather avoid folding through > > the whole tree, resolving [include] directives myself to find a .ml or > > a .mli which may be the right file. > > Yes the function is called expand_module it takes 3 arguments, the include > directories, the module name, the extensions. > >Example: let include_dirs = Pathname.include_dirs_of (Pathname.dirname > mlpack) > in build (expand_module include_dirs module_name ["mli"; > "mli.depends"]) > > Have a look to the ocamlbuild/ocaml_tools.ml file for a similar function > (import_mlypack). > -- David Teller-Rajchenbach Security of Distributed Systems http://www.univ-orleans.fr/lifo/Members/David.Teller Angry researcher: French Universities need reforms, but the LRU act brings liquidations. ___ 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
[Caml-list] Re: OCamlBuild question
Merci, avec ces explications, je suis enfin arrivé à faire fonctionner [build]. Maintenant, reste un problème que je n'arrive pas à comprendre : mon fichier disparaît. Pour être plus précis, j'écris le contenu de mon .mli dans un fichier que j'ai créé pour l'occasion, à l'intérieur de _build -- mais pour des raisons qui m'échappent, ocamlbuild trouve moyen de l'effacer avant la fin de la compilation. J'ai vérifié, une fois que j'ai écrit mon fichier, il existe bien. J'ai aussi vérifié, si je place mon fichier dans /tmp au lieu de _build, ça marche. J'ai aussi vérifié, si je remplace l'extension de mon .mli par .mlpack.mli, ça ne change rien. J'ai essayé de l'ouvrir avec [open_out] et avec [with_output_file], avec la même absence de résultats. Ah, et pour compliquer les choses, ça ne marche pas quand j'appelle ocamlbuild une seule fois. Mais il arrive que, si j'invoque ocamlbuild deux fois de suite, ça se mette à marcher. C'est assez frustrant. Des idées ? Merci, David On Tue, 2008-09-30 at 12:40 +0200, Nicolas Pouillard wrote: > If you need (depend) on files that you statically know then the ~deps argument > is fine (~deps:["%.mli.depends"; "%.mli"]). If you need files that you only > know dynamically then the 'build' argument function is for that purpose. > > > As for part 1, it requires the ability to find which source .ml / .mli > > correspond to a given module. I can only assume OCamlBuild offers some > > kind of API for this purpose, because I'd rather avoid folding through > > the whole tree, resolving [include] directives myself to find a .ml or > > a .mli which may be the right file. > > Yes the function is called expand_module it takes 3 arguments, the include > directories, the module name, the extensions. > >Example: let include_dirs = Pathname.include_dirs_of (Pathname.dirname > mlpack) > in build (expand_module include_dirs module_name ["mli"; > "mli.depends"]) > > Have a look to the ocamlbuild/ocaml_tools.ml file for a similar function > (import_mlypack). > -- David Teller-Rajchenbach Security of Distributed Systems http://www.univ-orleans.fr/lifo/Members/David.Teller Angry researcher: French Universities need reforms, but the LRU act brings liquidations. ___ 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