Re: [Caml-list] Define parser and printer consistently

2010-12-09 Thread Romain Bardou

On 09/12/2010 05:47, Dawid Toton wrote:

I'm going to define a parser and a printer for a simple grammar.
Is there a way to define both of them in a single construct using some
existing OCaml tool?

For example, I have a keyword "function". The usual parser would contain
a mapping like:
"function" -> `Function
and the straightforward printer would do:
`Function -> "function"

What is the best way to combine these definitions, so that duplication
would be minimized?
To be precise, avoiding duplication is not exactly what I need. I'm
looking for something that would prevent making inconsistent changes to
the parser and the printer.


I'm writing a tool called Parsini which, maybe, does what you're looking 
for. Parsini stands either for "parsing is not interesting" (i.e.: let's 
have a tool which does it quickly for us and move on to interesting 
things such as code generation) or for "parser houdini" or something :p


From a simple grammar, the tool :
- infers and produces an AST ;
- produces an ocamlyacc source ;
- produces an ocamllex source (optional - you can use your own lexer) ;
- produces a main file with :
  * functions to read your main entries easily from a channel, a file, 
a string...

  * functions to pretty-print your AST.
Your AST is pretty-printed with the Ocaml syntax, not the syntax of your 
own language, which I do not know how to do.


I have not released the tool yet, so nothing is official nor documented 
but you might want to take a look. License will be BSD. I've copied the 
darcs repository on my website :


http://romain.bardou.fr/parsini

So you should be able to download it easily with :

darcs get http://romain.bardou.fr/parsini

Have fun,

--
Romain Bardou

___
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] New Tuareg Mode

2010-07-20 Thread Romain Bardou

Hello,

So I've updated my Debian a few weeks ago and it updated tuareg-mode. 
It's great to know that Tuareg is still maintained. I remembered seeing 
a thread here with some reproaches, about colors or something. Well I 
don't really care about colors, they have always been ugly anyway. 
However I do care about indentation and there was a modification that I 
don't really like. The following code:


let f = function
  | A ->
  1
  | B ->
  2

match x with
  | A ->
  1
  | B ->
  1

is now indented like this:

let f = function
  | A ->
1
  | B ->
2

match x with
  | A ->
1
  | B ->
1

I find it less readable. I don't care about indenting too much on the 
right : if the indentation is too large I can simply cut the code into 
several functions. Which is good practise anyway.


Problem is, I can't find a way to configure Tuareg to indent 
pattern-matching the way it did before. I tried to change everything 
related to |, with, and -> with no success.


Note that I would probably be fine with:

let f = function
| A ->
1
| B ->
2

match x with
| A ->
1
| B ->
1

although I prefer the original version.

Any idea? Now, I now that it's just a matter of taste and that it's not 
really important, so if nothing can be done, so be it.


--
Romain Bardou

___
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] Ocamldoc and Unicode characters

2010-06-04 Thread Romain Bardou

On 03/06/2010 22:29, Maxence Guesdon wrote:

Le Thu, 3 Jun 2010 16:18:43 +0200,
Daniel Bünzli  a écrit :


I see two easy solutions:


[...]

Sure they are easy but they significantly complicate one's build
system for very little.

A command line switch for this in ocamldoc would be nice and forward
looking (since the rest of the tool suite is perfectly able to deal
directly with UTF-8 encoded sources).


Agreed, but 3.12.0 is already in feature freeze. Will be for 3.12.1.


Great ! I'll just wait then :p

--
Romain Bardou

___
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] Ocamldoc and Unicode characters

2010-06-03 Thread Romain Bardou

Hello,

If I put some unicode characters inside an ocamldoc comment, it is 
copied as is, but the browser does not print them correctly because the 
page header does not say that the page is encoded using unicode.


Is there a way I can change the header of the generated pages 
automatically to change the encoding information?


Thanks,

--
Romain Bardou

___
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] Module abbreviation

2009-12-18 Thread Romain Bardou
Basile STARYNKEVITCH wrote:
> Romain Bardou wrote:
>> Basile STARYNKEVITCH wrote:
>>> Romain Bardou wrote:
>>>> Hello, dear Caml-list,
>>>>
>>>> I have a file ast.mli. It has no .ml implementation as it contains only
>>>> type definitions.
>>>
>>> Then you should name that file ast.ml. Last time I tested (more than a
>>> year ago) n ast.ml file without corresponding ast.mli file is handled as
>>> if ast.mli was the output of ocamlc -i ast.ml.
>>>
>>> Regards
>>
>> Yes, this seems to be the easiest way. It's too bad that this implies
>> having a .cmo to link against just for some type definitions, though.
> 
> 
> Why is that bad?  The *.cm[oi] files are the only ones containing the
> processed type & module information, and we obviously don't want ocamlc
> to reparse ast.mli each time it is needed.

Indeed, but a .cmi would be enough :)

Cheers,

-- 
Romain Bardou

