Re: [Caml-list] ocamlfind + sexplib + bin_io
On Sat, Apr 28, 2012 at 14:12, Matej Košík 5764c029b688c1c0d24a2e97cd7...@gmail.com wrote: On 04/27/2012 08:29 PM, Markus Mottl wrote: Hi, even the following should work if everything is installed correctly: ocamlfind ocamlc -linkpkg -package sexplib.syntax,bin_prot.syntax -syntax camlp4o main.ml If I try this command, I get the same error: Camlp4: Uncaught exception: Not_found File main.ml, line 1, characters 0-1: Error: Preprocessor error Now, I am not sure what should be the conclusion. Well, the conclusion would be that there is something wrong with the installation ;-) I hesitate to claim that versions of (sexplib+bin_prot) libraries published in GODI are faulty---if I do not use ocamlfind, I can use those libraries just fine. It could be that there is more than one installation of these libraries on your system and that they are in conflict. E.g. if you ever installed type_conv outside of Godi. Do not you think that camlp4 is never expected (for any kind of input) throw an exception? Are we sure that the reported steps do not simply trigger a camlp4 bug? There is surely a reason for this exception. It might indeed be due to incompatible preprocessing modules. To make sure that things compile, please delete any potential other installations of the above libraries from your system. One problem that seems to have happened for some people is that they previously installed type-conv and bin-prot. These packages have been renamed to type_conv and bin_prot (complex reason). If they have been previously installed, you may now have both packages on your system. It seems Godi cannot determine renamed packages and will leave old ones in place. Please make sure to manually delete all files and directories in your Godi installation that match *type-conv* or *bin-prot*. If in doubt, just completely reinstall Godi. I've just tested the current release, and it works for me. Regards, Markus -- Markus Mottl http://www.ocaml.info markus.mo...@gmail.com -- Caml-list mailing list. Subscription management and archives: https://sympa-roc.inria.fr/wws/info/caml-list Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs
Re: [Caml-list] ocamlfind + sexplib + bin_io
Hi, even the following should work if everything is installed correctly: ocamlfind ocamlc -linkpkg -package sexplib.syntax,bin_prot.syntax -syntax camlp4o main.ml The currently best supported versions of type_conv, sexplib, and bin_prot can be found in my fork of Jane Street's Core library here: https://bitbucket.org/mmottl/ocaml-core-mmottl Installation is fairly easy: it only requires uninstalling all Jane Street Godi packages, type_conv, bin_prot, and sexplib, installing Oasis 0.3, and running one script build-and-install, which will install ocamlfind packages for all libraries. It may unfortunately still take a little while before Jane Street will release their latest version of Core, which should integrate the above and also finally into Godi. Until then people who want to use Core or any of type_conv, sexplib, and bin_prot are probably well-advised to not use the Godi packages. Regards, Markus On Fri, Apr 27, 2012 at 14:37, Matej Košík 5764c029b688c1c0d24a2e97cd7...@gmail.com wrote: On 04/27/2012 07:24 PM, David Allsopp wrote: Try adding -verbose to the call - ocamlfind will display the commands it is executing which may help refine the problem. With this: ocamlfind ocamlc -verbose -linkpkg -package sexplib,sexplib.syntax,bin_prot,bin_prot.syntax -syntax camlp4o main.ml I get the following output: Effective set of preprocessor predicates: preprocessor,syntax,camlp4o Effective set of compiler predicates: pkg_unix,pkg_bigarray,pkg_num.core,pkg_num,pkg_sexplib,pkg_camlp4,pkg_type_conv,pkg_sexplib.syntax,pkg_bin_prot,pkg_type-conv,pkg_bin_prot.syntax,syntax,autolink,byte + ocamlc.opt -verbose -I /home/mkosik/lib/godi/lib/ocaml/pkg-lib/num -I /home/mkosik/lib/godi/lib/ocaml/std-lib/camlp4 -I /home/mkosik/lib/godi/lib/ocaml/pkg-lib/type_conv -I /home/mkosik/lib/godi/lib/ocaml/pkg-lib/sexplib -I /home/mkosik/lib/godi/lib/ocaml/pkg-lib/type-conv -I /home/mkosik/lib/godi/lib/ocaml/pkg-lib/bin_prot -pp camlp4 '-I' '/home/mkosik/lib/godi/lib/ocaml/std-lib/camlp4' '-I' '/home/mkosik/lib/godi/lib/ocaml/pkg-lib/type_conv' '-I' '/home/mkosik/lib/godi/lib/ocaml/std-lib' '-I' '/home/mkosik/lib/godi/lib/ocaml/std-lib' '-I' '/home/mkosik/lib/godi/lib/ocaml/std-lib' '-I' '/home/mkosik/lib/godi/lib/ocaml/pkg-lib/num' '-I' '/home/mkosik/lib/godi/lib/ocaml/pkg-lib/sexplib' '-I' '/home/mkosik/lib/godi/lib/ocaml/pkg-lib/sexplib' '-I' '/home/mkosik/lib/godi/lib/ocaml/pkg-lib/type-conv' '-I' '/home/mkosik/lib/godi/lib/ocaml/pkg-lib/bin_prot' '-I' '/home/mkosik/lib/godi/lib/ocaml/pkg-lib/bin_prot' '-parser' 'o' '-parser' 'op' '-printer' 'p' 'pa_type_conv.cma' 'unix.cma' 'bigarray.cma' 'nums.cma' 'sexplib.cma' 'pa_sexp_conv.cma' 'pa_type_conv.cma' 'bin_prot.cma' 'pa_bin_prot.cma' /home/mkosik/lib/godi/lib/ocaml/std-lib/unix.cma /home/mkosik/lib/godi/lib/ocaml/std-lib/bigarray.cma /home/mkosik/lib/godi/lib/ocaml/std-lib/nums.cma /home/mkosik/lib/godi/lib/ocaml/pkg-lib/sexplib/sexplib.cma /home/mkosik/lib/godi/lib/ocaml/pkg-lib/bin_prot/bin_prot.cma main.ml + camlp4 '-I' '/home/mkosik/lib/godi/lib/ocaml/std-lib/camlp4' '-I' '/home/mkosik/lib/godi/lib/ocaml/pkg-lib/type_conv' '-I' '/home/mkosik/lib/godi/lib/ocaml/std-lib' '-I' '/home/mkosik/lib/godi/lib/ocaml/std-lib' '-I' '/home/mkosik/lib/godi/lib/ocaml/std-lib' '-I' '/home/mkosik/lib/godi/lib/ocaml/pkg-lib/num' '-I' '/home/mkosik/lib/godi/lib/ocaml/pkg-lib/sexplib' '-I' '/home/mkosik/lib/godi/lib/ocaml/pkg-lib/sexplib' '-I' '/home/mkosik/lib/godi/lib/ocaml/pkg-lib/type-conv' '-I' '/home/mkosik/lib/godi/lib/ocaml/pkg-lib/bin_prot' '-I' '/home/mkosik/lib/godi/lib/ocaml/pkg-lib/bin_prot' '-parser' 'o' '-parser' 'op' '-printer' 'p' 'pa_type_conv.cma' 'unix.cma' 'bigarray.cma' 'nums.cma' 'sexplib.cma' 'pa_sexp_conv.cma' 'pa_type_conv.cma' 'bin_prot.cma' 'pa_bin_prot.cma' 'main.ml' /tmp/camlpp99eefa Camlp4: Uncaught exception: Not_found -- Caml-list mailing list. Subscription management and archives: https://sympa-roc.inria.fr/wws/info/caml-list Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs -- Markus Mottl http://www.ocaml.info markus.mo...@gmail.com -- Caml-list mailing list. Subscription management and archives: https://sympa-roc.inria.fr/wws/info/caml-list Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs
Re: GADT examples: composable functions list (Was: Re: [Caml-list] Wanted: GADT examples: string length, counting module x)
of 'b val left : ('a, 'b) t - (('a, 'c) either, ('b, 'c) either) t (* [left af] @return computation that applies computation [af] to [l] if the input is [Left l], returning [Left result] and otherwise passes [Right r] through unchanged. *) val right : ('a, 'b) t - (('c, 'a) either, ('c, 'b) either) t (* [right af] is the dual of [left]. *) val (+) : ('a, 'c) t - ('b, 'd) t - (('a, 'b) either, ('c, 'd) either) t (* [af + ag] @return a computation that either performs [af] or [ag] depending on its input, returning either [Left res_af] or [Right res_ag] respectively. *) val (|||) : ('a, 'c) t - ('b, 'c) t - (('a, 'b) either, 'c) t (* [af ||| ag] @return a computation that either performs [af] or [ag] depending on input. *) val test : ('a, bool) t - ('a, ('a, 'a) either) t (* [test acond] @return a computation that tests its input with [acond] and returns either [Left res] if the predicate is true or [Right res] otherwise. *) end (* Functor from simple arrows with apply to fully-featured arrows *) module MkArrow (SA : SIMPLE_ARROW) : ARROW with type ('a, 'b) t = ('a, 'b) SA.t = struct include SA let swap (x, y) = y, x let first af = arr (fun (a, c) - af arr (fun b - b, c), a) app () let second af = arr swap first af arr swap let ( *** ) af ag = first af second ag let ( ) af ag = arr (fun x - x, x) af *** ag let liftA2 f af ag = af ag arr (fun (b, c) - f b c) type ('a, 'b) either = Left of 'a | Right of 'b let left af = arr (function | Left l - arr (fun () - l) af arr (fun x - Left x), () | Right _ as right - arr (fun () - right), ()) app () let mirror = function Left x - Right x | Right x - Left x let right af = arr mirror left af arr mirror let (+) af ag = left af right ag let (|||) af ag = af + ag arr (function Left x | Right x - x) let test acond = acond arr id arr (fun (b, x) - if b then Left x else Right x) end (* Instantiations of fully-featured arrows *) module Arrow = MkArrow (SimpleArrow) module ContArrow = MkArrow (SimpleContArrow) module DataContArrow = MkArrow (SimpleDataContArrow) (* Some silly fun with Kleisli categories *) (* Monad specification *) module type MONAD = sig type 'a t val return : 'a - 'a t val (=) : 'a t - ('a - 'b t) - 'b t val run : 'a t - 'a end (* Functor from arrow with apply operator to monad *) module MkArrowMonad (SA : SIMPLE_ARROW) : MONAD with type 'a t = (unit, 'a) SA.t = struct open SA type 'a t = (unit, 'a) SA.t let return x = arr (fun () - x) let (=) af g = af arr (fun x - g x, ()) app () let run af = SA.run af () end (* Functor from monads to their Kleisli category *) module MkKleisli (M : MONAD) : ARROW with type ('a, 'b) t = 'a - 'b M.t = MkArrow (struct open M type ('a, 'b) t = 'a - 'b M.t let arr f x = return (f x) let () f g x = f x = g let app () (f, x) = f x let run f x = M.run (f x) end) (* Example instantiation of a monad made from DataContArrows *) module MonadFromArrow = MkArrowMonad (DataContArrow) (* And now going back from monads to arrows *) module ArrowFromMonad = MkKleisli (MonadFromArrow) (* Some test code *) open DataContArrow let bump = arr succ let bump_n_times n = let rec loop n arrow = if n = 0 then arrow else loop (n - 1) (arrow bump) in loop n (arr id) let () = let n = 424242 in let arrow = bump_n_times n in let result = run arrow 0 in Printf.printf %d\n result - Regards, Markus -- Markus Mottl http://www.ocaml.info markus.mo...@gmail.com -- Caml-list mailing list. Subscription management and archives: https://sympa-roc.inria.fr/wws/info/caml-list Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs
Re: [Caml-list] concerning using of `deriving' syntactic plugin
On Wed, Mar 7, 2012 at 11:44, Matej Košík 5764c029b688c1c0d24a2e97cd7...@gmail.com wrote: I have found one (I guess unnecessary) disadvantage over `deriving'. If you process your *.ml file with sexplib/bin_prot preprocessor, you have to append with ... suffix to every type definition, otherwise you will get a an error report from the preprocessor. `Deriving' does not force you to do that. You can annotate only those type definitions, which for you makes sense to annotate. I'm not sure what the perceived problem is, but there should be no need to annotate all type definitions. It should suffice to annotate those for which converters are needed. This, of course, means that any types that a type definition is referring to will also need annotations (or hand-written conversion functions). Regards, Markus -- Markus Mottl http://www.ocaml.info markus.mo...@gmail.com -- Caml-list mailing list. Subscription management and archives: https://sympa-roc.inria.fr/wws/info/caml-list Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs
Re: [Caml-list] concerning using of `deriving' syntactic plugin
On Wed, Mar 7, 2012 at 12:28, Matej Košík 5764c029b688c1c0d24a2e97cd7...@gmail.com wrote: If you remove any of the with sexp clauses, you will get a preprocessor error: File main.ml, line 4, characters 18-23: Parse error: with expected after [type_declaration] (in [str_item]) File main.ml, line 1, characters 0-1: Till's fix suggestion should work, you'll have to use camlp4o as preprocessor. Btw., you also may want to open Sexplib.Std instead of Sexplib.Conv, which is the standard way. Regards, Markus -- Markus Mottl http://www.ocaml.info markus.mo...@gmail.com -- Caml-list mailing list. Subscription management and archives: https://sympa-roc.inria.fr/wws/info/caml-list Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs
Re: [Caml-list] Sexplib bug report
On Thu, Feb 16, 2012 at 20:55, bob zhang bobzhang1...@gmail.com wrote: Is it possible to separate the syntax extension from the code generation part? syntax extension is always fragile, code generation API is still pretty useful. In my opinion, the main meat lies in code generation part. Not sure, but even if, I guess it would not be easy. :sexp type t = bla bla maybe more robust, but it requires camlp4of as the basic preprocessor instead of camlp4o If there were only one preprocessor (sexplib) this would work, but having more than one (e.g. also bin-prot) does not seem straightforward. It's not clear how multiple and independently developed code generators can be composed, especially safely without interfering with each other. Regards, Markus -- Markus Mottlhttp://www.ocaml.infomarkus.mo...@gmail.com -- Caml-list mailing list. Subscription management and archives: https://sympa-roc.inria.fr/wws/info/caml-list Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs
Re: [Caml-list] [ANN] Vim plugin
Hi Pierre, thanks a lot for your contribution, I have updated the OCaml ftplugin file on my site and will submit it to Bram for inclusion in a future Vim release. Regards, Markus On Mon, Jan 30, 2012 at 16:29, Pierre Vittet pierre.vit...@inria.fr wrote: [English version below] Bonjour, Je ne sais pas si beaucoup d'entre vous utilise Vim pour coder en OCaml. J'ai eu besoin de faire quelques modifications sur le greffon officiel pour pouvoir utiliser pleinement les annotations. Je partage donc mes modifications pour le cas ou elles soient utiles à d'autres: http://www.vim.org/scripts/script.php?script_id=3906. J'ai corrigé 2 bogues et rajouté une fonctionnalité permettant d'utiliser les annotations avec l'ensemble des fichiers .ml ouverts. Jusqu'à présent il semble que les annotations ne fonctionnaient que sur le premier fichier ouvert. J'utilise ma version modifiée depuis plusieurs semaines sans problème. Si vous essayez mon greffon, je vous remercie de me faire un retour (sur les bogues ou leur absence). Merci Pierre Vittet - Hello, I don't know if many of you use Vim to write OCaml code. I had to make some change on the official plugin in order to use the annotation as I wanted. I share my modifications in the hope that they can be useful to others : http://www.vim.org/scripts/script.php?script_id=3906. I corrected 2 bugs and add a functionnality allowing to use annotations on every .ml file opened in the editor. Until now, it looks like previously annotation were working only on the first opened OCaml file. I use my modified version without any problem for several weeks. If you try my plugin, please, keep me informed of the eventual bugs. Thanks Pierre Vittet -- Markus Mottl http://www.ocaml.info markus.mo...@gmail.com -- Caml-list mailing list. Subscription management and archives: https://sympa-roc.inria.fr/wws/info/caml-list Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs
Re: [Caml-list] Let-less syntax for coreML
On Wed, Jan 4, 2012 at 07:18, Yaron Minsky ymin...@janestreet.com wrote: I think the biggest thing the community can do to improve OCaml is not to tweak around with language design. It's to improve the library packaging situation. Oasis seems to be the effort in this direction that has the most momentum, so I think pushing Oasis to become every bit as good as Hackage and Cabal is really the place to get maximum leverage. I would say that Jane Street is in a unique position to make a difference here. Having by far the largest OCaml team in the world, nobody else is as likely to benefit from and to achieve the goal of improving the library packaging situation. Just being able to attract more people to OCaml and hence potential employees would seem well worth the cost of specifically dedicating resources and pushing this project through. It is not very likely that individuals or small companies will be able or willing to support this project in the long term, and the OCaml team/INRIA understandably has other priorities (= research). Regards, Markus -- Markus Mottl http://www.ocaml.info markus.mo...@gmail.com -- Caml-list mailing list. Subscription management and archives: https://sympa-roc.inria.fr/wws/info/caml-list Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs
Re: [Caml-list] RFC: basename, dirname, PR#4549
Hi, I think the difference will mostly matter for code only that requires human input of paths, whether in a prompt or through a configuration file, and even there it would be rather unlikely to encounter such paths. Big deal, users can change their input easily. Having done my fair share of path mangling, I guess most applications that generate paths internally only, e.g. to walk through a directory hierarchy, are safe. It would seem highly unusual that anybody added an extra slash in code accessing files within a program. I personally prefer standard conformance. Regards, Markus On Tue, Dec 27, 2011 at 11:29, Damien Doligez damien.doli...@inria.fr wrote: Hello, I would like to get some comments from the OCaml community at large about the problem raised in http://caml.inria.fr/mantis/view.php?id=4549 In a nutshell, the problem is that our version of basename and dirname are not exactly the same as the Open Group's definition. We can easily implement the standard behaviour for basename and dirname, and it seems desirable, but there is a catch: we will have to change the specification of the standard library slightly. Currently, we specify this: [concat (dirname name) (basename name)] returns a file name which is equivalent to [name]. Moreover, after setting the current directory to [dirname name] (with {!Sys.chdir}), references to [basename name] (which is a relative file name) designate the same file as [name] before the call to {!Sys.chdir}. With the Open Group basename and dirname, this becomes false for names that include some trailing slashes, because such slashes are removed by basename. This means that a name foo/bar/ becomes foo/bar when put through [concat (dirname name) (basename name)] and opening foo/bar may succeed if it is a file, while opening foo/bar/ would fail. I would like to know if anyone relies on the precise behaviour documented in the standard library, and for everyone else, would you prefer the old behaviour or the new (standard) behaviour? -- Damien -- Caml-list mailing list. Subscription management and archives: https://sympa-roc.inria.fr/wws/info/caml-list Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs -- Markus Mottl http://www.ocaml.info markus.mo...@gmail.com -- Caml-list mailing list. Subscription management and archives: https://sympa-roc.inria.fr/wws/info/caml-list Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs
Re: [Caml-list] Fatal error: exception Pcre.Error(0)
Please read the pcre man page on partial matching: man pcrepartial. The reason why e.g. hsgshsn gives you a partial match is that it ends in n, and the pattern starts with n. This means that the subject string might match the pattern node if it were extended appropriately. Regards, Markus On Thu, Dec 22, 2011 at 20:21, oliver oli...@first.in-berlin.de wrote: Here is what I get in examples: let _ = let pattern = node in let doc = httpsdjshdjshdjnodeshdsden in (* true *) let doc = skjdfjjeroiurt//lkj in (* false *) let doc = skjdf in (* false *) let doc = skjdfg in (* false *) let doc = hsgshsn in (* ~flags:[`PARTIAL] = Fatal error: exception Pcre.Error(0) *) let doc = http://spnnden in (* ~flags:[`PARTIAL] = Fatal error: exception Pcre.Error(0) *) if Pcre.pmatch ~pat:pattern ~flags:[`PARTIAL] doc then print_endline true else print_endline false Rather looks like a true pcre-problem, not one of ocaml-pcre... ?! Ciao, Oliver -- Caml-list mailing list. Subscription management and archives: https://sympa-roc.inria.fr/wws/info/caml-list Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs -- Markus Mottl http://www.ocaml.info markus.mo...@gmail.com -- Caml-list mailing list. Subscription management and archives: https://sympa-roc.inria.fr/wws/info/caml-list Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs
Re: [Caml-list] PV-GADTs
On Tue, Dec 13, 2011 at 21:56, Jacques Garrigue garri...@math.nagoya-u.ac.jp wrote: In your example, how do you know in a pattern-matching that `Foo comes from t2? Type inference could be used, but I'm afraid it would be very fragile, and not easy to use. So at this point there is no plan to add GADT PVs. An alternative design would be to have extensible GADTs, where you would be able to add new cases, like for exn. I think this would be useful, and cover some uses that are not possible even with PVs. I really like using PVs for defining extensible, recursive DSLs. If it were possible to use GADTs in a similar way, that would be an awesome feature. But I wonder how this could be done cleanly. I agree that type inference would be impractical when combining PVs and GADTs, since PV constructors are not tied to a specific type. It seems you have something in particular in mind when you speak of extensible GADTs. Wouldn't such a feature require that GADTs have the same runtime representation as PVs, i.e. using the hash value of the variant name? Not sure what the GADT representation is right now anyway, but maybe this should be determined carefully before the next release if we want to add extensibility later. Regards, Markus -- Markus Mottl http://www.ocaml.info markus.mo...@gmail.com -- Caml-list mailing list. Subscription management and archives: https://sympa-roc.inria.fr/wws/info/caml-list Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs
Re: [Caml-list] Newest Sexplib and Hashtbl
Hi, There have been some changes to the newest release of Sexplib. It is now required to open Sexplib.Std to see the default converters for the standard OCaml types. The same is true for bin-prot. The code automatically generated by the preprocessor used to hard-code the converters by explicitly referring to the functions in Sexplib. But this prevented users from overriding them, motivating Jane Street to propose this change. Sorry, it seems that this change hasn't been mentioned in the docs. This will be fixed in future documentation releases. Please let me know if there are any other issues. Regards, Markus On Sun, Sep 18, 2011 at 14:41, Dario Teixeira darioteixe...@yahoo.com wrote: Hi, I've updated to the latest version of Sexplib, and the support for hashtable serialisation seems broken or at least changed. I was accustomed to using the syntax extension for convenient declaration of (de)serialisers, and this worked too for the Hashtbl module. For example: type dict_t = (key_t, value_t) Hashtbl.t with sexp But with Sexplib 7.0.4 this produces an error: Error: Unbound value Hashtbl.t_of_sexp Is this a bug, or must the (de)serialisers be declared manually with the newer versions of Sexplib? Thanks in advance for your time! Best regards, Dario Teixeira -- Markus Mottl http://www.ocaml.info markus.mo...@gmail.com -- Caml-list mailing list. Subscription management and archives: https://sympa-roc.inria.fr/wws/info/caml-list Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs