Re: [Caml-list] ifprint and format type question
Excerpts from Brian Hurt's message of Wed Apr 23 22:42:45 +0200 2008: > So, I'm trying to write code like (simplifying): > > let my_output (_: string) = ();; (* the real code is much more > complicated but not relevant *) > > let foo b fmt = > if not b then >Printf.ifprintf () fmt > else >Printf.ksprintf my_output fmt > ;; ifprintf works well with fprintf let foo b fmt = if not b then Printf.ifprintf oc fmt else Printf.fprintf oc fmt ;; Otherwise using Format.ifprintf could help due to its generalized notion of formatter. > The problem is that the above code doesn't compile- ifprintf wants fmt > to be ('b, unit, unit) format = ('b, unit, unit, unit) format4, while > ksprintf wants it to be ('b, unit, string, 'a) format4. Now, I could do > the above like: > > let foo b fmt = > Printf.ksprintf (fun s -> if b then my_output s) fmt > > but the point and purpose of using ifprintf is to avoid the cost of > converting the arguments to strings that are just going to be thrown away. Yes this defeats the purpose. > So, my questions are: > > 1: is there a way to make this work without using Obj.magic or > rewritting isprintf? With Printf.ksprintf I would say no. > 2: is there a reason ifprintf has the type 'a -> ('b, 'a, unit) format > -> 'b, instead of ('b, 'a, 'c) format -> 'b, or better yet ('b, 'a, 'c, > 'd) format4 -> 'b, or even better yet ('b, 'a, 'c, 'd, 'e, 'f) format6 > -> 'b (allowing it to unify with more different formats)? Hum there perhaps room for a more general ifprintf. > 3: Does ifprintf actually avoid the cost of converting it's arguments to > strings? The code is unclear. If the answer to this is 'no', the other > two questions are moot. Yes it does avoid the cost of converting it's arguments. -- 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
Re: [Caml-list] Two camlp4 questions
Excerpts from Richard Jones's message of Fri Apr 25 15:18:12 +0200 2008: > (1) How do I match on the pattern which is literally '_' in the > original code? > > match mypatt with > | <:patt< _ >> -> ... > > seems like it matches any pattern. I don't think so, it's supposed to match only the wildcard pattern. Proof: $ camlp4oof -str 'match x with <:patt< _ >> -> y' match x with | Ast.PaAny _ -> y -- 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
Re: [Caml-list] Help for Camlp4: Pcaml.input_file for 3.10?
Excerpts from Loup Vaillant's message of Tue May 06 11:57:41 +0200 2008: > Hello, Hi, > I would like to know if there is any equivalent > of Pcaml.input_file in Ocaml 3.10's Camlp4. > I tried to search the wiki, but with no luck so far. > > Pcaml.input_file were used for an #include like functionality. If I clearly remember this ugly global variable has been removed. -- 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
Re: [Caml-list] Help for Camlp4: Pcaml.input_file for 3.10?
Excerpts from Loup Vaillant's message of Tue May 06 18:10:13 +0200 2008: > 2008/5/6 Nicolas Pouillard <[EMAIL PROTECTED]>: > > Excerpts from Loup Vaillant's message of Tue May 06 11:57:41 +0200 2008: > > > > > > I would like to know if there is any equivalent > > > of Pcaml.input_file in Ocaml 3.10's Camlp4. > > > I tried to search the wiki, but with no luck so far. > > > [...] > > > > If I clearly remember this ugly global variable has been removed. > > OK, I got it, thank you for the fast response. > > Now, I can have the name of the preprocessed file with _loc. > > But How can I include a file in another? More generally, do we have a > substitute for it? Have a look at the Camlp4MacroParser syntax extension it provides an INCLUDE directive. -- 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
Re: [Caml-list] camlp4 - can you customize the lexer?
Excerpts from Richard Jones's message of Fri May 09 11:40:36 +0200 2008: > > The Camlp4 wiki contains an intriguing line "Connecting your own > Lexer.", but no link or information. I want to modify the OCaml lexer > to add a syntax for integer literals of my own type. Can this be > done? How? Since Camlp4, is now a lot more modular. This can be done by providing *another* Lexer module with a compatible signature. Then one create a new Camlp4.PreCast module by copy/pasting and using the new Lexer module. However the default lexer of Camlp4 is not extensible. Best regards, -- 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
Re: [Caml-list] ocamlbuild -> toplevel
Excerpts from matthieu.dubuget's message of Fri May 16 05:05:45 +0200 2008: > Hello, > > playing with ocamlbuild, I manage to produce one "my.top" toplevel by > filling "my.mltop" with some module names (cmo), and asking for: > ocamlbuild my.top. > > Now, instead of building a toplevel with cmo files, I would like to > build one with libraries (cma). > Is there any way to do this with ocamlbuild? .mllib Best regards, -- 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
Re: [Caml-list] ocamlopt, .cmxa and "not a compilation unit description" error Options
Excerpts from Charles Hymans's message of Tue Jun 10 20:15:13 +0200 2008: > Hi, > > I'd like to generate a library from a file that uses the nums library > (in a way such that the final user of my library does not have to > specify that nums is necessary). > > I was able to generate a .cma with the following command: > ocamlc -a nums.cma file.ml -o lib.cma > > However to generate a .cmxa, the command: > ocamlopt -a nums.cmxa file.ml -o lib.cmxa > > fails and reports the error that "nums.cmxa is not a compilation unit > description." In byte-code libraries can contains libraries, but not in native code. -- 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
Re: [Caml-list] Ocamlbuild_config
Excerpts from matthieu.dubuget's message of Mon Jun 23 12:55:56 +0200 2008: > Hello, > > during installation, one Caml module named Ocamlbuild_config is created > (at least when the ocamlbuild method is used). > > Is this module installed anywhere, and are the values listed in it > accessible from an ocamlbuild plugin? Not it is not installed. > That would avoid to call ocamlc or ocamlopt and parse results. Yes but this would add an extra effort about the maintainability of this file. -- 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
Re: [Caml-list] A question about the ocaml man page
Excerpts from Stefano Zacchiroli's message of Sun Jun 22 15:28:46 +0200 2008: > On Fri, Jun 20, 2008 at 05:30:09PM +0100, Richard Jones wrote: > > /me laughs :-) > > > > camlp4 is ... how shall I put this ... very very powerful, but also > > only 'lightly' documented. The situation has slightly improved with > > the camlp4 wiki (http://brion.inria.fr/gallium/index.php/Camlp4) but > > /me laughs too :-) > > The camlp4 wiki is ... mumble ... very useful, but also managed in a way > which is far from the wiki way. I've in the past tried at least twice to > get an account to contribute some documentation collected from this > mailing list after exchanges with Nicolas. Net result: no account > created -> no documentation contributed. I've just checked my e-mails, and I have no trace of your requests. All (16) requests for accounts have received have been successfully treated, and I don't know what happens to your requests. If you still want an account please send me the login you want by email. Cheers, -- 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
Re: [Caml-list] A question about the ocaml man page
Excerpts from Stefano Zacchiroli's message of Mon Jun 23 14:50:58 +0200 2008: > On Mon, Jun 23, 2008 at 01:59:16PM +0200, Nicolas Pouillard wrote: > > I've just checked my e-mails, and I have no trace of your requests. > > > > All (16) requests for accounts have received have been successfully treated, > > and I don't know what happens to your requests. > > Here is the Message ID: <[EMAIL PROTECTED]>, From > [EMAIL PROTECTED] to your gmail address, quoting from that: > > > Ok :), and many thanks for your info Nicolas. > > ... but, am I wrong, or user creation on the Gallium wiki is disabled? > > When I click on the login link I see no option for creating a new > > account; I've also trying crafting the URL for the user creation in ways > > similar to other Mediawiki installation, but also that is not working. > > which seems still to be true. Anyhow ... You're right, I've this e-mail, but I've read it as a criticism and not a request for account. > > If you still want an account please send me the login you want by email. > > "zack" if available, "zacchiro" otherwise. Thanks! Done. -- 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
Re: [Caml-list] Custom lexer in Camlp4
Excerpts from Jeremy Yallop's message of Tue Jun 24 15:03:19 +0200 2008: > Is there a way to replace the default lexer in Camlp4? I'd like to use > (an extended version of) one of the OCaml grammars, but with a different > lexer. You can rebuild (I mean functor application), your own camlp4 by giving another Lexer module. Basically you will have to copy/paste the short Camlp4.PreCast module (or a part of), by substituting Camlp4.Struct.Lexer by your Lexer implementation. That's fairly heavy but works. Regards, -- 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
Re: [Caml-list] Custom lexer in Camlp4
Excerpts from Jeremy Yallop's message of Tue Jun 24 16:30:23 +0200 2008: > Nicolas Pouillard wrote: > > Excerpts from Jeremy Yallop's message of Tue Jun 24 15:03:19 +0200 2008: > >> Is there a way to replace the default lexer in Camlp4? I'd like to use > >> (an extended version of) one of the OCaml grammars, but with a different > >> lexer. > > > > You can rebuild (I mean functor application), your own camlp4 by giving > > another Lexer module. Basically you will have to copy/paste the short > > Camlp4.PreCast module (or a part of), by substituting Camlp4.Struct.Lexer > > by your Lexer implementation. That's fairly heavy but works. > > Ok, I've built a slightly modified clone of PreCast. What's the best > way to persuade Camlp4 to use it? The original PreCast seems fairly > hardwired, e.g. in the Register module. Hum, you can't you have to build your own camlp4 driver :( -- 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
Re: [Caml-list] Custom lexer in Camlp4
Excerpts from Hezekiah M. Carty's message of Tue Jun 24 17:43:52 +0200 2008: > On Tue, Jun 24, 2008 at 11:16 AM, Richard Jones <[EMAIL PROTECTED]> wrote: > > On Tue, Jun 24, 2008 at 03:30:23PM +0100, Jeremy Yallop wrote: > > On a related note I had a crazy brainwave that we could use camlp4 to > > use 'ordinary' operators in an overloaded context. Something like: > > > > INT64 (2L * n / 3L) > > > > The INT64(expr) macro would inspect the AST of expr and change + -> > > Int64.add etc. Of course one can do this using the pa_openin macro > > and a module which overrides (+) etc, but maybe this is better? I was > > going to try modifying parts of virt-df to use this syntax to see if > > it would be beneficial. > > I toyed around with a simple extension to the pa_float example on the > camlp4 wiki. The modified version is here: [...] > Sadly camlp4 3.10+ does not play well with the toplevel, so these are > difficult to work with interactively. I do use pa_context in several > places though, and it seems to work well. Can you elaborate on that? -- 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
Re: [Caml-list] Custom lexer in Camlp4
Excerpts from Jeremy Yallop's message of Wed Jun 25 13:53:02 +0200 2008: > Nicolas Pouillard wrote: > > Excerpts from Jeremy Yallop's message of Tue Jun 24 16:30:23 +0200 2008: > >> Nicolas Pouillard wrote: > >>> Excerpts from Jeremy Yallop's message of Tue Jun 24 15:03:19 +0200 2008: > >>>> Is there a way to replace the default lexer in Camlp4? I'd like to use > >>>> (an extended version of) one of the OCaml grammars, but with a different > >>>> lexer. > >>> You can rebuild (I mean functor application), your own camlp4 by giving > >>> another Lexer module. Basically you will have to copy/paste the short > >>> Camlp4.PreCast module (or a part of), by substituting Camlp4.Struct.Lexer > >>> by your Lexer implementation. That's fairly heavy but works. > >> Ok, I've built a slightly modified clone of PreCast. What's the best > >> way to persuade Camlp4 to use it? The original PreCast seems fairly > >> hardwired, e.g. in the Register module. > > > > Hum, you can't you have to build your own camlp4 driver :( > > Thanks, Nicolas. That's useful to know. > > The solution I've adopted for now is to change the default quotation > expander to a function that just slots in my lexer before calling the > original expander. This means that I can use my custom lexical syntax > inside the << >> delimiters and I can use those delimiters either around > the whole program or around a particular term. I think this'll be fine > for my needs, although it would be nice to be able to customize the > lexer that's used for regular code as well. You've followed a reasonable approach, where one use quotations to embed a "foreign" language in the sense that it even doesn't share the same lexical conventions. However your right that changing the lexer should be doable. -- 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
Re: [Caml-list] camlp4 parser accepts more than its grammar?
Excerpts from Jake Donham's message of Thu Jun 26 23:10:20 +0200 2008: > Hi list, > > I expected the following program to fail with a parse error, but it > happily ignores the extra '+'. I would be grateful if someone could > point out what I'm doing wrong. Thanks, Nothing wrong from you, that's a camlp4 known bug (PR#4551, PR#4513...). > open Camlp4.PreCast;; > > let expr = Gram.Entry.mk "expr";; > let stmt = Gram.Entry.mk "stmt";; > > EXTEND Gram > expr: [[ > x = expr; "+"; y = expr -> x + y > | x = INT -> int_of_string x > ]]; > stmt: > [[ e = expr; ";"; `EOI -> e ]]; > END;; > > prerr_endline (string_of_int (Gram.parse_string stmt Loc.ghost "2 + 1 + ;")) > -- 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
Re: [Caml-list] CamlP4 lexer problem
Excerpts from dream.designer's message of Mon Jun 30 21:24:30 +0200 2008: > Yes, seems so, but is there a way to make it think otherwise? Not really. > 2008/6/30 Richard Jones <[EMAIL PROTECTED]>: > > > On Mon, Jun 30, 2008 at 08:46:57PM +0300, dream.designer wrote: > > > # ([% 5 %]) ;; > > > Characters 6-9: > > > ([% 5 %]);; > > > ^^^ > > > Parse error: [expr level simple] expected after "[%" (in [expr]) > > > > Is it not just the case that the scanner thinks %]) is a single token? > > > > Rich. > > > > -- > > Richard Jones > > Red Hat > > > -- 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
Re: [Caml-list] Disappointment
Excerpts from Paolo Donadeo's message of Mon Jul 21 23:28:36 +0200 2008: > I'm disappointed with myself and my incredibly low IQ. Late this > evening I decided -- and this is the third time -- to be enlightened > by the concept of monad. > > I like functional programming, but monads [1] must be too little to be > grabbed by my mind. This time the interest in monads was aroused by > the interesting article of David Teller, Arnaud Spiwack and Till > Varoquaux [2] about the error monad, but for using the library they > wrote I need at least some knowledge about monads and the do-notation. > > I tried with some tutorials found around, but I still cannot catch the > point: what the hell is a monad? Two key points that helped me: * Monads help to separate some plumbing from your code. * Monads provide a way to abstract code over some "let" construct. I will note that specific "let" construct "let!", it's somewhat like the do-notation but more atomic. Monads also come with "return", but that's not the essence of them. Think about that example: val div : int -> int -> int option val square : int -> option let f x y = match div x y with | None -> None (* here 'y' was equal to 0 *) | Some z -> match square z with | None -> None | Some x2 -> Some x2 In the previous example the plumbing is error handling (where errors are represented by None), and the "let!" construct is: let! x = e1 in e2 ===> match e1 with None -> None | Some x -> e2 And "return" is "Some". Another similar example: type ('a,'b) either = Left of 'a | Right of 'b val div : int -> int -> (string, int) either val square : int -> (string, int) either let f x y = match div x y with | Left error_msg -> Left error_msg | Right z -> match square z with | Left error_msg -> Left error_msg | Right x2 -> Right x2 Here the plumbing is still there for "error handling", but is somewhat different. The "let!" construct is: let! x = e1 in e2 ===> match e1 with Left m -> Left m | Right x -> e2 And "return" is "Right". Finally one could have used the "let!" construct abstractly (and also "return"). let f x y = let! z = div x y in let! x2 = square z in return x2 One can obtain the two previous versions by choosing which "let!"/"return" we want, namely choosing the monad. Hope that helps, -- 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
Re: [Caml-list] OCaml and Matlab
Excerpts from Till Crueger's message of Thu Jul 24 10:47:51 +0200 2008: > Hi, > > I am currently trying to get OCaml and Matlab to work together. I found > OCamlMex on the Caml-Hump > (http://caml.inria.fr/cgi-bin/hump.en.cgi?contrib=400). > However when I try to compile it, I get an error: > > ocamlc.opt -c -pp "camlp4r " -I /usr/lib64/ocaml/camlp4 mex.mli > File "mex.mli", line 235, characters 15-17: > Unbound type parameter 'a > make[2]: *** [mex.cmi] Fehler 2 > make[2]: Leaving directory `/home/till/ocamlmex-2.0.1/src' > make[1]: *** [byte-code-library] Fehler 2 > make[1]: Leaving directory `/home/till/ocamlmex-2.0.1/src' > make: *** [all] Fehler 2 > > The line mentioned in the error looks like this: > > type mxArray = 'a; > (** The basic type for all the external data inside Matlab : a mxArray > can be a numeric array, a cell array, a struct array, or other kind of > data see mxClassID *) > > So I am not at all surprised, that it won't work, because the 'a actually > is unbound. Was this maybe possible with older versions of the compiler, > or are there some workarounds, to get it working again? That's a syntactic over the revised syntax of abstract types, now abstract types are like in the original syntax: type mxArray; -- 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
Re: [Caml-list] OCaml and Matlab
Excerpts from Till Crueger's message of Thu Jul 24 22:40:59 +0200 2008: > On Thu, 24 Jul 2008 11:23:27 +0200, Nicolas Pouillard > <[EMAIL PROTECTED]> wrote: > > >> So I am not at all surprised, that it won't work, because the 'a > >> actually > >> is unbound. Was this maybe possible with older versions of the compiler, > >> or are there some workarounds, to get it working again? > > > > That's a syntactic over the revised syntax of abstract types, now > > abstract > > types are like in the original syntax: > > > > type mxArray; > > Ok, that was also my first guess, that occured to me afterwards. So I > changed it to normal abstract types and fixed the .mli file. However, the > problem still remains, because the types are the same way in the actuall > implementation file. So it seems like there is more at work here, because > abstract types are not possible in .ml files, or are they? They are. -- 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
Re: [Caml-list] ocamlc: how to keep sources and objects in different directories?
Excerpts from Roberto Bagnara's message of Wed Aug 13 09:32:51 +0200 2008: > Vincent Hanquez wrote: > > On Tue, Aug 12, 2008 at 07:03:06PM +0200, Roberto Bagnara wrote: > >> Hi there, > >> > >> it seems that `ocamlc' wants to create the .cmo file in the same > >> directories as the .ml file. More specifically I observe this: > >> > >> $ ocamlc -g -c -I +gmp -I ../../../interfaces/OCaml > >> ../../../interfaces/OCaml/ppl_ocaml_types.ml > >> I/O error: ../../../interfaces/OCaml/ppl_ocaml_types.cmo: Permission denied > >> > >> The ../../../interfaces/OCaml directory is read-only: > >> is there an option causing `ocamlc' to write the .cmo > >> file in the current directory instead? > > > > you can use "-o ./ppl_ocaml_types.cmo" > > Thanks Vincent, but it does not work: > > $ ocamlc -g -c -I +gmp -I ../../../interfaces/OCaml > ../../../interfaces/OCaml/ppl_ocaml_types.ml > I/O error: ../../../interfaces/OCaml/ppl_ocaml_types.cmo: Permission denied > $ ocamlc -g -c -I +gmp -I ../../../interfaces/OCaml > ../../../interfaces/OCaml/ppl_ocaml_types.ml -o ./ppl_ocaml_types.cmo > I/O error: ../../../interfaces/OCaml/ppl_ocaml_types.cmo: Permission denied > $ ocamlc -version > 3.10.1 > > Any other idea? The -o option should be before the .ml. Regards, -- 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
Re: [Caml-list] Haskell vs OCaml
Excerpts from Jon Harrop's message of Thu Aug 14 15:57:47 +0200 2008: > On Thursday 14 August 2008 12:50:43 blue storm wrote: ... > > and Haskell is faster than most (scripting) languages used these days > > anyway). > > Despite being written in Python, Mercurial is orders of magnitude faster than > Darcs. The difference of performances between Darcs and Mercurial is 99% due differences in algorithms not in the implementation language. So this comparison does not make sense! -- 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
Re: [Caml-list] Haskell vs OCaml
Excerpts from Jon Harrop's message of Thu Aug 14 23:16:26 +0200 2008: > On Thursday 14 August 2008 21:57:59 you wrote: > > Excerpts from Jon Harrop's message of Thu Aug 14 15:57:47 +0200 2008: > > > On Thursday 14 August 2008 12:50:43 blue storm wrote: > > > > and Haskell is faster than most (scripting) languages used these days > > > > anyway). > > > > > > Despite being written in Python, Mercurial is orders of magnitude faster > > > than Darcs. > > > > The difference of performances between Darcs and Mercurial is 99% due > > differences in algorithms not in the implementation language. So this > > comparison does not make sense! > > Only if the choice of algorithm was independent of the language, which is > rarely the case. > > For example, Fortran programmers use arrays when they are unsuitable and > their > programs can be slower than scripting languages as a consequence. That is > Fortran's fault. > > Does the Darcs implementation overuse singly linked lists because they are > more accessible? Are the reported stack overflows indicative of this? I don't > know but I certainly wouldn't rule it out as a possibility. I'm talking about the informal algorithms, their independent of that kind of things... -- 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
Re: [Caml-list] ocamlbuild and pack
Excerpts from johannes.kanig's message of Tue Sep 09 15:38:04 +0200 2008: > Hi List, > > I have the following problem. I have three files, each consisting of one > line: > > a.ml: type t = float > b.ml: type t = A.t > c.ml: include B > > Now I want to put these modules into a pack, but I only want to export A and > C, so I write a file project.mli: > module A : sig type t end > module C : sig type t = A.t end > > As I want to use ocamlbuild, I also create a file project.mlpack: > A > C B should be in the pack even if you want to hide it. > Now, the command "ocamlbuild project.cmo" works fine, but I can't build a > library from that: > ocamlbuild project.cma > Circular dependencies: "project.cmo" already seen in > [ "b.cmo"; "project.cmo" ] > > There clearly aren't any circular dependencies, are there? Am I missing > something? B depends on A, but A is in the pack Project. {B|->Project} Project includes C, that depends on B. {Project->B} > The problem goes away if I export B instead of C. So the troublemaker seems > to be the include directive. In that case: * A is in Project {} * B depends on A that is in Project, but B is also in Project {} * C depends on B that is in Project {C->Project} No cycle in this one -- 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
Re: [Caml-list] Camlp4. print variable value to target source.
Excerpts from SerP's message of Thu Sep 11 14:15:59 +0200 2008: > On Thu, 2008-09-11 at 13:00 +0100, Jeremy Yallop wrote: > > Quoting ?? ??? <[EMAIL PROTECTED]>: > > > Exitst any way to do such things? > > > > > > -- > > > let t = <:ctyp> in > > > <:str_item> > > > > I think that you're looking for this: > > > > let t = <:expr< <:ctyp> >> in > > <:str_item> > > > > although I'm curious as to why. > > > > Jeremy. > > > > The problem what t variable result of parsing > > EXTEND Gram > str_item: > [ > [ "mtype" ; n = a_LIDENT ; "=" ; t = ctype -> ><:expr< > let f = <:expr<$t$>> >>> > ] > END > > And result now is: > > let f = t > > But i need to: > > let f = Ast.TyId (_loc, Ast.IdLid (_loc, "int")) You the syntactic meta lifting (as in <:expr< <:ctyp< int >> >>) is not sufficient, you need to call the function that do this lifting. #load "camlp4of.cma";; open Camlp4.PreCast;; module M = Ast.Meta.Make(Ast.Meta.MetaGhostLoc);; let ghost = Loc.ghost;; let t = <:[EMAIL PROTECTED]< int >>;; M.Expr.meta_ctyp ghost t;; Best regards, PS: Tolevel output :) - : Camlp4.PreCast.Ast.expr = Camlp4.PreCast.Ast.ExApp (, Camlp4.PreCast.Ast.ExApp (, Camlp4.PreCast.Ast.ExId (, Camlp4.PreCast.Ast.IdAcc (, Camlp4.PreCast.Ast.IdUid (, "Ast"), Camlp4.PreCast.Ast.IdUid (, "TyId"))), Camlp4.PreCast.Ast.ExId (, Camlp4.PreCast.Ast.IdAcc (, Camlp4.PreCast.Ast.IdUid (, "Loc"), Camlp4.PreCast.Ast.IdLid (, "ghost", Camlp4.PreCast.Ast.ExApp (, Camlp4.PreCast.Ast.ExApp (, Camlp4.PreCast.Ast.ExId (, Camlp4.PreCast.Ast.IdAcc (, Camlp4.PreCast.Ast.IdUid (, "Ast"), Camlp4.PreCast.Ast.IdUid (, "IdLid"))), Camlp4.PreCast.Ast.ExId (, Camlp4.PreCast.Ast.IdAcc (, Camlp4.PreCast.Ast.IdUid (, "Loc"), Camlp4.PreCast.Ast.IdLid (, "ghost", Camlp4.PreCast.Ast.ExStr (, "int"))) -- 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
Re: [Caml-list] Sys.getenv does not work under OS X?
Excerpts from Alan Schmitt's message of Thu Sep 11 14:51:06 +0200 2008: > Hello, > > I'm using OS X (Leopard, up to date), with ocaml 3.10.2 (compiled with > godi), and I was trying to use htmlc which fails for some reason. it > boils down to the following: > > [EMAIL PROTECTED] compiler % echo $HOST > charm.inrialpes.fr > [EMAIL PROTECTED] compiler % ledit ocaml > Objective Caml version 3.10.2 > > # Sys.getenv "$HOST";; > Exception: Not_found. Wrong > # Sys.getenv "HOST";; > Exception: Not_found. Should work > Is Sys.getenv supposed to work under OS X? I'm guessing some special thing for HOST, since it work for HOME -- 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
Re: [Caml-list] Re: pervasives.cmi is not a compiled interface (solved)
Excerpts from Joel Reymont's message of Thu Sep 11 12:44:59 +0200 2008: > Fixed by building with build/fastworld.sh I think that the "make clean && ./build/distclean.sh" have fixed it, not the ./build/fastworld.sh process. All the best, -- 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] 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
Re: [Caml-list] ocamlbuild not including dependencies with mlpack
Excerpts from Ashish Agarwal's message of Mon Oct 06 19:49:16 +0200 2008: > Ocamlbuild seems to not include dependent modules when building a library, > when that library is defined by an mlpack file. However, it works fine if I > manually pack, i.e. define an ml file instead of an mlpack file. Here's a > summary: > > --- mylib.mlpack --- > A > B > > $ ocamlbuild mylib.cma > $ cat _build/_log #just showing relevant line > ocamlfind ocamlc -a -linkpkg mylib.cmo -o mylib.cma > > I was expecting a.cmo and b.cmo to get included in the library but they are > not. > Now if a replace the mylib.mlpack with mylib.ml as follows, I get what I > want. > > --- mylib.ml --- > module A = A > module B = B > > $ ocamlbuild mylib.cma > $ cat _build/_log #just showing relevant line > ocamlfind ocamlc -a -linkpkg a.cmo b.cmo mylib.cmo -o mylib.cma > > How can I get the latter behavior with mlpack? Thank you. The concept of package is precisely to get rid of a.cmo and b.cmo, since mylib.cmo (in your first example) contains all the code of A and B. In the second example mylib.cmo does not contains the code of A and B but merely a bunch of 'let' definitions. In your case, if you want to avoid name-space pollution by using packs, then the first option is the right one. Best regards, -- 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
Re: [Caml-list] Re: Metaprogramming features
Excerpts from jonathandeanharrop's message of Tue Oct 07 02:17:13 +0200 2008: > On Monday 06 October 2008 17:46:49 Chung-chieh Shan wrote: > > Jon Harrop <[EMAIL PROTECTED]> wrote in article > <[EMAIL PROTECTED]> in gmane.comp.lang.caml.inria: > > > Exactly. The difference is (only) the performance characteristics. > > > > To the contrary, that is not the only difference; the timing of > > side effects (including non-termination and exceptions) can also be > > different. We give an example at the beginning of our Section 2. > > I don't follow. Your paper translates the following staged function: > > let power7 : int -> int = > .! . .~(Printf.printf "power\n"; power 7 ..)>.;; > > into this: > > let npower7 = > (fun () -> fun x -> (printf "power\n"; npower 7 (fun () -> x)) ()) ();; > > and notes that the result is different because the former calls printf > immediately whereas the latter defers. > > Surely the discrepancy is because the translation should be: > > let npower7 = > let e = printf "power\n"; npower 7 (fun () -> x) in > (fun () -> fun x -> e ()) ();; Hum "unbound value x" :) -- 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
Re: [Caml-list] conjunctive type in polymorphic variants
Excerpts from Conglun Yao's message of Thu Oct 09 06:15:16 +0200 2008: > Hi all, > > I have just met a strange problem (it might have already been > answered, but I can't find the it) while using camlp4 to generate a > polymorphic type like: > > type t = [ `A of int * int | `B of string ] > > error msg "The present constructor A has a conjunctive type" is thrown > by the compiler. > > I followed the ocaml source code, found in ocaml-3.10.2/typing/typetexp.ml > Line 290, it does the following check in add_field function: > if List.length stl > 1 || c && stl <> [] then > raise(Error(styp.ptyp_loc, Present_has_conjunction l)); > > Sorry, I can't fully understand the source code, but it seems we can > only define a polymorphic variant with only one additional type > declaration, like >`A of int or `A of (int * int) > rather than `A of int * int Right. > It looks wired, as we can directly define > type t = [ `A of int * int | `B of string ] in toploop or a *.ml file. I think there is some syntactic thing to make it equal to `A of (int * int) in this case since `A of int * int does not make sense. > Or I have some mis-understanding in this part. In your camlp4 code you have to add tuple nodes to wrap star nodes: <:ctyp< $tup:t$ >> Best regards, -- 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
Re: [Caml-list] camlp4 module dependencies
Excerpts from John Harrison's message of Sun Sep 21 20:05:36 +0200 2008: > I'm trying once again to make some code work under the new camlp4. I > don't want to make any real syntax modifications, but just enable > quotations performing a simple string transformation on the body of > the quotation, e.g. turning > [...] > Can anyone tell me what else I should be loading/opening? You have to add the include directories: $ ocaml camlp4of.cma -I +camlp4 -I +camlp4/Camlp4Parsers Regards, -- 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
Re: [Caml-list] More problems with simple quotation parser
Excerpts from John Harrison's message of Sun Sep 21 20:47:15 +0200 2008: > I've hit another problem with the simple string transformation > quotation parser (see my previous message). For the sake of this > example, here is a somewhat simplified variant, which I turn > into "Quotexpander.cma": [...] > Any idea what's going on? Do I need to put some kind of wrapping > round the transformed phrase? The camlp4 lexer allow much longer bracketing tokens like [<, >], [%, {#, ... ) so when using extensions of OCaml (since this lexer extension does not break any OCaml code in original syntax) one have to put more spaces to make separate tokens. -- 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
Re: [Caml-list] File inclusion with Ocamldoc
Excerpts from Dario Teixeira's message of Wed Oct 15 16:43:32 +0200 2008: > Hi, > > > 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? > > You're right. I took the Ocamlbuild manual at face value, since > it states it cannot handle implementation files. Nevertheless, > I'm still running into some problems with Ocamlbuild+Ocamldoc. > First, while Ocamldoc will by default merge the comments from .ml > and .mli files (with precedence given to the .mli file, unless > -inv-merge-ml-mli is given), when I use Ocamlbuild to generate > the documentation I notice the following pattern: if only the .ml > file is present then it's used for generating the documentation; > If, however, both .ml and .mli are present, then only the .mli > is taken into account (no merging is done). Second, how does one > tell Ocamlbuild to include .txt files in the documentation? The manual states that implementation files are not handled because if you have a .ml and .mli then ocamlbuild will choose the .mli. -- Nicolas Pouillard aka Ertai ___ 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 ?
Excerpts from romain.bardou's message of Thu Oct 16 10:30:49 +0200 2008: > > 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? 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. > 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 I won't recommend that. -- Nicolas Pouillard aka Ertai ___ 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] .annot files in 3.11
Excerpts from David Allsopp's message of Sat Oct 18 13:25:13 +0200 2008: > > Le 17 oct. 08 à 11:25, David Allsopp a écrit : > > > > > Has anyone else found that ocamlopt in 3.11 seems to ignore the - > > > dtypes > > > option? ocamlc creates .annot files as normal when passed -dtypes. > > > > According to the release notes -annot should now be used. However > > there's no annot tag for ocamlbuild could that please be added for > > 3.11 ? I've added an 'annot' tag to ocamlbuild that triggers the '-annot' option. The 'dtypes' becomes deprecated and will follow the '-dtypes' option. -- Nicolas Pouillard aka Ertai ___ 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 vs INCLUDE: how to copy snippets into _build/ ?
Excerpts from Stefano Zacchiroli's message of Sat Nov 08 16:09:40 +0100 2008: > I'm using ocamlbuild and camlp4oof to exploit the INCLUDE syntax > extension, that is have camlp4 expand in the obvious way stuff like: > > INCLUDE "some/relative/path/snippet.mli" > > The path passed to INCLUDE is relative to the including file, but with > ocamlbuild I've a problem. Namely, the snippet is not copied inside > the appropriate subdir of _build, and camlp4 correctly fails with > something like: > > File "some/relative/path/snippet.mli", line 52, characters 0-3: > I/O error: "some/relative/path/snippet.mli: No such file or directory" > Preprocessing error on file src/foo/bar/including.mli > Command exited with code 2. > > The snippet is not otherwise processed by the OCaml toolchain, it is > just meant to be INCLUDEd. > > How can I tell ocamlbuild to copy into the _build/ directory my > snippets? > > My reading of the manual doesn't hint me to any useful tag ... Try to have something like open Ocamlbuild_plugin dispatch begin function | After_rules -> dep ["file:src/foo/bar/including.mli"] ["some/relative/path/snippet.mli"] end to your myocamlbuild.ml -- Nicolas Pouillard aka Ertai ___ 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: inconsistent globbing?
Excerpts from Hugo Ferreira's message of Fri Nov 14 09:12:44 +0100 2008: > Hello, > > I recently altered my project's _tag file > to include the compilation of a native version > of an application so: > > true: use_menhir, debug, profile > : not_hygienic > : not_hygienic > "src/ml_cudd.{d.byte,d.native}": use_cudd, use_gmp, use_bigarray > > However this did not work. I had to change this to: > > true: use_menhir, debug, profile > : not_hygienic > : not_hygienic > "src/ml_cudd.d.byte": use_cudd, use_gmp, use_bigarray > "src/ml_cudd.p.native": use_cudd, use_gmp, use_bigarray > > Isn't > > "src/ml_cudd.{d.byte,d.native}" > > equivalent to: > > "src/ml_cudd.d.byte": use_cudd, use_gmp, use_bigarray > "src/ml_cudd.p.native": use_cudd, use_gmp, use_bigarray > > If not, why? "..." are for constants and <...> are for globbings. So "src/ml_cudd.{d.byte,p.native}" should be written Best regards, -- Nicolas Pouillard aka Ertai ___ 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
Excerpts from daniel.buenzli's message of Sun Nov 16 19:22:02 +0100 2008: > Hello, > > Is it possible to specify a single installed module (instead of a lib) > for link time ? That is is there something like -lib but for module so > that I can type : > > ocamlbuild -I +xmlm -mod xmlm test.native > > where test.ml uses the xmlm module This would make sense, but I would prefer not to push things in this direction. Options like -lib,-cflag,-lflag... are intended to be used only in a quick hack usage, indeed they are global and tags are much more powerful. > And what about having special tags use_lib_$LIB and use_mod_$MOD that > automatically create rules to use libraries $LIB.cm(x)a and module > $MOD.cm(o|x) so that just the appropriate -I to find the files has to > be specified. In most cases having to use a plugin just for that seems > overkill. Or is there another way ? 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 2/ ln -s xmlm ocamlbuild -I xmlm test.native 3/ ln -s $(ocamlc -where)/xmlm . ocamlbuild -tag_line '"xmlm": not_hygienic' -I xmlm test.native Hope that helps, -- Nicolas Pouillard aka Ertai ___ 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] Wanted: your feedback on the hierarchy of OCaml Batteries Included
Excerpts from Jon Harrop's message of Tue Nov 18 19:17:23 +0100 2008: > On Tuesday 18 November 2008 10:06:25 Richard Jones wrote: > > On Tue, Nov 18, 2008 at 10:56:18AM +0100, David Teller wrote: > > > open System.IO;; > > > open System.File;; > > > > Your biggest problem is using dot ('.') instead of underscore ('_'). > > Using a dot means that the System namespace cannot be extended by > > external packages. If you use an underscore then an external package > > can extend the namespace (eg. by providing System_Newpackage) > > I don't follow. Can you not use "include" to extend an existing module: > > # module Array = struct > include Array > let empty = [||] > end;; > module Array : > sig > external length : 'a array -> int = "%array_length" > ... > val empty : 'a array > end Yes but that's the same than saying you can change a value: let x = 42 let x = x + 1 So you make a new module but don't extend it. -- Nicolas Pouillard aka Ertai ___ 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] Wanted: your feedback on the hierarchy of OCaml Batteries Included
Excerpts from Maxence Guesdon's message of Wed Nov 19 21:11:24 +0100 2008: > On Wed, 19 Nov 2008 10:46:24 +0100 > "Paolo Donadeo" <[EMAIL PROTECTED]> wrote: > > > Couldn't we take inspiration from the Python standard library [1]? > > Python hasn't namespace but is provided with a module system similar > > to OCaml *and* the standard library is really impressive. > > > > And nobody can say Python is a bureaucratic language like Java :-) > > > > > > [1] http://www.python.org/doc/2.5.2/lib/lib.html > > Hello, > > I think a hierarchy in the documentation is very useful: it helps beginners > understand the big picture about all available modules and help developers > find the functions they look for. But in the code, I think it is really > more convenient to only have one level of "standard" modules. > > By the way, I, too, always prefix idents with the module they come from, > (like in List.length) and only "open" a module to use fields and > constructors, so using Data.Containers.List.length or whatever is longer > than "List.length" is not an option. Having a shortcut "List" for > Data.Containers.List does not convince me, because the problem will remain > with modules with no shortcut. > > So hierarchy in documentation: yes; in the code: no. No one (I guess) would recommend you to use fully qualified paths as in Data.Containers.List.length of course. Data.Containers.List.length is the external name, made to be well organized not to be quick to type, the way to use it to open it *OR* to define an internal name for it : module L = Data.Containers.List And then use L.length, L.map... I know that the choice of name qualification, opening, or local modules is controversial, however I would like to point out that the external name don't need to be the same than the internal name. Cheers, -- Nicolas Pouillard aka Ertai ___ 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] Wanted: your feedback on the hierarchy of OCaml Batteries Included
Excerpts from Richard Jones's message of Thu Nov 20 11:33:03 +0100 2008: > On Thu, Nov 20, 2008 at 10:28:07AM +0100, Nicolas Pouillard wrote: > > No one (I guess) would recommend you to use fully qualified paths as in > > Data.Containers.List.length of course. Data.Containers.List.length is the > > external name, made to be well organized not to be quick to type, the way > > to use it to open it *OR* to define an internal name for it : > > > > module L = Data.Containers.List > > > > And then use L.length, L.map... > > I've lost the plot on what problem are we trying to solve .. except > for the original one which is "Windows users are too stupid to use a > packaging system, so let's give them everything in a single > installer". But surely having everyone using privately named modules > is a bad idea? The private names chosen won't be consistent, and they > require a reference back to the top of the code to find out which > module they are really using. Encouraging developers to open modules > is also usually a bad idea, except in very limited circumstances > (hello Printf). Actually having to look at the top of each file (and only the top), is my favorite option. That's in fact exactly what I already do. -- Nicolas Pouillard aka Ertai ___ 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] open Module (not?) considered harmful
Excerpts from David Allsopp's message of Thu Nov 20 11:29:44 UTC 2008: > On 20 November 2008 10:49, Stefano Zacchiroli wrote: > > On Thu, Nov 20, 2008 at 10:33:03AM +, Richard Jones wrote: > > > Encouraging developers to open modules is also usually a bad idea, > > > except in very limited circumstances (hello Printf). > > > > Why? You and others failed me to convince of this. Or, better, I'm > > sure there are problems with that, but they just show deficiencies > > inherited from other parts of the language. > > Consider > > open Array;; > open List;; > > (* Hundreds of lines of code *) > > length [];; That's not a good example, because I consider the shadowing above as an ambiguity on certain identifiers. Don't confuse short names and ambiguous names. > The code is now is brittle in terms of the order of the open statements at > the top of the file and will fail to compile if they're swapped. Of course, > if you don't care about that kind of subtle refactoring error then open is > completely fine. Personally, I find that kind of brittleness irritating - > and it also has the potential to waste a huge amount of time if you have to > refactor the code. > > Whether you find code less readable with or without module names is of > course a matter taste and IIRC, OCaml 3.11 .annot files contain the > necessary information to expand them so there could be a nice editor plugin > to expand or remove module paths... > > > > The most straightforward solution to this problem to me looks like > > > providing a syntax equivalent like "from Module import foo, bar" > > > which selectively imports only some identifiers from a given module. > > Which, for values only, is of course a trivial camlp4 extension... and could > be generalised to include type declarations and so on with only a little > more work. The .NET languages have a syntax for selectively importing > classes from a namespace rather than the entire namespace (and it's > different from Java's in that you can rename the class while you do it). I have a trivial camlp4 extension for that actually if someone is interested, feel free to ask. -- Nicolas Pouillard aka Ertai ___ 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] open Module (not?) considered harmful
Excerpts from Nicolas Pouillard's message of Thu Nov 20 14:01:53 +0100 2008: > Excerpts from David Allsopp's message of Thu Nov 20 11:29:44 UTC 2008: > > On 20 November 2008 10:49, Stefano Zacchiroli wrote: > > > On Thu, Nov 20, 2008 at 10:33:03AM +, Richard Jones wrote: > > > > Encouraging developers to open modules is also usually a bad idea, > > > > except in very limited circumstances (hello Printf). > > > > > > Why? You and others failed me to convince of this. Or, better, I'm > > > sure there are problems with that, but they just show deficiencies > > > inherited from other parts of the language. > > > > Consider > > > > open Array;; > > open List;; > > > > (* Hundreds of lines of code *) > > > > length [];; > > That's not a good example, because I consider the shadowing above as > an ambiguity on certain identifiers. Don't confuse short names and ambiguous > names. > > > The code is now is brittle in terms of the order of the open statements at > > the top of the file and will fail to compile if they're swapped. Of course, > > if you don't care about that kind of subtle refactoring error then open is > > completely fine. Personally, I find that kind of brittleness irritating - > > and it also has the potential to waste a huge amount of time if you have to > > refactor the code. > > > > Whether you find code less readable with or without module names is of > > course a matter taste and IIRC, OCaml 3.11 .annot files contain the > > necessary information to expand them so there could be a nice editor plugin > > to expand or remove module paths... > > > > > > The most straightforward solution to this problem to me looks like > > > > providing a syntax equivalent like "from Module import foo, bar" > > > > which selectively imports only some identifiers from a given module. > > > > Which, for values only, is of course a trivial camlp4 extension... and could > > be generalised to include type declarations and so on with only a little > > more work. The .NET languages have a syntax for selectively importing > > classes from a namespace rather than the entire namespace (and it's > > different from Java's in that you can rename the class while you do it). > > I have a trivial camlp4 extension for that actually if someone is interested, > feel free to ask. Given the crowd of people wanting it, I've added a link [1] to the camlp4 wiki [2] :) [1] http://aloxe.inria.fr/darcs/pa_import [2] http://brion.inria.fr/gallium/index.php/Camlp4_contributions -- Nicolas Pouillard aka Ertai ___ 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] OCaml 3.11.0 release candidate
Excerpts from Andres Varon's message of Fri Nov 28 16:50:14 +0100 2008: > Hello, > > On Nov 25, 2008, at 12:09 PM, Damien Doligez wrote: > > > Dear OCaml users, > > > > We are closing in on version 3.11.0. A Release Candidate is now > > available. > > If there are no show-stoppers in this RC, then 3.11.0 will be > > officially > > released next week. > > > > The release candidate is available here: > > < http://caml.inria.fr/pub/distrib/ocaml-3.11/ > > > (look for 3.11.0+rc1) > > I have a question about the behavior of camlp4orf (and family) in > 3.11.0. Now with the availability of native dynlink, it seems like > camlp4orf and camlp4orf.opt can load external modules inside the core. > If one looks at their respective help: > > .(cmo|cma) Load this module inside the Camlp4 core > .cmx Load this module inside the Camlp4 core > > This is a feature I've been looking for to speedup compilation times. > However, if I try the native version, here is what I get: > > samson:src andres$ camlp4orf.opt poyExtension.cmx > Error: don't know what to do with poyExtension.cmx > Use option -help for usage > > Is the usage different for the camlp4*.opt preprocessors? You should try with .cmxs files. -- Nicolas Pouillard aka Ertai ___ 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] ocamlbuildlib.cmxa not built under 3.11
Excerpts from Alexy Khrabrov's message of Tue Dec 09 08:12:38 +0100 2008: > When trying to build hunpos, > > http://code.google.com/p/hunpos/ > > -- under 3.11, it complains that ocamlbuildlib.cmxa cannot be found in > `ocamlbuild -where`, and it's not there after I did make world.opt in > the top dir of ocaml 3.11. Going into ocamlbuild and saying make > native leaves an boot/ocamlbuild, but end up with an error trying to > use _build which isn't there. > > Since hunpos builds fine under 3.10.2, I wonder whether this is an > intended change in 3.11... Try to build with "make opt.opt". Cheers, -- Nicolas Pouillard aka Ertai ___ 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] "Virtual" dependencies in ocamlbuild
Excerpts from Stéphane Glondu's message of Sat Jan 24 19:27:08 +0100 2009: > Hi all, > > Is there any way to add a dependency to a .cma file without adding it to > the linking command? > > It seems that "dep" from the API also adds the dependency for linking: > for example, if that dependency is a stamp file, that stamp file is > stupidly added to "ocamlc -a" command, making it fail. You can avoid linking by adding the "dont_link_with" tag, to your dep declaration. Best regards, -- Nicolas Pouillard ___ 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] Defining a family of functors
Excerpts from David Teller's message of Tue Jan 27 22:12:59 +0100 2009: > I'd like that, too. I may be wrong but I have the impression that most > of this can already be done with the current type system of OCaml. > > Unless I'm mistaken, for first-class modules, you essentially need > * extendable records (aka objects, good thing we already have them) > * existential types (which may be encoded with universal types, and > since we have universal types in classes, there may be a way to to this > already) The encoding of modules using existential types in non modular, this basically means that you have to heavily transform the source. What one need to encode modules is "open" existential types, this well and clearly explained in this POPL'09 paper: «Modeling Abstract Types in Modules with Open Existential Types», by Benoît Montagu and Didier Rémy > * namespace (which I'm sure could be encoded somehow). > > Now, the syntax would certainly be awful, but if I'm right it wouldn't > take too much to get these modules into the compiler. Kind regards, -- Nicolas Pouillard ___ 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] Ampersand in camlp4 grammar extension
Excerpts from Paul Steckler's message of Wed Jan 28 10:39:16 +0100 2009: > I'm writing a camlp4 grammar extension for OCaml that tries to match > ampersands and rewrite expressions containing them. That wouldn't > be a good idea if my code contained ordinary ampersands used for conjunctions. > But the code doesn't. > > I'm struggling how to match the ampersands in my expression rewrite rules. > I've tried "&" and SYMBOL "&", which don't work -- the preprocessed file > contains > the original ampersands. OTOH, I've written rules which use things like "->" > and > work fine. The answer depends on what you want to achieve, if you want to give to "&" another syntactic form (no longer infix, or change the priorities), then I would recommend you to just use "&" in your grammar rules. It will declares it as a keyword (add it into a table of keywords) and then the token filter between (between the lexer and the parser) will transform it from SYMBOL to KEYWORD. In fact, I've just looked at the lexer and the '&' token is *at the beginning* emitted using the SYMBOL constructor, however by looking at the OCaml parser files, one can see that "&" is already used literally, so already declared as a keyword and so already transformed as a KEYWORD "&". Conclusion use "&" to match it. However I can guess in your question that you don't really want to change the syntax of the binary operator "&", but rather to change it's meaning. In camlp4 there is a much more sane and easier way to do this using filters. By the way there is an example in the camlp4 sources that does exactly this. $ cd camlp4/examples $ cat apply_operator.ml open Camlp4.PreCast; AstFilters.register_str_item_filter (Ast.map_expr (fun [ <:e...@loc< $e1$ & $e2$ >> -> <:e...@loc< $e1$ $e2$ >> | e -> e ]))#str_item; $ ocamlbuild -tags camlp4rf,use_camlp4 apply_operator.cmo $ cat apply_operator_test.ml (* To force it to be inlined. If not it's not well typed. *) let ( & ) = ();; fun f g h x -> f & g & h x $ camlp4o ./_build/apply_operator.cmo apply_operator_test.ml (* To force it to be inlined. If not it's not well typed. *) let ( & ) = () let _ = fun f g h x -> f (g (h x)) Best regards, -- Nicolas Pouillard ___ 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: Re : [Caml-list] Warning wished
Excerpts from Julien SIGNOLES's message of Wed Jan 28 15:24:14 +0100 2009: > Le mercredi 28 janvier 2009 à 14:07 +, Matthieu Wipliez a écrit : > > > Hello, > > > > > > Is it a bug or a well-known feature that the above program does not emit > > > a warning (because "f x" should have type unit in the body of "g") ? > > > > > > = > > > let f x = x > > > let g x = f x; 1 > > > (* let _ = g 2 *) > > > > > > > I'm not familiar with the internals of the compiler, but what I suppose is > > happening is that it tries to unify the type of "f x" and "unit", and this > > succeeds because "f x" has type 'a, which can be unified with anything. The > > meaning of "a;b" seems to be let _ = a in b rather than let () = a in b. > > > > But like I said, these are suppositions. > > Sure. However in my real case, I had an "ok" code like this : > > let f x : 'a -> unit = ... > let g x = > f x; > x > > I changed a little bit the specification of f : > > let f x : 'a -> 'a = ... > > I just expected that caml helps me to find all the instances where I had > to take care of this specification change. Such a thing is one of the > very good features of caml. Unfortunatly, in this case, caml did not > help me while the old implementation of "g" became wrong with the new > specification of "f" :-(. That's because (let f x : 'a -> 'a = ...) is not a specification for a polymorphic function, this is rather an existential quantification than a universal one. They are some ugly tricks to ensure a polymorphic function, like this one: module M : sig val f : t -> 'a -> 'a end = struct let f x = ... end include M Best regards, -- Nicolas Pouillard ___ 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] Ampersand in camlp4 grammar extension
Excerpts from Paul Steckler's message of Thu Jan 29 05:36:44 +0100 2009: > Hi Nicolas, > > > However I can guess in your question that you don't really want to change > > the > syntax of the binary operator "&", but rather to change it's meaning. In > camlp4 there is a much more sane and easier way to do this using filters. > By the way there is an example in the camlp4 sources that does exactly this. > > Yes, this seems to work -- but it would be simpler, in fact, if I could just > use > a rule in my grammar extension. > Do you know if there's a way to debug grammar extensions? I don't think there is a nice way do to it. > Maybe I need to > DELETE a rule from the original grammar, though it's not clear to me which > rule that is. Look at Camlp4Parsers/Camlp4OCamlRevisedParser.ml The rule is: infixop5: [ [ x = [ "&" | "&&" ] -> <:expr< $lid:x$ >> ] ] ; -- Nicolas Pouillard ___ 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] Defining a family of functors
Excerpts from David Teller's message of Wed Jan 28 12:25:26 +0100 2009: > On Wed, 2009-01-28 at 01:32 +0100, Nicolas Pouillard wrote: > > The encoding of modules using existential types in non modular, this > > basically means that you have to heavily transform the source. > > > > What one need to encode modules is "open" existential types, this well > > and clearly explained in this POPL'09 paper: > > > > «Modeling Abstract Types in Modules with Open Existential Types», > > by Benoît Montagu and Didier Rémy > > Yes, I was just reading that paper. However, it is my impression that we > could get away without open existential types, at the cost of reduced > features. > > On the other hand, it was pointed to me that Alain already wrote a > compiler patch implementing first-class modules. That's right. -- Nicolas Pouillard ___ 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 question
Excerpts from Matthieu Dubuget's message of Wed Feb 11 23:26:43 +0100 2009: > Hello, > > I'm trying to manage "internal" camlfind packages. I use "internal" with > the same meanning than in ocamlbuild documentation when speaking about > libraries. > > I want my camlfind packages to be re-installed if one of their > dependency was modified. For this, I wrote a simple rule, based on > %.iocamlfind files containing the files to install into findlib > directory. This rule also produces a stamp file : %.oocamlfind. > > I also want my camlfind package to be installed if they are needed by > another rule. For this, I do: dep ["pkg_"^nm][nm ^ ".oocamlfind"] for > each internal package. > > It seems to work ok: Suppose that package toto requires package tutu. > When I ask ocamlbuild toto.oocamlfind, the packages tutu is re-built if > needed. And if I modify one file of tutu, and then ask ocamlbuild to > generate toto.oocamlbuild, tutu is re-built and installed into findlib > directories. fine. > > BUT, when I'm producing a %.native from %.cmx, my dependencies (ie > %.oocamlfind files) are inserted in the command line... > > Here is an example: > ocamlfind ocamlopt -linkpkg -package mtsvrac -package log > logtest/test.cmx mtsvrac.oocamlfind log.oocamlfind -o logtest/test.native > > mtsvrac.oocamlfind and log.oocamlfind where added to the dependencies of > logtest/test.native. > > What would be the right solution to avoid this problem? > Is there something like a "dependency that should not be linked?" Hello, You should try to tag your .oocamlfind file with the dont_link_with tag. (this point certainly needs an entry in the FAQ...) Best regards, -- Nicolas Pouillard ___ 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 - infer_interface
Excerpts from Guillaume Yziquel's message of Sat Feb 28 21:08:46 +0100 2009: > Hello. > > A small comment on the ocamlbuild wiki, and more specifically on its > plugin for ocamlfind: > > http://brion.inria.fr/gallium/index.php/Using_ocamlfind_with_ocamlbuild > > This plugin fails to generate .inferred.mli files. The following lines > (thanks to bluestorm on #ocaml irc channel) are needed in the > After_rules of the plugin: > > -1- flag ["ocaml"; "infer_interface"; "pkg_"^pkg] & S[A"-package"; A pkg]; > > -2- flag ["ocaml"; "infer_interface"; "syntax_"^syntax] & S[A"-syntax"; > A syntax]; > > -3- flag ["ocaml"; "pkg_threads"; "infer_interface"] (S[A "-thread"]) > > Since I could not find a single occurrence of "infer_interface" on the > Gallium wiki, and since I do not believe that using ocamlbuild and > ocamlfind together to infer .mli files is "not a simple task", I > sincerely believe that the documentation of ocamlbuild is insufficient, > and insufficently structured. (This is to echo the debate between Daniel > Bünzli and Romain Bardou, among others, two or three weeks ago > concerning the lack of documentation). > > Could these three lines be added to the myocamlbuild.ml plugin for > ocamlfind on the Gallium wiki, and could tags such as "infer_interface" > be documented thoroughly on the wiki? That would be helpful! Thanks for this contribution. I've added these 3 lines in the Wiki. -- Nicolas Pouillard ___ 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] stl?
Excerpts from Brian Hurt's message of Wed Mar 04 17:14:50 +0100 2009: > > > On Wed, 4 Mar 2009, Peng Zang wrote: > > > -BEGIN PGP SIGNED MESSAGE- > > Hash: SHA1 > > > > On Wednesday 04 March 2009 01:11:18 am Brian Hurt wrote: [...] > > But I'll add one more reason. With functors you have extra overhead like > > having to be explicit with what function you're using. In your example when > > you want to use Newton's method you always must write "RatioNewton.newtons" > > or "FloatNewtons.newtons". The alternative is to functorize the call site, > > but (1) that has its own cost: lots of boilerplate functorizing code > > crowding > > the real code and (2) you just defer the explicit naming cost as when that > > function is called you'll still have to call either Float version or Ratio > > version. > > Yeah. I think of this as one of the advantages of Functors. > > Here are two real problems I've hit with type classes, in only a few weeks > banging around in Haskell. > > For example, you can't have more than one instance of a type class for any > given type. So let's say you want to have a type class for things that > can be converted to and from s-expressions, like: [...] > Now, I comment you *can* do this in Haskell- using GHC specific > extensions. But you don't need fancy extensions (which cause problems in > the type checker, if I understand things correctly) to do this, quite > easily, with functors. Haskell `newtype's is a pretty reasonable answer to this problem. A `newtype' is a bit like a type with only one constructor of only one argument, except that there is no runtime cost for it. However by being a *new* type one can define different instances of type classes for it. Moreover since the deriving feature is extended on `newtype's, retrieving all the goodness of the wrapped type is costless (deriving newtype is easy since generally the code justs virtually unpacks and re-packs using the constructor and call the same functions on the wrapped value). Examples: \begin{code} {-# LANGUAGE GeneralizedNewtypeDeriving #-} import Data.List import Data.Function newtype MySet a = MkMySet { toList :: [a] } -- here toList is an accessor -- function (MySet a -> [a]) deriving (Read,Show,Functor,Monad) -- ... norm :: Ord a => MySet a -> [a] norm = nub . sort . toList instance (Ord a) => Eq (MySet a) where (==) = (==) `on` norm instance (Ord a) => Ord (MySet a) where compare = compare `on` norm propMySet = MkMySet [1,2,3,4] == MkMySet [1,1,2,4,3] \end{code} Or another one: \begin{code} newtype DownInt = DownInt { fromDownInt :: Int } deriving (Eq,Read,Show,Enum,Num) instance Ord DownInt where compare = flip compare `on` fromDownInt -- same as compare x y = fromDownInt y `compare` fromDownInt x propDownInt = DownInt 4 < DownInt 2 -- this example is contrived since sortBy would be simpler here -- however in larger examples the benifit is clearer, for instance -- List.sort is not in a functor in OCaml. sortDownInt :: [Int] -> [Int] sortDownInt = map fromDownInt . sort . map DownInt propDownInt' = [4,3,2,1] == sortDownInt [1,2,3,4] -- since DownInt is in the Num class (an explicit choice -- from the definition of DownInt), literals can be -- freely lifted to DownInt. propDownInt'' = [4,3,2,1] == sort [(1::DownInt),2,3,4] \end{code} Note that one can generalize `DownInt' as `Down' and get an easy way to reverse the order on a type. Since that, I personally consider type-classes goodness more valuable than functors usage that doesn't fall in that category. All the best, -- Nicolas Pouillard ___ 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] using a camlp4 man filter with my own type
Excerpts from Joel Reymont's message of Thu Mar 05 16:04:09 +0100 2009: > I looked at the Camlp4 filter wiki [1] but still can't figure this out. > > + ocamlfind ocamlc -package 'oUnit, dyp, extlib' -c -I +camlp4 -g -w a > -pp 'camlp4of -I src -filter map' -I src -o src/easy_type_check.cmo > src/easy_type_check.ml > File "src/easy_type_check.ml", line 45, characters 10-15: > Error: This expression has no method expr > > This used to work fine in 3.10.x and the error points to "match > super#expr e with" in strip_token_loc below. Can you look at (or post) the result of the generation? $ camlp4of -I src -filter map src/easy_type_check.ml -- Nicolas Pouillard ___ 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] building 64bit ocaml from cvs on mac osx leopard
Excerpts from Joel Reymont's message of Thu Mar 05 19:27:01 +0100 2009: > Ashish, > > I'm not getting the previous error anymore and my issue is the same as > yours now. > > Reason? > > SANITIZE: a total of 749 files that should probably not be in your I recall that moving from one build procedure to another requires a full clean (make clean ; ./build/distclean.sh). -- Nicolas Pouillard ___ 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] building 64bit ocaml from cvs on mac osx leopard
Excerpts from Ashish Agarwal's message of Thu Mar 05 19:12:23 +0100 2009: > I just did a fresh install and it is working fine for me when I use the > normal method. The ocamlbuild method seems to compile fine, but make install > gives some error. I checked ocamlbuild's log file and the last line says > "Compilation successful", but when I do make install it says "cp: ocamlc: No > such file or directory", although I verified that _build/ocamlc does exist. > This seems like a different error than yours. When using the ocamlbuild procedure, the installation is done via ./build/install.sh. BTW what were your errors with the `make' procedure? > > On Thu, Mar 5, 2009 at 10:39 AM, Joel Reymont wrote: > > > > > On Mar 5, 2009, at 3:10 PM, David Allsopp wrote: > > > > Have you tried building the normal way (./configure -cc "gcc -m64" && make > >> world bootstrap opt opt.opt install)? fastbuild.sh is experimental IFAIK > >> > > > > > > Makes no difference. > > > > make libraryopt > > cd stdlib; make allopt > > ../boot/ocamlrun ../ocamlopt -warn-error A -nostdlib -g `./Compflags > > pervasives.cmx` -c pervasives.ml > > /var/folders/pc/pcNEaYn32RW2i++8ZQvErU+++TM/-Tmp-/camlasm1dfba1.s:602:junk > > `...@plt' after expression > > /var/folders/pc/pcNEaYn32RW2i++8ZQvErU+++TM/-Tmp-/camlasm1dfba1.s:633:junk > > `...@plt' after expression > > ... > > File "pervasives.ml", line 1, characters 0-1: > > Error: Assembler error, input left in file > > /var/folders/pc/pcNEaYn32RW2i++8ZQvErU+++TM/-Tmp-/camlasm1dfba1.s > > make[2]: *** [pervasives.cmx] Error 2 > > make[1]: *** [libraryopt] Error 2 > > make: *** [opt] Error 2 > > > > --- > > http://tinyco.de > > Mac, C++, OCaml > > > > > > > > > > ___________ > > 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 > > -- Nicolas Pouillard ___ 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] building 64bit ocaml from cvs on mac osx leopard
Excerpts from Joel Reymont's message of Fri Mar 06 10:13:32 +0100 2009: > > On Mar 6, 2009, at 8:17 AM, Nicolas Pouillard wrote: > > > I recall that moving from one build procedure to another requires > > a full clean (make clean ; ./build/distclean.sh). > > > ./build/distclean && ./configure ... && ./build/fastworld.sh The full clean is (make clean ; ./build/distclean.sh) not just ./build/distclean.sh. -- Nicolas Pouillard ___ 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] building 64bit ocaml from cvs on mac osx leopard
Excerpts from Joel Reymont's message of Fri Mar 06 11:40:13 +0100 2009: > > On Mar 5, 2009, at 4:08 PM, Andres Varon wrote: > > > I don't think that it compiles the way it is now. It seems to me > > that there was a version merge error and asmcomp/amd64/emit.mlp has > > repeated definitions of emit_call and emit_jump. > > > Here's the offending part of asmcomp/amd64/emit.mlp. > > The two load_symbol_addr are equivalent and the only difference in the > rest is the Mac OSX check. /More after the code/ > > let emit_call s = >if !Clflags.dlcode && not macosx >then `call{emit_symbol s...@plt` >else `call{emit_symbol s}` > > let emit_jump s = >if !Clflags.dlcode && not macosx >then `jmp {emit_symbol s...@plt` >else `jmp {emit_symbol s}` > > let load_symbol_addr s = >if !Clflags.dlcode >then `movq{emit_symbol s...@gotpcrel(%rip)` >else if !pic_code >then `leaq{emit_symbol s}(%rip)` >else `movq${emit_symbol s}` > > > let emit_call s = >if !Clflags.dlcode >then `call{emit_symbol s...@plt` >else `call{emit_symbol s}` > > let emit_jump s = >if !Clflags.dlcode >then `jmp {emit_symbol s...@plt` >else `jmp {emit_symbol s}` > > let load_symbol_addr s = >if !Clflags.dlcode >then `movq{emit_symbol s...@gotpcrel(%rip)` >else if !pic_code >then `leaq{emit_symbol s}(%rip)` >else `movq${emit_symbol s}` The second part of this code have to be removed, this is an undesirable behavior of merging some CVS branches. However the CVS HEAD is not supposed to be as stable as the ocaml3110 branch. > On my system dlcode is true and so is macosx so it should note be > taking the PLT branch. There's also this ocamlbuild rule for building > asmcomp/emit.ml from asmcomp/amd64/emit.mlp > > let emit_mlp = "asmcomp"/C.arch/(if ccomptype = "msvc" then > "emit_nt.mlp" else "emit.mlp") in > rule "emit.mlp" >~prod:"asmcomp/emit.ml" >~deps:[emit_mlp; "tools/cvt_emit.byte"] >begin fun _ _ -> > Cmd(S[ocamlrun; P"tools/cvt_emit.byte"; Sh "<"; P emit_mlp; >Sh">"; Px"asmcomp/emit.ml"]) >end;; > > I believe the issue is that distclean.sh does not remove ocamlopt in > the root of the ocaml source distribution. I was able to get past the > PLT error once I removed ocamlopt from the root of the tree and > modified asmcomp/amd64/emit.mlp to remove the second set of emit_call > and emit_jump functions that do not include Mac OSX checks. > > I got a different error from fastworld.sh now and it does not seem to > be related to 64 bits. > > + boot/ocamlyacc -v ocamldoc/odoc_text_parser.mly > 5 shift/reduce conflicts. > + ./ocamlc.opt -nostdlib -c -g -w Ale -warn-error Ale -I toplevel -pp > 'boot/ocamlrun camlp4/boot/camlp4boot.byte' -I camlp4 -I stdlib -I > camlp4/Camlp4Top -I camlp4/build -o camlp4/Camlp4Top/Top.cmo camlp4/ > Camlp4Top/Top.ml > File "camlp4/Camlp4Top/Top.ml", line 37, characters 4-26: > Error: Unbound value Toploop.print_location This last error is rather strange, and I can't reproduce it, maybe it's another strange build state error? -- Nicolas Pouillard ___ 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] Revised syntax scope (3.10 vs. 3.11)
Excerpts from Andre Nathan's message of Fri Mar 27 05:42:34 +0100 2009: > Hello > > I've found the following difference of behavior between OCaml 3.10 and > 3.11. The code below > > <:expr< > do { > let a = "foo" in > print_endline a; > print_endline a > } > >> > > when run through camlp4o becomes, in 3.10, > > let a = "foo" in (print_endline a; print_endline a) > > while in 3.11 it becomes > > ((let a = "foo" in print_endline a); print_endline a) > > which causes `a' to become out of scope in the second print_endline. > Is the behavior of 3.11 the correct one? I had to move the binding > of `a' out of the do block so that this works in both versions. That was indeed the intended behavior, to get a larger scope for 'a' use this syntax: <:expr< do { let a = "foo"; (* <--- semicolon here *) print_endline a; print_endline a } >> -- Nicolas Pouillard ___ 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] quasiquoting: 3 parsers for camlp4 vs 1 for haskell?
Excerpts from Jon Harrop's message of Thu Apr 23 01:19:09 +0200 2009: > On Friday 17 April 2009 19:24:31 Joel Reymont wrote: > > From the quasiquoting paper by Geoffrey Mainland [1], page 7: > > > > "The major advantage of our approach over that of camlp4 > > is that we demonstrate how to use generic programming > > to reuse a single parser to parse quasiquoted patterns, > > quasiquoted expressions and plain syntax that does not > > include antiquotes. Because OCaml does not support generic > > programming out of the box, > > I have no idea what he meant by this. > > > in camlp4 this would require three separate parsers, > > AFAICT, that was not true when he wrote it (Sept 2007) and is not true today. There was indeed three different parsers for OCaml-like syntax in the old camlp4. Actually there was one classical parser for the official/original OCaml syntax but this one was not embeddable in quotations. There was also two parsers for the revised syntax one being the classical one and the other being for quotations. > > each generating different representations of the same concrete syntax." > > That has never been true. We are talking about quotations here, and I can confirm that the two parsers for the revised syntax where generating to different representations of the concrete syntax. Example (simplified): f 42 => App (Var "f") (Int "42") <> => App (App (Con "Var") (Str "f")) (App (Con "Int") (Str "42")) The new version of camlp4 use only one grammar for the revised syntax (instead of two) and a grammar extension for the official/original syntax. Best regards, -- Nicolas Pouillard ___ 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 plugin linking phase
Excerpts from Daniel Bünzli's message of Fri May 08 15:27:40 +0200 2009: > Is there a way to add options to the plugin linking phase (I'd like to > link my plugin with Str) ? There is no support for this in ocamlbuild. However, I think you can workaround this issue by providing -ocamlc 'ocamlc str.cma' (same for ocamlopt). -- Nicolas Pouillard ___ 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] OCaml version 3.11.1+rc0
Excerpts from Stéphane Glondu's message of Fri May 22 11:41:40 +0200 2009: > Damien Doligez a écrit : > > We need you to test this on as many system types as possible. Please > > report success or failure to as usual. > > It looks like ocamlbuild plugins do not work anymore... maybe because > `ocamlbuild -where` now points to the same location as `ocamlc -where`. I've committed a patch to fix exactly this, thanks for the report! -- Nicolas Pouillard ___ 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] batteries compilation error
Excerpts from Florent Monnier's message of Tue Sep 01 11:14:49 +0200 2009: > Hi, Hi, > Trying to compile batteries (version 20090405 on ocaml 3.11.1), > I get this error: > > + ocamlfind ocamlc -c -g -I src/syntax/pa_strings -I src -I src/core -I > src/main -I src/libs -I src/core/extlib_threads -I src/core/extlib -I > src/core/baselib -I src/core/baselib_threads -I src/libs/common -I > src/libs/camlzip -I src/libs/sexplib -I src/libs/findlib -I > src/libs/compilers -I src/libs/ocamlnet -I build/optcomp -o > src/syntax/pa_strings/pa_estring.cmi src/syntax/pa_strings/pa_estring.mli > File "src/syntax/pa_strings/pa_estring.mli", line 12, characters 0-19: > Error: Unbound module Camlp4.PreCast > > this line 12 is only: > open Camlp4.PreCast > > > Does someone have an idea of what could cause this error ? I don't see any "-I +camlp4" can you add it? -- Nicolas Pouillard http://nicolaspouillard.fr ___ 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] batteries compilation error
Excerpts from Florent Monnier's message of Wed Sep 02 22:02:11 +0200 2009: > > > Trying to compile batteries (version 20090405 on ocaml 3.11.1), > > > I get this error: > > > > > > + ocamlfind ocamlc -c -g -I src/syntax/pa_strings -I src -I src/core -I > > > src/main -I src/libs -I src/core/extlib_threads -I src/core/extlib -I > > > src/core/baselib -I src/core/baselib_threads -I src/libs/common -I > > > src/libs/camlzip -I src/libs/sexplib -I src/libs/findlib -I > > > src/libs/compilers -I src/libs/ocamlnet -I build/optcomp -o > > > src/syntax/pa_strings/pa_estring.cmi src/syntax/pa_strings/pa_estring.mli > > > File "src/syntax/pa_strings/pa_estring.mli", line 12, characters 0-19: > > > Error: Unbound module Camlp4.PreCast > > > > > > this line 12 is only: > > > open Camlp4.PreCast > > > > > > > > > Does someone have an idea of what could cause this error ? > > > > I don't see any "-I +camlp4" can you add it? > > if I run the command like this on the command line it passes right > but when I run again the make command it doesn't continue because > ocamlbuild complains about sanity violation > Anyway as it is for packaging purpose I will need to patch the Makefile, > the problem is that I don't see where to add this statement in the Makefile: > http://git.ocamlcore.org/cgi-bin/gitweb.cgi?p=batteries/batteries.git;a=blob;f=Makefile.in;hb=HEAD > > (also I've search in the debian package, and it seems they haven't patch the > Makefile at all) If you are using ocamlbuild, then a -tag use_camlp4 could do the job. -- Nicolas Pouillard http://nicolaspouillard.fr ___ 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 directory inclusion problem
Excerpts from Dario Teixeira's message of Sat Oct 24 18:11:26 +0200 2009: > Hi, > > I've come across another issue with Ocamlbuild, and I'm not sure if this one > is a bug or a feature. Consider the project tree below; note that everything > under lib/ is supposed to produce a foo.cma library, while cmd/ is a command > line application that uses foo.cma (and which can be safely ignored for now). > > |-- _tags > |-- lib/ > | |-- _tags > | |-- foo.mllib > | |-- foo_core.mlpack > | |-- foo_core/ > | | |-- (...) > | | > | |-- foo_ext.mlpack > | |-- foo_ext/ > | |-- (...) > | > |-- cmd/ > |-- (...) > > The file lib/_tags just contains " or : include". If I > issue > "ocamlbuild foo.cma" inside the lib/ directory, then foo.cma gets built as > expected. > However, if I move to the parent directory and issue "ocamlbuild lib/foo.cma", > I get an error: > > ocamlc -pack lib/foo_ext/beta.cmo lib/foo_ext/alpha.cmo -o lib/foo_ext.cmo > File "_none_", line 1, characters 0-1: > Error: The implementation (obtained by packing) >does not match the interface lib/foo_ext.mli: >Modules do not match: > sig val num : int end >is not included in > Foo_core.Zero.S >Unbound module type Foo_core.Zero.S > Command exited with code 2. > > > The problem is of course that "-I lib" should be added to the invocation of > ocamlc. > For this purpose I've created a myocamlbuild.ml in the root directory, with > the > following contents: What about adding «"lib": tnclude» into the main _tags file? BTW « or : include» could be written «"foo_core" or "foo_ext": include» Best regards, -- Nicolas Pouillard http://nicolaspouillard.fr ___ 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] revised syntax for abstract types ?
Excerpts from Serge Leblanc's message of Thu Dec 10 12:56:44 +0100 2009: > Hi, the documentation for the revised syntax explain that abstract types > are expressed by : The documentation is too old, abstract types now have the same syntax in revised than in the original OCaml syntax. -- Nicolas Pouillard http://nicolaspouillard.fr ___ 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] obj.magic for polymorphic record fields
Excerpts from Jacques Le Normand's message of Sun Dec 20 18:44:57 +0100 2009: > Dear ocaml-list, > the following code does not type check: > > type foo = {bar : 'a. 'a -> 'a} > let a : int -> int = fun x -> x > let baz = {bar = Obj.magic a} > > with the error > > Error: This field value has type 'a -> 'a which is less general than > 'b. 'b -> 'b > > > my question is: how could I use obj.magic to get a polymorphic type? Apart from the traditional "You should avoid Obj.magic as much as possible!" I once faced this situation and the solution is to use modules. module M : sig val f : 'a -> 'a end = struct let f = Obj.magic end ;; let baz = {bar = M.f };; Have fun! -- Nicolas Pouillard http://nicolaspouillard.fr ___ 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] Favorite OCaml editor?
Excerpts from Alain Frisch's message of Tue Jan 05 11:27:07 +0100 2010: > On 05/01/2010 09:13, Jon Harrop wrote: > > I think the best way to write a decent editor for OCaml would be to write > > one > > using LablGTK for the GUI and camlp4 to parse OCaml code. > > It is indeed very tempting to reuse an existing OCaml parser in order to > support syntax-related features (indentation, coloring, and whatnot); > especially if you can then support syntax extension properly. > > The problem is that the editor is supposed to work even with partial or > syntactically invalid code, which is not the case for the OCaml parsers > (built-in or Camlp4-based). It would be great to have a parser for OCaml > syntax, with robust error recovery. Has anyone worked on such a project? Reusing the work done in the Yi [1][2] editor for the Haskell syntax should be pretty straightforward. Very long and painful however due to the complexity of the grammar of a real language. [1]: http://www.haskell.org/haskellwiki/Yi [2]: http://www.cse.chalmers.se/~bernardy/FunctionalIncrementalParsing.pdf -- Nicolas Pouillard http://nicolaspouillard.fr ___ 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] Favorite OCaml editor?
Excerpts from Alain Frisch's message of Tue Jan 05 14:00:36 +0100 2010: > On 05/01/2010 11:44, Nicolas Pouillard wrote: > > Reusing the work done in the Yi [1][2] editor for the Haskell syntax should > > be pretty straightforward. Very long and painful however due to the > > complexity > > of the grammar of a real language. > > > > [1]: http://www.haskell.org/haskellwiki/Yi > > [2]: http://www.cse.chalmers.se/~bernardy/FunctionalIncrementalParsing.pdf > > Thanks for the links. The paper is a very interesting reading indeed. > Its main focus is on incrementality (not reparsing the whole buffer at > every keystroke). I'm not so sure how important it is in the context of > the current discussion though: I guess that with an efficient parsing > technology and modern computers, parsing even a big buffer at every > keystroke should be fast enough. Trivial optimizations like storing the > internal state of the parser at some point could also be used if needed. Hum I doubt, or maybe you are prepared to accept more penalty than I do (I consider Emacs to be noticeably slower than Vim on keystrokes, but please don't feed the troll). > I'm more concerned about the error recovery aspect; the paper suggests > the use of annotated error recovery rules, but writing them for a > grammar like OCaml's does not seem an easy task at all. Indeed this is really a manual process but incrementally adding the rules seemed to work. Actually this is a really visual process. -- Nicolas Pouillard http://nicolaspouillard.fr ___ 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 - how to force the rebuilding of a target inside a plugin?
On Sun, 21 Feb 2010 23:15:09 +0100, Vincent Aravantinos wrote: > Hi list, > > does anybody (Nicolas?) knows if it is possible to force a target to > be rebuilt from within an ocamlbuild plugin? > > Concretely I am making a plugin for LaTeX compilation and would like > to say to ocamlbuild: > "first compile the source, then if the .aux file has changed then > recompile it". I would suggest to not try to bypass the dependency system and to instead try to make a rule that fits ocamlbuild mechanism. However the simpler is maybe to call a tool which does this job like rubber. -- Nicolas Pouillard http://nicolaspouillard.fr ___ 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 - how to force the rebuilding of a target inside a plugin?
On Mon, 22 Feb 2010 15:30:14 +0100, Vincent Aravantinos wrote: > > Le 22 févr. 10 à 14:45, Nicolas Pouillard a écrit : > > > On Sun, 21 Feb 2010 23:15:09 +0100, Vincent Aravantinos > > > > wrote: > >> Hi list, > >> > >> does anybody (Nicolas?) knows if it is possible to force a target to > >> be rebuilt from within an ocamlbuild plugin? > >> > >> Concretely I am making a plugin for LaTeX compilation and would like > >> to say to ocamlbuild: > >> "first compile the source, then if the .aux file has changed then > >> recompile it". > > > > I would suggest to not try to bypass the dependency system and to > > instead > > try to make a rule that fits ocamlbuild mechanism. However the simpler > > is maybe to call a tool which does this job like rubber. > > Great, I didn't know of this tool! I'll use it. > > Still, would have it been possible to make a dependency on the .aux > file such that ocamlbuild can be aware that this file changed in order > to launch a new compilation? No there is no such behavior, but this may be simulated by having two rules, one .tex->.aux+... and one .tex+.aux->... and putting them in the right order might work. -- Nicolas Pouillard http://nicolaspouillard.fr ___ 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] Static exception analysis or alternative to using exceptions
On Mon, 31 May 2010 16:36:22 +0200, Goswin von Brederlow wrote: > Richard Jones writes: > > > On Wed, May 26, 2010 at 06:15:05PM +0200, Hans Ole Rafaelsen wrote: > >> What experience does people have to using alternatives to exceptions, such > >> as option types or exception monads? Does use of third part libraries that > >> still throws exceptions make such approaches hard to use? Performance wise > >> it seems to be comparable to catching exceptions or matching for options, > >> so > >> I guess the difference be might a question of programming style? > > > > Personally I've found that you should only throw those exceptions > > which can be caught in a single place in the program. By this I mean > > that an exception such as Not_found shouldn't be thrown, and instead > > it would be better to use an option type (for stdlib functions which > > throw Not_found, you have to be _very_ careful that the exception > > cannot "escape"). > > Which needlessly complicates your code when it never happens. > > Imho a good module should provide both an exception and option based > interface to fit the circumstances and programming style. Since having all functions in all flavours can lead to hard to interface bloat, one should consider tiny functions to switch from a style to another. It tends to be easier to start from an option type in the case of Not_found instead of the other way around for the following reason: * The typechecker does not remind us to catch the exception. * We need a custom handler per exception. * We need to take a thunk to delay the computation. let not_found_to_option f = try Some (f ()) with Not_found -> None On the contrary look at: let from_option exn = function | Some x -> x | None -> raise exn Example: from_option Not_found (List.find p xs) Best regards, -- Nicolas Pouillard http://nicolaspouillard.fr ___ 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] build/fastworld issues
On Fri, 04 Jun 2010 10:56:51 +0300, Török Edwin wrote: > Hi, > > I have successfully built 3.12.0+dev25 with 'make world.opt', but I get > an error if I try 'build/fastworld.sh'. > Both 'make world.opt' and 'build/fastworld.sh' work fine on ocaml 3.11.2. > > Here is the error: > + ./ocamlopt.opt -nostdlib -c -g -warn-error A -I otherlibs/dynlink/nat > -I stdlib -o otherlibs/dynlink/nat/dynlink.cmx > otherlibs/dynlink/nat/dynlink.ml > File "otherlibs/dynlink/nat/dynlink.ml", line 43, characters 0-15: > Error: Unbound module Cmx_format > Command exited with code 2. > Compilation unsuccessful after building 1621 targets (678 cached) in > 00:00:18. > > This happens on Debian unstable, x86-64. > Should I open a bugreport, or is reporting to this list about problems > with trunk enough? This issue is fixed in the 3.12 branch. -- Nicolas Pouillard http://nicolaspouillard.fr ___ 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] build/fastworld issues
On Fri, 11 Jun 2010 00:02:58 +0300, Török Edwin wrote: > On 2010-06-10 23:21, Nicolas Pouillard wrote: > > On Fri, 04 Jun 2010 10:56:51 +0300, Török Edwin > > wrote: > >> Hi, > >> > >> I have successfully built 3.12.0+dev25 with 'make world.opt', but I get > >> an error if I try 'build/fastworld.sh'. > >> Both 'make world.opt' and 'build/fastworld.sh' work fine on ocaml 3.11.2. > >> > >> Here is the error: > >> + ./ocamlopt.opt -nostdlib -c -g -warn-error A -I otherlibs/dynlink/nat > >> -I stdlib -o otherlibs/dynlink/nat/dynlink.cmx > >> otherlibs/dynlink/nat/dynlink.ml > >> File "otherlibs/dynlink/nat/dynlink.ml", line 43, characters 0-15: > >> Error: Unbound module Cmx_format > >> Command exited with code 2. > >> Compilation unsuccessful after building 1621 targets (678 cached) in > >> 00:00:18. > >> > >> This happens on Debian unstable, x86-64. > >> Should I open a bugreport, or is reporting to this list about problems > >> with trunk enough? > > > > This issue is fixed in the 3.12 branch. > > > > Thanks, switching to 3.12 branch worked. > Not being familiar with OCaml development process I thought that 3.12 > will be released from trunk, I didn't know 3.12 branch existed already. The 3.12 branch is quite new. Recently forked off the trunk. Bug-fixes goes to both and breaking code goes to trunk. However since the beta release is quite soon the trunk may not be up to date. Best regards, -- Nicolas Pouillard http://nicolaspouillard.fr ___ 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] ocaml build error
On Thu, 10 Jun 2010 15:54:49 +0100, Joel Reymont wrote: > How do I fix this? Switch to the 3.12 branch instead of the trunk. -- Nicolas Pouillard http://nicolaspouillard.fr ___ 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] [Camlp4] Quotation expander with OCaml syntax
On Mon, 26 Jul 2010 16:41:46 +0200, Raphael Proust wrote: > Hi all, Hi, > I'm working on a syntax extension as part of an internship in the > Ocsigen team. The aim of the syntax extension is to split the code of a web > application in two separate files: one for the client and one for the > server. A > few transformations are to take place in the process. > > Quotations are to be transformed into client code while antiquotations can > refer > to server side values transmitted to the client at runtime. > > > In order to avoid any XY problems, here is an abstracted and simplified > example > of the expected behavior: > > (* Pre-parsed code: *) > let start = <:on< f $y$ >> in > let html_node = > span ~a:[onclick start] "some text" (* a is used for (html) attributes *) > > (* Server side post-parsed code: *) > let start _arg1 = > "call_closure(some_unique_name," ^ mymarshall _arg1 ")" > in > let html_node = span ~a:[onclick (start y)] "some text" > > (* Client side post-parsed code: *) > let _ = register_closure some_unique_name (fun _arg1 -> f _arg1) > > > > If the example isn't clear enough I can detail it a little bit more. > > > I'm unsure of what is the standard way of doing such a thing in Camlp4. What > I > have in mind is to use the original Ocaml syntax for the quotation expander. > This would (IIUC) allow me to filter the AST to transform every > antiquotation > found inside the quotation itself. > > I'm not sure this is the ideal way of doing such a thing because of the size > of > the pattern matching in the AST filter. On the other hand, because the > quotation > is supposed to contain valid OCaml code, it seems normal to reuse the > original > parser. If the <:on<...>> contents is valid OCaml syntax I would suggest you to not go in the quotations direction. You will avoid a ton of syntactic issues. What I suggest you is to directly use camlp4 filters, for instance by changing the meaning of some constructor application and labels for antiquotations: (* Pre-parsed code: *) let start = On (f ~y) in let html_node = span ~a:[onclick start] "some text" (* a is used for (html) attributes *) Have fun, -- Nicolas Pouillard http://nicolaspouillard.fr ___ 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] [Camlp4] Quotation expander with OCaml syntax
On Mon, 26 Jul 2010 17:41:58 +0200, Raphael Proust wrote: > On Mon, Jul 26, 2010 at 5:13 PM, Nicolas Pouillard > wrote: > > On Mon, 26 Jul 2010 16:41:46 +0200, Raphael Proust > > wrote: > > > Hi all, > > Hi, > > > > > [...] > > > > > > (* Pre-parsed code: *) > > > let start = <:on< f $y$ >> in > > > let html_node = > > > span ~a:[onclick start] "some text" (* a is used for (html) attributes *) > > > > > > (* Server side post-parsed code: *) > > > let start _arg1 = > > > "call_closure(some_unique_name," ^ mymarshall _arg1 ")" > > > in > > > let html_node = span ~a:[onclick (start y)] "some text" > > > > > > (* Client side post-parsed code: *) > > > let _ = register_closure some_unique_name (fun _arg1 -> f _arg1) > > > > > > > > > I'm unsure of what is the standard way of doing such a thing in Camlp4. > > > What > > > I > > > have in mind is to use the original Ocaml syntax for the quotation > > > expander. > > > This would (IIUC) allow me to filter the AST to transform every > > > antiquotation > > > found inside the quotation itself. > > > > > > [...] > > > > If the <:on<...>> contents is valid OCaml syntax I would suggest you to not > > go > > in the quotations direction. You will avoid a ton of syntactic issues. > > > > What I suggest you is to directly use camlp4 filters, for instance by > > changing > > the meaning of some constructor application and labels for antiquotations: > > > > (* Pre-parsed code: *) > > let start = On (f ~y) in > > let html_node = > > span ~a:[onclick start] "some text" (* a is used for (html) attributes *) > > I'd rather not use a constructor because it imposes a strong limitation on the > user (it basically reserves a keyword) whereas the <:on< ... >> solution does > not (<:smthg< ... >> is already "reserved"). You still qualify it if you want to avoid clashes: MyModule.On > And labeling antiquotations is far from ideal since it prevents complex > expressions from being inlined. You basically need to write: > let y = h a in > let z = g x z in > On (f ~y ~z) > instead of: > <:on< f $h a$ $g x z$ >> Nothing prevents you to reserve another syntax for going back to plain OCaml code. > What I basically need is to get an AST with antiquotations and quotations > being > special nodes. How is this achievable w/o reimplementing a whole grammar? Doing this amounts to making the almost the same thing than Camlp4OCamlOriginalQuotationExpander but with some filtering code. > The alternative solution is to use raw strings, to find antiquotation marks, > to > split the string and to reinject it in the different files. Is there a way to > keep precise _loc information this way? Yes _loc would be hard to preserve this way. -- Nicolas Pouillard http://nicolaspouillard.fr ___ 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] interest in a much simpler, but modern, Caml?
On Sun, 8 Aug 2010 14:44:11 -0400, Jeremy Bem wrote: > On Sun, Aug 8, 2010 at 1:59 PM, Florian Weimer wrote: > > > * Jeremy Bem: > > > > > To support my research, I've developed an implementation ("Llama Light") > > of > > > the core Caml language. Modules, objects, labels etc are not supported > > > (except for file-level modules). The system strongly resembles OCaml, > > > however the completely rewritten typechecker is not only much smaller in > > > terms of lines-of-code; it has a genuinely simpler design owing > > especially > > > to the lack of first-class modules. > > > > How do you deal with strings (are they mutable?) and polymorphic > > equality (is it type-safe?)? > > > > Yes and no, respectively. In other words, nothing new here. > > Strings can be made immutable (in both Llama and OCaml) by disabling > String.set in the standard library (the s.[i] <- c construct is just sugar > for a call to that function). And removing the other functions of String module which mutates strings (actually I've made an experiment in which I removed string mutability). > Is there a better approach to polymorphic equality floating around? Type classes! -- Nicolas Pouillard http://nicolaspouillard.fr ___ 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] interest in a much simpler, but modern, Caml?
On Sun, 08 Aug 2010 20:52:53 +0200, Florian Weimer wrote: > * Jeremy Bem: > > > Yes and no, respectively. In other words, nothing new here. > > Oh. I just happen to think that those two are very high on the list > of things you want to fix once you can start with a clean slate. > > > Is there a better approach to polymorphic equality floating around? > > Besides type classes? I'm not sure. It's probably possible to remove > this feature from the language, with a little bit of syntactic > overhead to pass around a matching comparison function. Yes for instance the very concise local opening notation comes in handy here: if Int.(x = 42) then ... else ... -- Nicolas Pouillard http://nicolaspouillard.fr ___ 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] interest in a much simpler, but modern, Caml?
On Sun, 8 Aug 2010 15:39:28 -0400, Jeremy Bem wrote: > On Sun, Aug 8, 2010 at 2:52 PM, Florian Weimer wrote: > > > * Jeremy Bem: > > > > > Yes and no, respectively. In other words, nothing new here. > > > > Oh. I just happen to think that those two are very high on the list > > of things you want to fix once you can start with a clean slate. > > > > > Is there a better approach to polymorphic equality floating around? > > > > Besides type classes? I'm not sure. It's probably possible to remove > > this feature from the language, with a little bit of syntactic > > overhead to pass around a matching comparison function. > > > > Maybe I should clarify that my main goal has been to bring Caml Light > up-to-date with OCaml's improvements, while keeping the type-checking code > very simple, not to try to make further improvements. In fact, I wouldn't > necessarily claim that omitting the module and object systems is an > improvement, just that it is a simplification. > > But actually, now that you mention it, I did briefly explore the idea of > removing Caml's polymorphic comparison functions. > > One issue I ran into was syntactic. How would you write: > if 'A' <= c && c <= 'Z' then ... > where c is a char, without polymorphic comparison, and without more radical > changes such as type classes? Ideally the solution would generalize to > int64s, etc. As said in my previous email local opening can help here: if Char.('A' <= c && c <= 'Z') then ... > I also found multiple instances of a pattern like > type foo = Foo of int | Goo of string > if myfoo = Foo 3 then ... > It felt tedious and perhaps destructive to re-code all of these. Having to recode them sure is tedious but very simple as well in these case: match myfoo with Foo 3 -> ... | ... > Finally, on what theoretical basis do we disallow polymorphic comparison but > retain polymorphic hashing and marshalling? Perhaps we just want all these > functions to be less convenient, e.g. isolated in their own "Polymorphic" > module. After all, Llama retains even the "Obj" module. With type clases you would have a class for each of them. For sure it make sense to keep them all like you keep the Obj module the difference is the intended usage if they are called Unsafe_generic_equality.(=), unsafe_generic_hash, and unsafe_generic_marshalling then its fine. For sure we then want to expose safer variants of those to the user. Another idea that can help would be to have only one builtin type class (no not the equality one as in SML), the Typeable class. This class simply expose a value to represent a type. In these three cases (equality, marshalling, and hashing) we will even don't look at these values, the purpose is to give us the right to behave in a non-parametric way. However it does not fix the equality for abstract types, so I don't know if the gain worth the added complexity. > If there is a broad consensus for immutable strings, I could make that > change as well, again with a bit of delay as I'll need to port things like > the relocation mechanism in the Llama linker, in order to remain > self-hosting. For sure it would a lot nicer to have at least a type for immutable strings and make the literals immutable. Then having a second type for mutable strings and two copying functions (freeze and thaw) to convert them would help you a lot in adapting existing code. Regards, -- Nicolas Pouillard http://nicolaspouillard.fr ___ 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] interest in a much simpler, but modern, Caml?
On Mon, 9 Aug 2010 09:10:43 -0400, David House wrote: > On 8 August 2010 17:47, bluestorm wrote: > > If you don't have any of these, you have to declare infix operators > > directly inside the module. You'd have a "val (=) : int -> int -> > > bool" in the "int.ml" file for example. That's notoriously painful to > > handle if you use the "open" statement : a bunch of "open" statements > > in a non-careful order and your infix operators become unusable > > because you don't know anymore where they come from. What you really > > need is some form of "explicit open", à la Python or Haskell, such as > > "from Int import (mod, of_char, to_char)" instead of the full open : > > only a few identifiers are unqualified, and you still use Int.(=), > > Int.(+) instead of polluting the global namespace. > > If you're willing to explicitly name the things you wish to import > then this doesn't seem to be a hard problem to solve: > > let mod = Int.mod > let of_char = Int.of_char > let to_char = Int.tochar You may want to import types, data constructors, exceptions, modules as well... While some of them can be mitigated data constructors cannot AFAIK. -- Nicolas Pouillard http://nicolaspouillard.fr ___ 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] specify include directories with ocamlbuild
On Tue, 24 Aug 2010 09:31:52 +0200, Hendrik Tews wrote: > Hi, Hi, > in 3.11 I used > >: I(+camlp4/Camlp4Parsers) > > in _tags to specify that ocamlbuild should add > -I +camlp4/Camlp4Parsers when compiling some_file. In 3.12 this > gives > > Warning: tag "I" does not expect a parameter, but is used with parameter > "+camlp4/Camlp4Parsers" > > What is the recommended way to specify an include directory in > 3.12? Can you try to have the following declaration in your myocamlbuild.ml pflag ["ocaml"] "I" (fun x -> S[A"-I"; A x]) The syntax foo(bar) was implicitely turned into arguments "-foo bar" for commands involving the matched files, however this was too much specific (the "-" thing) and too much coarse grained. Indeed there was no way to choose when to add this flag (linking, compiling, pre-processing, building doc...). This is now possible with thes parameterized flags, and almost backward compatible since we added default pflags: pp(_), for-pack(_), inline(_), package(_), predicate(_), syntax(_) However we didn't thought about I(_)... -- Nicolas Pouillard http://nicolaspouillard.fr ___ 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] Contribute your Camlp4 knowledge! [was: account for Camlp4 wiki]
On Fri, 3 Sep 2010 10:36:23 -0700, Jake Donham wrote: > On Fri, Sep 3, 2010 at 12:07 AM, Hendrik Tews > wrote: > > Great! Let's collect all our Camlp4 knowledge in this wiki! > > Hopefully the wiki can replace the non-existing documentation one > > day. > > For people who haven't seen it, I have a number of Camlp4 articles at > > http://ambassadortothecomputers.blogspot.com/p/reading-camlp4.html > > Would it be appropriate to cut and paste this material to the wiki? I think so. If cut/pasted in an organized way it should provide with a better long term place for this information to be. Feel free to link back to your blog if you want to. Thanks for all your reading/writting! -- Nicolas Pouillard http://nicolaspouillard.fr ___ 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