___
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] Module abbreviation

2009-12-17 Thread Romain Bardou
Basile STARYNKEVITCH wrote:
> Romain Bardou wrote:
>> Hello, dear Caml-list,
>>
>> I have a file ast.mli. It has no .ml implementation as it contains only
>> type definitions.
> 
> 
> Then you should name that file ast.ml. Last time I tested (more than a
> year ago) n ast.ml file without corresponding ast.mli file is handled as
> if ast.mli was the output of ocamlc -i ast.ml.
> 
> Regards

Yes, this seems to be the easiest way. It's too bad that this implies
having a .cmo to link against just for some type definitions, though.

Thanks again,

-- 
Romain Bardou

___
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] Module abbreviation

2009-12-15 Thread Romain Bardou
Hello, dear Caml-list,

I have a file ast.mli. It has no .ml implementation as it contains only
type definitions.

I have a file toto.ml, which contains simply:

module A = Ast

So I only use it as an abbreviation, to write A.t instead of Ast.t for
instance.

However, at link-time, the following error occurs:

File "_none_", line 1, characters 0-1:
Error: Error while linking toto.cmo:
Reference to undefined global `Ast'

I found a workaround, which is to change ast.mli to put all type
definitions in a signature, such as:

module type Sig =
sig
  type t = ...
  ...
end

And then, in toto.ml:

module type A =
sig
  include Ast.Sig
end

Is there any better way to write such a module abbreviation, without
changing ast.mli? And, of course, without copying or renaming ast.mli
into ast.ml.

By the way, this is yet another evidence for the need of a construction
"sig of" which would take a module (with or without implementation) and
return its signature.

Thanks,

-- 
Romain Bardou

___
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] ocamlbuild documentation

2009-10-21 Thread Romain Bardou
Sam Steingold a écrit :
> Hi,
> 
> What documentation for ocamlbuild is available in in addition to
> http://brion.inria.fr/gallium/index.php/Ocamlbuild &
> http://nicolaspouillard.fr/ocamlbuild/ocamlbuild-user-guide.html?

Hello,

As far as I know there is none.

-- 
Romain Bardou

___
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] ocamlbuild and ocamlfind - using multiple grammars in a project

2009-04-08 Thread Romain Bardou

So, just tag your files, but not two files with two syntax tags.


Sorry, I meant "do not tag a single given file with two syntax tags"

--
Romain Bardou

___
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] ocamlbuild and ocamlfind - using multiple grammars in a project

2009-04-08 Thread Romain Bardou

Hans Ole Rafaelsen a écrit :

Hi

I'm trying to build a project using ocamlbuild with ocamlfind. One 
submodule requires 'json-static' and another requires 
'bitstring.syntax'. The preprocessors requires different syntaxes, 
resulting in the following error:


ocamlfind: No unique value for the META variable 'preprocessor': package 
camlp4 defines `camlp4', package bitstring.syntax defines `camlp4of'


Is there a way to make a myocamlbuild.ml file to select the preprocessor 
to use on a submodule/file basis?


Yes. In the wiki plugin, you have lines such as:

flag ["ocaml"; "compile";  "syntax_"^syntax] & S[A"-syntax"; A syntax];

This means that the "-syntax foo" option will only be added if a package 
"foo" exists AND your compiled file (i.e. ".ml") has tag "syntax_foo". 
So, just tag your files, but not two files with two syntax tags.


On a similar topic: Is it possible to tell ocamlbuild to use another 
file than myocamlbuild.ml for additional build instructions? At the 
moment I have a makefile that changes links to different files, but I'm 
not happy too with this method.


Unfortunately, not yet.

--
Romain Bardou

___
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] Question about the -dlambda option of ocamlc/ocamlopt

2009-03-25 Thread Romain Bardou

Alp Mestan a écrit :

Hi,

I'm currently studying the lambda code generation phase of the standard 
OCaml compiler.


You can take a look at this for an example : 
http://blog.mestan.fr/2009/03/22/ocaml-and-dlambda-1/


I'm wondering what is 'makeblock' for ?
And why is there '/' after every variable/function name ? 
Isn't the name sufficient for identifying variables ?


Thanks !


If I recall correctly, makeblock is for block allocation and is used to 
make empty blocks for everything that does not fit in just one integer.


The / is used to uniquely identify identifiers. In this example :

let x = 1 in let x = 2 in x

The / allows you to know which "let" variable is represented 
by the "x" at the end.


--
Romain Bardou

___
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] ocamlbuild & deps

2009-02-21 Thread Romain Bardou

Daniel Bünzli wrote:


Le 20 févr. 09 à 16:39, Romain Bardou a écrit :

I think there is a difference. It is indeed an optimization issue but 
not at the level of Ocamlbuild itself : it is as the level of your 
compilation process. If A *dynamically* depends on B, and your whole 
project (say, 10 hours of compilation) depends on A, but you have no 
way to build B, then Ocamlbuild will start to compile your project 
until it finds out that A cannot be built (maybe several hours later). 
If B had been put as a ~dep, then Ocamlbuild would not even had 
started building the project in the first place, saving you a lot of 
time.


