06:52:19 <jpdeplaix> whitequark: it can be done (in an other style) with « for i = 0 to 4 do f i done » 06:53:40 <jpdeplaix> but you function is not very clear 06:58:49 <ski> i suppose `times n f' should be `[f 0;f 1;...;f (n-1)]' ? 07:03:38 <jpdeplaix> yes but for the return type 07:10:11 <whitequark> jpdeplaix: yeah, that would work 07:10:24 <whitequark> (I ended up writing a recursive function since it was more convenient) 09:21:06 <companion_cube> hi, I have a problem with using ocamlfind libraries with ocamlbuild 09:21:22 <companion_cube> here is a simple test case: http://ocaml.xelpaste.net/8103 09:48:07 <companion_cube> ok,looks like the package(lib) tag is also needed for .mli files 09:58:18 <Kakadu> hi! I have merlin question 09:58:48 <Kakadu> I'm studing :Locate command and it seems that sometimes it can't find location of variable 09:59:05 <Kakadu> for example in let () = List.iter (fun _ -> print_int x)  it can 09:59:20 <Kakadu> but in let y=x+x it can't locate x declared a line above 09:59:31 <Kakadu> shout this behavour be reported as a bug? 10:03:04 <Kakadu> Well, now it works 10:03:06 <Kakadu> strange 10:14:15 <kerneis> Kakadu: did you recompile in the meantime? 10:14:25 <Kakadu> nope 10:15:22 <kerneis> it might also be an instance of this "bug": https://github.com/def-lkb/merlin/issues/77 (since you mentionned "a line above") 10:16:08 <Kakadu> or maybe I didn't recompile it. I already don't know for sure 10:17:12 <Kakadu> Does merlin use its own autocomletion mechanism or ocp-index? 10:18:38 <kerneis> I'm pretty sure it doesn't use ocp-index since: depends: ocamlfind & yojson & menhir 10:19:01 <kerneis> I don't know how it does it, though 10:19:36 <kerneis> gasche once gave more details: https://sympa.inria.fr/sympa/arc/caml-list/2013-02/msg00155.html 10:19:46 <rks`> Kakadu: we don't use ocp-index 10:20:17 <rks`> and if you are trying to use « Locate » or completion on identifiers local to your buffer, you don't need to recompile 10:20:20 <rks`> it should work 10:20:43 <rks`> if it doesn't, it probably means that your code is not syntactically valid 10:21:06 <rks`> (it might also be a bug, but it's less likely :)) 10:22:28 <Kakadu> Can somebody try to place cursor to the 3rd 'x' and execute 10:22:34 <Kakadu> :Locate ? http://paste.in.ua/8621/raw/ 10:23:25 <rks`> ok 10:23:28 <rks`> so that is a bug 10:23:31 <rks`> and I know where 10:23:36 <rks`> I'll fix that 10:23:36 <rks`> :) 10:23:47 <Kakadu> should I report it as a bug? 10:23:50 <rks`> no it's ok 10:23:54 <rks`> I'll get on it right away 10:27:25 <Kakadu> hm 10:27:42 <Kakadu> does opam installs merlin.el somewhere? 10:28:20 <rks`> Kakadu: here is the fix https://github.com/def-lkb/merlin/commit/5f857f0dd52042e374971243ffde7d3e2955661c 10:29:36 <Kakadu> rks`: it helps 10:29:38 <rks`> Kakadu: it's somewhere in .opam/<your swith> 10:29:57 <rks`> so maybe .opam/***/share/merlin/emacs/site-lisp/ 10:30:20 <Kakadu> .../4.00.1/share/emacs/site-lisp/merlin.el 10:30:32 <rks`> probably yes 10:30:41 <Kakadu> I was looking for it in share/ocamlmerlin and didn't found 10:32:31 <rks`> hum, yeah 10:32:35 <rks`> that's a mismatch on our side. 10:33:10 <kerneis> rks`: wouldn't is be more robust to set delimiters to "anything but acceptable chars for an ocaml identifier"? 10:33:47 <kerneis> hmm, no, because ocaml supports latin1 identifiers 10:34:27 <rks`> kerneis: your patches are very welcome 10:34:51 <kerneis> yeah, in fact ocaml is very annoying 10:35:03 <rks`> I agree that it's a bit ugly at the moment, but I don't know how to do it properly 10:35:17 <kerneis> with its ability to define (**fooBar-é) as an operator 10:35:35 <pippijn> really? 10:35:46 <pippijn> you can have letters in operators? 10:35:54 <kerneis> no? 10:36:12 <kerneis> oh no, I'm mixing up with another language I hack on currently 10:36:18 <rks`> I think you are. 10:36:24 <pippijn> # let ( *o* ) = (+);; 10:36:24 <pippijn> Error: Syntax error 10:36:40 <kerneis> ok, so it should be doable 10:37:55 <kerneis> using some regexps based on http://caml.inria.fr/pub/docs/manual-ocaml/manual011.html#infix-op and http://caml.inria.fr/pub/docs/manual-ocaml/lex.html#infix-symbol 10:38:06 <kerneis> I'll try that but not before next week 10:38:45 <rks`> ok thank you :) 10:43:00 <Kakadu> in emacs after pressing C-c l it prints "Package to use:<cursor>". With a space after ':' it will look like nicer 10:45:03 <def-lkb> Kakadu: we'll fix that, thanks 10:48:32 <Kakadu> two connected questions 10:49:37 <Kakadu> 1) Is it theoretically possible to have a hotkey for "A-x merlin-switch-to-ml <module-under-cursor>" 10:49:39 <Kakadu> ? 10:49:50 <Kakadu> pardon, M-x* 10:50:01 <def-lkb> Certainly yes 10:51:08 <Kakadu> 2) I have module Name and Name.ml for it. I'm trying to use M-x merlin-swith-to-ml ENTER Name ENTER and it says that module is not found. Yes, I have "S ." in my .merlin. What I'm doing wrong? 10:53:39 <kerneis> Kakadu: you need B as well I believe 10:53:51 <Kakadu> B _build exists too 10:53:52 <rks`> not for that. 10:54:10 <rks`> Kakadu: no idea what's going wrong here 10:57:25 <Kakadu> strange 10:57:44 <Kakadu> there it autocompletion when I enter module name 10:58:14 <def-lkb> Kakadu: it may be a bug i fixed recently in experimental branch 10:58:18 <Kakadu> but after ENTER it says No such file (message: Not_found) 10:58:24 <Kakadu> ah 11:00:16 <Kakadu> What about merlin identation engine in emacs? Does it use tuareg's, ocp-indent's or it's own? Can you mention it in README? 11:00:55 <def-lkb> merlin does nothing with indentation 11:01:08 <def-lkb> you can use whatever engine you want :) 11:31:17 <gasche> kerneis: I thought about it a bit more and decided to pull the feature out 11:32:53 <gasche> I will apply my fix du jour in trunk, and revert version/4.01 changes corresponding to that feature 11:33:42 <Kakadu> okay 11:34:28 <Kakadu> I have 1 :: 2 ::  in my .ml file. I have set cursor on "::" and I press C-c C-l 11:34:50 <Kakadu> emacs/merlin says that 'nil not found 11:34:54 <Kakadu> +' 11:35:16 <Kakadu> it seems it happens with (|!) operator too 11:35:27 <Kakadu> is it a bug? 11:36:22 <def-lkb> I don't know how it is done on emacs side, but lexing identifiers in this context is very fragile (an hack :p) 11:44:43 <kerneis> gasche: sounds reasonable 11:46:21 <Drup> Kakadu: :: is not really an operator, that's not a good example :/ 13:20:19 <librarian> Hi all! want to write a utility (for training purposes), that will parse log file with regex (Pcre), and I couln't understand from documentation http://mmottl.bitbucket.org/projects/pcre-ocaml/api/Pcre.html is there a function, that will return array of matches, for example: 13:20:19 <librarian> line: "a:b c=d e-f", regex: "([a-z]+:[a-z]+) ([a-z]+=[a-z]+) ([a-z]+-[a-z]+)" will return ["a:b", "c=d", "e-f"] 13:22:44 <gasche> librarian: you are probably looking for extract_all_opt 13:22:54 <gasche> the Pcre interface is, however, particularly horrible to use 13:23:07 <gasche> Str in the standard library is not much better, but at least a bit simpler 13:25:18 <companion_cube> \o 13:27:18 <Qrntz> librarian, check out ocaml-re 13:55:55 <librarian> I've been trying to parse string in ocaml shell: http://pastebin.com/0CsXznNk 13:55:55 <librarian> And there are two errors: 1. Error: Reference to undefined global `Batteries' when I try to use regex " " (default regex) and 2. Exception: Pcre.Error Pcre.MatchLimit. when I try to use regex "^\\[(.*)+\\]\\[(.*)+\\] ([0-9.]+)" 14:03:42 <Kakadu> probably this link http://cadmium.x9c.fr/distrib/caml-instructions.pdf should be added there: http://ocaml.org/papers.html 14:03:46 <Kakadu> Any thoughts? 14:37:29 <gasche> Kakadu: what I expect to see in a Papers page is a list of academic articles discussing aspects of the language or its use 14:37:56 <gasche> caml-instructions.pdf would qualify more as "technical documentation" or "internals documentation" 14:38:22 <gasche> librarian: I cannot access your pastebin link 14:38:43 <librarian> intresting... 14:38:58 <Kakadu> I can't too 14:39:20 <librarian> http://pastebin.com/ZMARsQVb 14:39:25 <librarian> try this 14:40:22 <ousado> or try some paste site without ads :) 14:40:47 <ousado> I like gist.github.com 14:41:13 <Kakadu> paste.in.ua is very lightweight 14:43:55 <gasche> hm 14:44:07 <gasche> I have no idea why you have this Batteries error, this looks like an installation problem on your side 14:44:36 <gasche> would changing "open Batteries;;" to "open Batteries_uni;;;" solve this problem? 14:45:43 <librarian> Yes! Thanks, it runs 14:47:07 <librarian> It is very standart ubuntu 12.04 14:48:06 <gasche> iirc. Batteries_uni is the style used in Batteries 1.x, while 2.x versions use Batteries 14:49:34 <gasche> re. regexps, you could try the call extract_opt instead of extract_all_opt so that it only try to find one match instead of all 14:49:37 <gasche> see if it helps 14:50:08 <gasche> but if the regexp is somewhat broken (and I refuse to parse regexps by the eye, it's too exhausting), it may not 14:56:07 <librarian> Seems this works good 15:00:17 <librarian> And I still couldn't understand, why it fails with Pcre.Error Pcre.MatchLimit 15:13:14 <gasche> librarian: I have no idea 15:13:24 <gasche> Qrntz pointed you to ocaml-re before 15:13:33 <gasche> it's a pure-ocaml implementation of regexp matching, with various interfaces available 15:14:23 <gasche> it may be better-behaved 15:22:33 <pippijn> when would intersection of regular expressions with named sub-expressions be useful? 15:23:19 <pippijn> (a:hello) & (b:hel)(c:lo) = (a:(b:hel)(c:lo)) 15:24:52 <ggole> Is there any good way to test if a set is a singleton? 15:25:04 <ggole> (Good = O(1)). 15:25:32 <flux> .exists true? 15:25:51 <flux> ah, no 15:26:09 <flux> Set.split and then check subtrees if they are empty or not.. 15:26:20 <flux> or max_elt != min_elt 15:26:33 <ggole> Hmm, exists might be ok 15:26:35 <flux> or fold/iter and exceptions :) 15:26:44 <flux> no, it will tell only if there is 1 or more elements 15:26:45 <pippijn> max_elt is not O(1) 15:26:50 <flux> ah, that is correct 15:26:53 <pippijn> and neither is min_elt 15:26:58 <pippijn> they are O(depth) 15:27:04 <ggole> Oh. Hmm. 15:27:09 <flux> and Set.split is not good either 15:27:28 <flux> so the only way is then fold/iter and an exception 15:27:30 <ggole> So: a fold, passing a count as the accumulator, raising an exception after the first? 15:27:36 <flux> but actually they suck as well 15:27:41 <flux> because don't they start from min_elt? 15:27:53 <ggole> Ack. 15:27:57 <pippijn> they don't? 15:28:11 <flux> "The elements of s are presented to f in increasing order with respect to the ordering over the type of the elements." 15:28:15 <Drup> every operation will need to go to the leaf anyway 15:28:25 <pippijn> Drup: right 15:28:33 <pippijn> fold will need that, too 15:28:34 <flux> so it appears there is no way to do that 15:28:53 <pippijn> the implementation needs to provide an is_singleton 15:29:03 <pippijn> it can do that in O(1) 15:29:09 <flux> well, other than Obj.magickin the bejesus out of it 15:29:34 <pippijn> are there more than one representation for singleton? 15:29:41 <flux> maybe it should provide a way to iterate in the tree order 15:30:05 <pippijn> if not, you can check s = Set.singleton ob 15:30:18 <flux> hey, how about this 15:30:25 <ggole> It's just Node (Empty, val, Empty, _) 15:30:31 <flux> Set.compare (Set.singleton (Set.choose s)) s 15:30:31 <ggole> Trivial :( 15:30:34 <pippijn> ggole: yes 15:30:51 <pippijn> _ = 1? 15:30:52 <ggole> choose is min_elt. 15:30:56 <flux> whyyy? 15:31:08 <pippijn> choose == min_elt :) 15:31:16 <flux> hmm, probably because "equal elements will be chosen for equal sets" 15:31:40 <flux> but I think 'choose' would have been the perfect interface for retrieving the element that is the fastest to retrieve :-o 15:31:47 <pippijn> # module S = Set.Make(String);; 15:31:51 <pippijn> # S.min_elt == S.choose;; 15:31:51 <pippijn> - : bool = true 15:32:31 <flux> well, Set should have .fast_choose then 15:32:48 <flux> it appears there is no way to get any element from Set without O(lg n) 15:34:35 <Drup> if I remember correctly, Set is a balanced binary tree, so there is no "fastest" element to retrieve ... 15:34:39 <ggole> I'm not expecting the sets to be huge, maybe I should just wrap a list. 15:34:56 <flux> drup, ..there is no root node in the seT? 15:35:21 <flux> all values are in the leafs? 15:35:24 <Drup> depend of the encoding of the tree, I don't know 15:35:32 <flux> I would expect there is a root node with a value 15:35:45 <ggole> It's an AVL tree with values at each branch. 15:35:52 <ggole> Of course one shouldn't rely on that. 15:36:04 <flux> of course, but somen values are faster to retrieve than others, yes? 15:37:04 <ggole> Yes, but you have no guarantee of which ones. 15:37:56 <flux> I think I wouldn't care in that case 15:38:14 <flux> if I did care, I would use min_elt etc.. 15:38:15 <ggole> Really the thing I want is val single: 'a t -> 'a option, and picking a value isn't helpful for that. 15:38:22 <ggole> I'll just wrap a list. 15:38:32 <ggole> And cry a bit if the sets get large. 15:57:47 <pippijn> ggole: if the sets are small, lists are actually much better 15:58:56 <pippijn> ggole: I had a priority queue with 5-30 elements and it was much faster a list than as a set 16:00:39 <pippijn> linear search for the place to insert was faster 16:00:52 <pippijn> than binary search but with the set overhead 16:02:50 <ggole> We'll see how this goes. 16:02:58 <pippijn> actually 16:03:01 <pippijn> that was a mutable list 16:03:22 <pippijn> maybe that's an unfair comparison 16:05:01 <ggole> You could do a pretty nice fast mutable set with a bit of *cough* Obj.magic 16:08:28 <companion_cube> hashtables make good mutable sets 16:09:07 <ggole> Slow union/difference/intersection though. 16:09:49 <ggole> Although the data structure I was thinking of would probably suffer the same drawback. 16:10:10 <companion_cube> assuming lookup is O(1), those operations are O(ln n) 16:10:23 <companion_cube> not too shabby, is it? 16:10:37 <companion_cube> (union may be more expensive than intersection) 16:10:52 <ggole> For hash tables? 16:11:01 <ggole> All of those are linear time afaict 16:11:35 <companion_cube> yes 16:12:14 <ggole> (Linear in the size of the table that you are not changing.) 16:15:03 <pippijn> hash tables are unordered sets 16:16:37 <companion_cube> https://github.com/c-cube/ocaml-containers/blob/master/smallSet.mli for reference ^^ 16:19:47 * ggole idly wonders why one of the type signatures has a _ 16:20:28 <companion_cube> just because it does not use the type variable 16:20:59 <ggole> But neither does is_empty, and that has a variable? 16:21:15 <ggole> (Makes sense though.) 16:22:33 <companion_cube> right 16:24:39 <nlucaroni> I'm having a hell of a time getting compilation with ocamlbuild -use-ocamlfind with c-libraries to build a cma file w/out "missing external function" messages on execution. Can someone suggest a myocamlbuild.ml file and compare where I may be going wrong? 16:31:07 <nlucaroni> ... or if someone can help me figure out the proper final link command. I feel like I've tried every permutation of options. 16:42:38 <companion_cube> sorry nlucaroni, I never compiled C stubs :( 18:32:06 <adrien> nlucaroni: try setting up an oasis project 18:32:40 <adrien> nlucaroni: I find that ocamlbuild is fairly annoying for C stubs without a myocamlbuil.ml 18:32:44 <adrien> and oasis will give you one 18:32:50 <adrien> (properly set) 21:12:26 <nlucaroni> adien: I had used oasis, but I have c-files that are generated with rules and wasn't able to include them persistently when remaking the setup. Unless there was something I missed in the docs... 21:12:36 <nlucaroni> adrien* opps, sorry.