Heu no. If B cannot be built then the compilation of A stops and the 
compilation of your project stops.


It is however true that if A has a dependency on a heavy C in parallel 
to B you'll have to wait for the end of C. But even in this case, it's 
just a matter of calling 'build' with B and C in a sensible order (and 
not in parallel).


Ok I think I did not explain correctly. Let's say that :
- A dynamically depends on B
- A depends on C
- B cannot be built
Now if I try to build A, C will be built, then the rule to build A will 
be applied and the dependency on B will be discovered. But B cannot be 
built so the compilation fails.


Now if the compilation of C takes 10 hours, you will have to wait 10 
hours no matter what. "Damn, I waited 10 hours just to discover that it 
cannot compile!" If the dependency on B was not dynamic, C would not 
have been built at all.


So, there is indeed a difference between dynamic and static 
dependencies, with or without parallelism. In fact, dynamic dependencies 
also tend to break parallelism as dynamic dependencies cannot be built 
at the same time as static dependencies. In my example, C and B cannot 
be built in parallel. This is another difference.


You cannot, in general, run the rule to discover dynamic dependencies 
before building static dependencies. Indeed, what if the rule needs to 
read one of the static dependencies to discover other dependencies?


--
Romain Bardou

___
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] ocambuild, disabling caml rules ?

2009-02-20 Thread Romain Bardou

Daniel Bünzli a écrit :

Is it possible to disable the default rules ?

I'm using ocamlbuild for a plain C project with my own rules and it is 
painfull when something fails that it fallbacks on ocaml C's compilation 
rules. These rules wil anyway fail and they override the error that 
occured with my rule that should have been used.


I don't think there is any. In fact, the rules are hard-coded in the 
source code (in ocaml_specific.ml) like this :


rule "ocaml: ml -> d.cmo & cmi" ...;;
rule "ocaml: ml -> cmo & cmi" ...;;

So there is no test, they are always ran. And there is no way to delete 
a rule AFAIK.


--
Romain Bardou

___
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] ocamlbuild & deps

2009-02-20 Thread Romain Bardou
Am I right in thinking that in rule specifications we could get rid of 
the ~dep(s) parameter of rules and have all deps be specified/discovered 
dynamically via the 'build' argument ? Otherwise stated is ~dep(s) just 
an optimization ?


Out of curiosity any idea in the cost of suppressing these arguments 
(i.e. was that road actually followed at some point) ?


If the answer to the first question is yes. Then I think the 
documentation could be made clearer by stating that what is asked to be 
built by the 'build' argument is considered as dependencies. However if 
you know some deps statically you can specify them as dep(s) argument 
this will just implicitely add  them to the list given to the 'build' 
argument.


I think there is a difference. It is indeed an optimization issue but 
not at the level of Ocamlbuild itself : it is as the level of your 
compilation process. If A *dynamically* depends on B, and your whole 
project (say, 10 hours of compilation) depends on A, but you have no way 
to build B, then Ocamlbuild will start to compile your project until it 
finds out that A cannot be built (maybe several hours later). If B had 
been put as a ~dep, then Ocamlbuild would not even had started building 
the project in the first place, saving you a lot of time.


Well, at least that's how I understand it ;)

--
Romain Bardou

___
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] ocamlbuild rules generating multiple files

2009-02-11 Thread Romain Bardou

Daniel Bünzli a écrit :

Hello,

If in a rule a command generates multiple files (which don't necessary 
have the same basename as the dep), how can I make ocamlbuild understand 
that these files now exist in _build ?


I also encountered this problem, and AFAIK there is no support yet for 
what I would call "dynamic productions". The answer of Nicolas Pouillard 
was: "hmm good question... indeed it should be added" (roughly 
translated :) ).


--
Romain Bardou

___
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: ocamlbuild documentation (was Re: [Caml-list] Re: [ANN] OCaml Batteries Included, alpha 3)

2009-02-09 Thread Romain Bardou
Indeed, it is not exactly said and should be added in the API 
documentation, but because the API documentation is not a wiki, I cannot 
do that, and neither can you. However, the "Making plugins" page of the 
wiki does contain this sentence: "This is usually done After_rules." in 
the "Manage tags" part. It is true that it does not mention explicitely 
the "flag" function, but along with the examples it should be clear 
enough. Isn't it?


Sorry, I answered too fast: "flag" is really different than "tag", so my 
answer is kind of silly here ;) However, there ARE some examples in the 
part which talks about "flag", where we clearly see an usage (After_rules).


--
Romain Bardou

___
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: ocamlbuild documentation (was Re: [Caml-list] Re: [ANN] OCaml Batteries Included, alpha 3)

2009-02-09 Thread Romain Bardou
Well I would disagree and say that the bare minimum is here. This is 
why I stopped contributing to the wiki: I had nothing else interesting 
to add. So now I ask: what exactly is missing from this bare minimum?


A text with paragraph, words and explanations, not scattered phrases and 
paragraphs without coherence. You know a structured document.


I'm actually very surprised here. If you look at the "Documentation" 
part of the index:


http://brion.inria.fr/gallium/index.php/Ocamlbuild

Except from the lists, which are, well, lists, like in an appendix, all 
pages meet what you ask. To me everything contains structure, paragraph, 
explanations, coherence, and is not scattered. Is, for instance, the 
"Solver mechanism" page really that badly written?


The "FAQ" part is not structured, but you should not need it (for "bare 
minimum" standards) except to find more plugin examples.


In my opinion, questions such as "can I use the flag function inside 
the rule function" are definitely not part of the bare minimum.


Not but maybe _when_ I'm supposed to call Plugin.flag is.

(btw, the answer is: the use of the flag function inside the rule 
function is not specified, thus not documented)


What do you mean by "not specified", your beautiful "manual" doesn't 
even tell me where/when I should call Plugin.flag.


Indeed, it is not exactly said and should be added in the API 
documentation, but because the API documentation is not a wiki, I cannot 
do that, and neither can you. However, the "Making plugins" page of the 
wiki does contain this sentence: "This is usually done After_rules." in 
the "Manage tags" part. It is true that it does not mention explicitely 
the "flag" function, but along with the examples it should be clear 
enough. Isn't it?


--
Romain Bardou

___
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: ocamlbuild documentation (was Re: [Caml-list] Re: [ANN] OCaml Batteries Included, alpha 3)

2009-02-09 Thread Romain Bardou
You need a reasonable base documentation first if you want people to try 
your system. The bare minimum (i.e. the one that doesn't make your loose 
your time with the system) is not here yet. And if you want to build 
things for others to use you better have some empathy, so you should be 
able to imagine some of these questions.

>
> What I see in the wiki doesn't qualify as a manual to me.

Well I would disagree and say that the bare minimum is here. This is why 
I stopped contributing to the wiki: I had nothing else interesting to 
add. So now I ask: what exactly is missing from this bare minimum? In my 
opinion, questions such as "can I use the flag function inside the rule 
function" are definitely not part of the bare minimum.


(btw, the answer is: the use of the flag function inside the rule 
function is not specified, thus not documented)


--
Romain Bardou

___
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: ocamlbuild documentation (was Re: [Caml-list] Re: [ANN] OCaml Batteries Included, alpha 3)

2009-02-09 Thread Romain Bardou
Is it just a matter of copy/pasting the contents of the wiki into the 
OCaml manual?


Are you serious ?


You don't have to be so mean :(

Yes, the way the plugin api works is still lagely undocumented (a random 
example is it possible to use Plugin.flag inside a rule and what would 
the effects be ? another is why is the tags argument of Plugin.rule 
deprectated and thus how can I make a rule apply only if a file has a 
given tag or maybe I shouldn't do that, etc.).


Unfortunately, while authors might be the best persons to answer these 
questions, they are also the ones who do not have any question ;) 
Finding the right questions is not easy and a Wiki is a nice way to find 
out.


There are a lot of things the authors of ocambuild know that are not in 
the wiki and that I don't want to discover by trial/error/understand the 
ocamlbuild source/consult mailling list/try to look at the wiki and I'd 
be very grateful to them if they'd share this knowledge in a 
well-written manual.


As far as I can tell it does answer a lot of the questions you 
highlighted.


Many people don't understand that very often the barrier to adoption is 
just a single, extensive source of documentation called a manual. Let me 
repeat that again, a wiki (or its content) is not a substitute for a 
manual. The whole carefully edited "big picture" documentation is 
missing and you won't get that by copy and pasting random samples from 
the wiki. We need this well-written thing called a manual that any 
respectful tool should provide, they had a good start here [1] but it is 
not sufficient as it covers only the simplest cases.


While I agree that the documentation should answer most questions, I 
fail to see how "try to look at the wiki" is different from "try to look 
at the manual". The only problem I have with the wiki is that it is not 
in the same place as the OCaml manual. Do we have to rename "wiki" into 
"manual in which you can write your own notes" ? :)


--
Romain Bardou

___
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: ocamlbuild documentation (was Re: [Caml-list] Re: [ANN] OCaml Batteries Included, alpha 3)

2009-02-09 Thread Romain Bardou
Simple projects are not the problem. The plugin interface lacks 
documentation.


Well I would like to know what "simple things" Jon could not do then.

Wikis are nice but not are no substitute for real documentation. The 
designers of ocamlbuild should once take the time to thoroughly explain 
and document the philosophy and workings of ocamlbuild; how does it 
work, what is the right way to do thing, what is the wrong way to do 
things, how do I achieve this etc.


So far every program of the caml toolchain had sufficiently clear 
documentation in ocaml's manual. With respect to that ocamlbuild is an 
unwelcomed precedent.


Is it just a matter of copy/pasting the contents of the wiki into the 
OCaml manual? Or does the wiki really lacks important information? As 
far as I can tell it does answer a lot of the questions you highlighted.


--
Romain Bardou

___
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] Re: [ANN] OCaml Batteries Included, alpha 3

2009-02-09 Thread Romain Bardou

- better integration with findlib (modules would help, and also the
possibility to use directly findlib modules from ocamlbuild modules)


I have a few patches ready for Ocamlbuild which:
- add some support for Findlib in the plugin API
- add a -pkg option (to be used instead of -lib)

I will work on what we call parameterized tags to be able to write tags 
such as use_pkg(unix). Right now I miss time but I hope that the whole 
system will be ready before 3.12.


All these should greatly improve the integration of findlib into 
Ocamlbuild. My goal is that the findlib plugin on the wiki becomes obsolete.


--
Romain Bardou

___
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] Re: [ANN] OCaml Batteries Included, alpha 3

2009-02-09 Thread Romain Bardou

So: what need to be improved?


Documentation! I tried to use ocamlbuild several times and gave up because I 
could not figure out how to do simple things.


Is the problem really the lack of documentation or a problem to find it 
because it is not on the caml.inria.fr website?


The wiki:
http://brion.inria.fr/gallium/index.php/Ocamlbuild
should answer all questions you have to compile simple projects. In 
fact, the user manual (first link on the wiki) should answer these 
questions.


It would really help to improve the documentation if you could explain 
what were the problems you encountered and where did you look for the 
documentation.


Please note that since the first OCaml meeting (last year), the wiki has 
changed quite a bit, so if you tried Ocamlbuild before, you might want 
to try it again.


--
Romain Bardou

___
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] Melt 1.0.0 released : program LaTeX documents using OCaml

2009-02-04 Thread Romain Bardou
Melt is a set of libraries and tools which allows you to program LaTeX 
documents using OCaml. This combines the typesetting power of LaTeX with 
the programming power of OCaml. It can be combined with Mlpost to 
include figures.


If you were at JFLA, it can be seen as my answer to the question "what 
about MlTeX" which was asked during the Mlpost presentation.


Melt can be download on OCamlForge:
https://forge.ocamlcore.org/projects/melt/

This is the first release of Melt. Thus, it might not be considered as 
truly stable. However, several documents, including articles and slides, 
have already been produced using Melt, so it is definitely usable.


The documentation is included in the distribution (read the README). 
Some examples can be found in the "bench" directory (see doc.mlt).


Have fun with Melt! :)

--
Romain Bardou

___
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] polymorphic variants, long form

2009-01-21 Thread Romain Bardou

Jacques Carette a écrit :

Luc Maranget wrote:

What is the proper 'long name' of a polymorphic variant?
module S = struct type a = [`Foo of int] end

How do I refer to `Foo without opening S?  Both S.`Foo and `S.Foo are 
syntax errors.


Jacques



'Foo does the job, it does not refer to any previous type definition.

% ocaml
Objective Caml version 3.11.0

# `Foo;;
- : [> `Foo ] = `Foo
  
Just  a few minutes after I sent my email, I remembered the answer 
myself: unlike normal variants, polymorphic variants are not scoped but 
affect the namespace in a GLOBAL way.  Both extremely convenient and 
non-modular at the same time.


It does not actually affect the namespace, as there is no namespace for 
polymorphic variants. All variant names can be used, anywhere, and then 
types are inferred. Your type definition S.a does not declares anything 
but S.a, which is just a type abbreviation and could be expanded to 
[`Foo of int] everywhere.


--
Romain Bardou

___
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] ocamlbuild rule with recursive action

2008-12-03 Thread Romain Bardou

Daniel Bünzli a écrit :


Le 2 déc. 08 à 12:27, DooMeeR a écrit :


Well, you can define a rule like this :


Thanks. I'll try something along these lines.

But that's kind of ugly. In the future could maybe ocamlbuild add 
another case in the command type, something like


Rec of action -> (command * bool)

Or maybe there is another way ?

Daniel


Well, you can also simply execute the commands yourself, in a loop, 
using Command.execute or Command.execute_many.


--
Romain Bardou

___
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] ocamlbuild and installed modules and libraries

2008-11-17 Thread Romain Bardou

Daniel Bünzli a écrit :


Le 16 nov. 08 à 21:37, Nicolas Pouillard a écrit :


I'm a bit uncomfortable with this kind of dynamic or special tags.

However the simplest solution to your problem is probably one of those:

 1/ ocamlbuild -cflags -I,+xmlm,xmlm.cmx test.native


You meant,


ocamlbuild -cflags -I,+xmlm -lflags -I,+xmlm,xmlm.cmx test.native



I still think using ocamlbuild with installed libraries/modules is a 
little bit problematic. If we have to do it that way [1] we are 
hard-coding the location of the library in the plugin which doesn't feel 
right.


For me there should be (1) a way of defining the dependency on a 
module/library (hopefully without needing a plugin) and (2) a way of 
defining its location (-I). These two aspects should be decoupled. This 
makes it easier to drive the installation process in build scripts by 
using environment variables, i.e. I just need
to specify the location of the module/library I depend on via a suitable 
-I $DEPDIR to compile the sources.


Isn't it almost as simple to write, in a script:
  ocamlbuild -cflags -I,$DEPDIR -lflags -I,$DEPDIR
instead of:
  ocamlbuild -I $DEPDIR
Remember that $DEPDIR must be absolute, or relative to the _build directory.

Then you can use ocamlbuild with the -lib option as usual, in a 
"decoupled" way. For instance, if bla/bla.cma is in your current directory:


$ ocamlbuild -classic-display -lib bla -cflags -I,../bla -lflags 
-I,../bla test.byte

ocamldep.opt -modules test.ml > test.ml.depends
ocamlc.opt -c -I ../bla -o test.cmo test.ml
ocamlc.opt -I ../bla bla.cma test.cmo -o test.byte

And for modules, instead of -lib bla, you write -lflags bla.cmo or 
-lflags bla.cmx. You can have several -lflags if you want. Unfortunately 
you have to specify the extension, so it is true that a -mod option 
would actually add something.


I admit, though, that it is not really easy to understand how to include 
a library. One solution would be to have findlib in ocamlbuild, but even 
then, there would be problems if you want a Makefile which is supposed 
to work also when findlib is not installed.


I think there is a recent debate about the -I option of Ocamlbuild...

--
Romain Bardou

___
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] What does Jane Street use/want for an IDE? What about you?

2008-10-23 Thread Romain Bardou

tab has no length. projects tab-indented (not talking about alignment here),
is the only consistant choice that permit everyone in this same project
to use any *representation* they want for their indentation (8 spaces, 2
spaces, 4 spaces, 11 spaces, ...) without making a mess.


Sure, this would work if you could force everyone to follow this 
convention AND that your indentations are always a multiple of the same 
number of spaces. Unfortunately, the later does not seem to hold for 
OCaml programs. For instance:


let x = List.map (fun z ->
very_long_stuff_blablablablablablablabla)

IMO this is ugly and I try to avoid this indentation style, but it is 
not always easy and it is the behavior of the Tuareg mode (OCaml mode 
for emacs), and I think the vim OCaml mode too.


--
Romain Bardou

___
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] What does Jane Street use/want for an IDE? What about you?

2008-10-23 Thread Romain Bardou

That's actually nearly what Camelia has right now. Right now Camelia
insists on not dealing with tabs at all -- it converts them all to
spaces. This "feature" has to go obviously, and it's a few-liner to
convert between characters (which include tabs) and columns.


What do you mean with this? Reason I ask is that in OcalIDE an option to
save files with spaces only, was added because it allows one to 
simultaneously edit files in various editors, each with its own tab

"length". If not, indenting is not maintained. I myself think that
avoiding tabs altogether is a good solution.


I agree.

Even without changing your editor, you can change the tab length.

Moreover, if the editor uses tabs and counts them as more than one 
character (default behavior of emacs) it won't be able to locate errors 
correctly.


Finally, when you use backspace to delete one space and suddenly it 
deletes eight of them because it was actually a tab, it's annoying 
because it's unpredictable.


Altogether, this means that if you edit a file and put tabs in it, it 
may work for you, but it may annoy the people you give your file to :p


--
Romain Bardou

___
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] Camelia progress, indenter

2008-10-21 Thread Romain Bardou

That works for me.
In future I can implement functionality similar to Visual Studio's .vcproj
files, where you can basically hand-tune the build process, all without
leaving the IDE. I have had a go at writing a proof-of-concept stand-alone
"executor" or "builder" for .vcproj files, and it's not only doable, but
the concept should be easy to duplicate and is relatively user-friendly -
certainly better than dealing with Makefiles directly, and better than
dealing with qmake's .pro files too.


I do not know .vcproj files, but if you invent some syntax to describe 
projects, it would be great if you could do it in cooperation with some 
maintainer of Ocamlbuild. This is the kind of file that could be used by 
both by an editor and by Ocamlbuild :)


--
Romain Bardou

___
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] Camelia progress, indenter

2008-10-20 Thread Romain Bardou

Kuba Ober a écrit :

I'm not sure that parsing ocamlbuild file is the right thing to do. For
a simple OCaml project (which would probably mean most Camelia
projects), there are no OCamlBuild files at all.

Mmmhhh there's .itarget (i.e. a list of files you wish generated
after compilation), but that's about it. And, again, most projects don't
have any.


OK, so I'll focuse on .itarget instead, since that's the thing that the
debugger has to cooperate with to decide what executable to run and debug.


Err... I'm not sure .itarget is what you want. It's close of what you 
want, sure, but you may have several .itarget for the same project, 
things like that.


A typical project may have:
  * some source files (.ml .mli .mly .mll);
  * several main targets (.byte .native .mllib .mlpack), that may or 
may not be put together in one or several .itarget;

  * a documentation (.odocl);
  * some special rules (_tags myocamlbuild.ml), like some libraries to use;
  * a configure script.
This is not, IMO, easily relatable to the project itself, which is 
simply a list of files...


Given a list of files, an IDE can guess interesting targets such as:
  * .docdir/index.html for each .odocl;
  * .cma .cmxa for each .mllib;
  * .cmo for each .mlpack.
But potentially every file can generate several interesting targets. For 
instance, from the file x.mlpack, one can generate x.cmo, x.cmx, x.cma, 
x.cmxa, x.mli, or even x.docdir/index.html.


IMO, simply allowing to view the whole contents of a directory is 
enough, especially thanks to the fact that ocamlbuild does not pollute 
your source directory.


--
Romain Bardou

___
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] ocamlbuild: ml -> cmx & cmi & o ?

2008-10-16 Thread Romain Bardou

There is a deep reason for this, the short answer is:

  "if you want native-compilation only, then all your .ml files must have a
  .mli"

Indeed ocamlbuild only generates .cmi from .ml using ocamlc, this is to avoid
conflicting defaulting rules in the engine.


Are conflicting rules a problem?

--
Romain Bardou

___
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] ocamlbuild: ml -> cmx & cmi & o ?

2008-10-16 Thread Romain Bardou
I observe that ocamlbuild does not build cmx cmi and o files from a ml 
file (which has no associated mli) directly.  Do others see different 
behavior?  Instead it builds cmo and cmi from the ml using ocamlc, and 
then builds the cmx and o files from there using ocamlopt.  Is there a 
reason I’m missing that ocamlbuild does not have a default rule for this 
case, using only one call to ocamlopt?  If so, is there an easy way to 
do this with a plugin?


I observe the same behavior. I think it's just a matter of reordering 
the rules in ocaml_specific.ml, as the following plug-in solves the 
problem thanks to "~insert: `top":


open Ocamlbuild_plugin

let () = dispatch begin function
  | After_rules ->
  rule "ml -> cmx"
~dep: "%.ml"
~prods: ["%.cmx"; "%.o"; "%.cmi"]
~insert: `top
begin fun env _ ->
  let ml = env "%.ml" in
  Cmd(S[!Options.ocamlopt; A "-c"; P ml])
end
  | _ -> ()
end

--
Romain Bardou

___
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] File inclusion with Ocamldoc

2008-10-15 Thread Romain Bardou

You can use .txt files to do this. Simply type ocamldoc
comment  (without (** *)) in a file.txt file and pass it to
ocamldoc like any  .ml or .mli file. This will be considered
as a File module and you can refer to it by {!File} from any
ocamldoc comment.


Excellent!  Thanks for the tip.  Incidentally, the 3.10 version
of Ocamlbuild does not support the generation of documentation
from implementation files.  Will 3.11 fix this?


It works for me with the 3.10.1. I just tried to write a file test.ml, 
and a file truc.odocl with "Test" in it, and then ran ocamlbuild :

ocamlbuild truc.docdic/index.html
And it worked. Or maybe I didn't understand what you want?

--
Romain Bardou

___
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] Ocamlfind and -a-format

2008-10-14 Thread Romain Bardou

Hello,

Is there a way to use ocamlfind to ask for the name of the cma / cmxa to 
use when using a given package ?


According to the man page of ocamlfind query, the "%a" or "%A" formats 
should give this information, but I only get an empty line. Same problem 
with the -l option which prints every relevant information about a package.


Thanks,

--
Romain Bardou

___
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] Replacing Pervasives?

2008-09-08 Thread Romain Bardou

David Teller a écrit :

Would that open anything by default?


On Mon, 2008-09-08 at 12:04 +0200, Romain Bardou wrote:

I guess you could try and make your own stdlib directory, and then
call 
ocamlc using:


ocamlc -nostdlib -I mystdlib

or something like that...



My guess is that it would try to open mystdlib/Pervasives.cmo...

In other word it's as if you changed your "official" 
stdlib/Pervasives.cmo except that it's cleanier as you don't actually 
override it (which would change your Pervasives for all your projects).


I didn't try it though, so maybe I'm missing something.

Another way to automatically open your module would be to do a weird 
Makefile such as:


%.cmo: %.ml
echo "open Myperv;;\n" > $*.temp.ml
cat $*.ml >> $*.temp.ml
ocamlc -c $*.temp.ml -o $*.cmo
rm $*.temp.ml

Or you could do this using some Ocamlbuild plug-in, or just by using the 
-ocamlc option of Ocamlbuild...


Basically, just use any hack which can replace your ocamlc by a script 
which adds "open Myperv;;\n" before calling ocamlc ^^


--
Romain Bardou

___
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] Replacing Pervasives?

2008-09-08 Thread Romain Bardou

David Teller a écrit :

Technically, I guess I can write a Camlp4 extension just to add "open
Foo" at the beginning of every file, but it seems a bit complex for such
a simple task. Any other idea?

Thanks,
 David


On Mon, 2008-09-08 at 10:06 +0200, David Teller wrote:

Dear list,

 Does anyone know how I can get a module to be auto-opened by the
compiler, in the same vein as Pervasives? I would very much prefer not
having to tweak around the source code of ocamlc for this purpose.

Thanks,
 David



I guess you could try and make your own stdlib directory, and then call 
ocamlc using:


ocamlc -nostdlib -I mystdlib

or something like that...

--
Romain Bardou

___
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] Polymorphic variant as a witness?

2008-06-23 Thread Romain Bardou

Hello,

Maybe I don't understand entirely your problem but it seems to me that 
this does what you want:


# let x = ref `A;;
val x : _[> `A ] ref = {contents = `A}
# match !x with `B -> 1 | _ -> 2;;
- : int = 2
# x;;
- : _[> `A | `B ] ref = {contents = `A}
# match !x with `C -> 1 | _ -> 2;;
- : int = 2
# x;;
- : _[> `A | `B | `C ] ref = {contents = `A}

The type of x is expanded with more and more "effects" in a modular 
fashion (thanks to the _ pattern).


In fact you do NOT want to generalize here, as generalizing would allow 
you to instantiate the type, whereas what you want is some kind of 
side-effect in the type, as far as I can understand.


Did this help or did I miss something? :)

--
Romain Bardou



David Teller a écrit :

  Dear list,

 I have been thinking for some time about using polymorphic variants to
encode some aspects of a types-and-effects type system in OCaml using
Camlp4. While the idea is still quite fuzzy, I have the feeling that, if
I could have a value (let's call it "witness") with type 
  [> ] ref
which I could "touch" into becoming 
  [> `A] ref

then
 [> `A | `B] ref
etc. as effects `A, `B, etc. appear in the program, it could provide
interesting information on the effects of the program. 


 Now, of course, I can't define a value with type ref [> ] or even with
type ref [> `dummy]. That is, when compiling a module consisting only in
a declaration such as
   let witness = ref `dummy
I'm faced with the good old "cannot be generalised" error message. This
strikes me as normal -- I'm sure that, with the right modifications on
witness, I could cause runtime type inconsistencies for any client
attempting to read the value of witness. However, in this case, I'm not
going to read any value from witness, ever. I only want to "touch" it
into becoming something a tad more complex, which I could then look at
with ocamlc -i or such.

My question is: is there a way to hijack polymorphic variants into doing
what I wish? Or to encode this behaviour somehow?

Thanks,
 David



___
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] Ocamlbuild: could help embedding Ocaml code into shared object?

2008-06-05 Thread Romain Bardou

Matthieu Dubuget a écrit :

I often deliver my work as shared objects (DLL, in fact, because I'm
stuck with Windows at work).

I would like to have ocamlbuild take care of this, but I don't know
exactly how to do it?

The idea would be to split the work in two separate rules.

The first rule generates a shared object from the Objective Caml code:

rule "mloo & cmx* -> native.oo.o"
 ~dep:"%.mloo"
 ~prod:"%.native.oo.o"
 action_for_nativecode

rule "mloo & cmo* -> byte.oo.o"
 ~dep:"%.mloo"
 ~prod:"%.byte.oo.o"
 action_for_bytecode

The actions should return commands with A "-output-obj". But I do not
know how to write them. It would need a mechanism similar to the one
used for mlpack. For example, one .mloo file listing the ocaml files to
link into the output object. Dynamic dependencies are to be generated
from the content of the .mloo file.

Unfortunately, I have no idea how to write that?

The second rule would generate a shared object from the .o files.
Maybe the current clib is enough? I have to add a flag to link
the runtime engine by adding -lasmrun -lm -ldl (-lm and -ldl being
deduced from the output of ocaml* -config).

Am I looking in the right direction?

Thanks in advance for your help

Matt


I know nothing about DLLs and OCaml but if I understand correctly, you 
need the following.


1) How to parse a file similar to a .mllib file in a plug-in. There is 
an example in the Ocamlfind plug-in on the wiki:


http://brion.inria.fr/gallium/index.php/Using_ocamlfind_with_ocamlbuild#Source

You want to look at the find_packages function.

2) How to generate dynamic dependencies. This is done by calling the 
second argument of the function you give to the rule function. This is 
also explained in the wiki:


http://brion.inria.fr/gallium/index.php/Making_plugins#Dynamic_dependencies

I hope it helps.

--
Romain Bardou

___
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