Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
320 lines (319 sloc) 23.3 KB
00:38:54 <NaCl> adrien: does the default lablgtk2 META need to link in{o,x}?
01:04:54 <thelema> NaCl: only if you're compiling w/ threads
01:05:15 <thelema> NaCl: I'd recommend not, and using the event loop to get your work done
01:05:44 <NaCl> thelema: What's being done is calling an external process
01:05:59 <NaCl> and using the event loop to monitor the changes in it's stdout
01:06:23 <NaCl> and this is an exceedingly slow process
01:08:51 <thelema> ah, hmm... well, you don't need a thread to do that.
01:09:58 <NaCl> Well, not in GTK itself, I guess
01:10:05 <NaCl> just use Unix.create_process, right?
01:10:11 * NaCl is recycling oldish code
02:15:33 <orbitz> NaCl: Lwt works great for that
02:16:20 * NaCl wonders if he wants to make yet another spec file
02:18:27 <NaCl> orbitz: indeed, does look interesting. But GTK will be handling the mainloop stuff
04:41:43 <adrien> thelema: why do you recommend against linking lablgtk with threads?
04:42:18 <adrien> NaCl: lwt is really simple to use with lablgtk and works pretty well too, I think you can chose the way you want
08:20:41 <gildor> anybody aware of an OCaml library for prime numbers generator/test/factorization ?
09:50:26 <NaCl> adrien: so, use lwt to start the process, then use glib's fd monitoring for the mainloop?
10:12:17 <f[x]> gildor, I could find some code if you want, not a library
11:11:32 <gildor> f[x]: that is just to know, if it is worth creating a library with some pieces of code that I gather while doing Project Euler
11:12:57 <f[x]> actually, as I think of it, cryptokit should have such code
12:25:33 <adrien> NaCl: should be something like "Lwt_glib.init ()", nothing more than that
12:25:38 <adrien> the rest is automatic
12:41:55 <likebike> I was watching one of the lecture videos on the Janestreet website, and Yaron Minsky said something to the effect of "OCaml has object-oriented support, but nobody uses it! Even the creator of the object system doesn't use it." Would you guys say this is a fairly accurate statement?
12:42:09 <ezyang> That was certainly my impression of it.
12:42:36 <rproust> the creator uses the OO type system for typing JS objects in js_of_ocaml
12:42:39 <likebike> I was reading about the object system, and the need to always deal with "explicit" types seemed to make things complex.
12:42:43 <flux> some use it, for example ocamlnet
12:42:47 <adrien> lablgtk uses objects so actually, people do use it
12:43:04 <flux> the thing about ocaml oo is that it is sort of an advanced subject
12:43:08 <adrien> that was an exageration
12:43:23 <flux> you might end up with curious error messages which can be difficult to understand
12:43:40 <adrien> what flux said, and it's good to tell learners not to use oo in ocaml: better wait a bit
12:43:41 <flux> but, ocaml's oo is a great system in any case
12:44:08 <adrien> I've seen several people jump to oo in ocaml immediately, and that's not a good thing
12:45:16 <likebike> ok, thanks
12:48:22 <hcarty> likebike: I jumped in to OCaml's OO support early in my OCaml learning time. I thought it was very cool, used it everywhere in my code... and was then bitten horribly because I hadn't used it properly.
12:48:44 <likebike> haha. k. I'll wait a while. :)
12:49:03 <hcarty> likebike: The OO system in OCaml is very cool, but it requires a different kind of discipline from a user
12:50:26 <hcarty> It's worth learning! But it's important to remember that the compiler doesn't protect as nicely as it does when using a functional programming style.
12:51:51 <hcarty> Protect the programmer that is... as flux said, the error messages can become cryptic and/or HUGE
13:50:10 <thelema> gildor: check out batteries/examples/euler/
13:51:03 <thomasga> does ocaml-installer still alive ? the hg repository seems to be dead on ocamlforge
13:54:11 <f[x]> gildor, is there some stable url to download latest version of package from oasis-db?
13:54:22 <f[x]> i.e. without version number
13:55:53 <thelema_> f[x]: at the moment, you can do that in two steps: first get<pkgname>
13:56:23 <f[x]> ok, I see
13:56:31 <thelema_> this is a simple key=value file, the key `tarball` has the name of the latest version
13:57:35 <Tommytom> Hello, how can I give an object to a arg method of current class ?
13:58:52 <thelema_> Tommytom: you want to pass an object as a method parameter?
13:59:32 <Tommytom> yes but an instance of current class
14:03:45 <thelema_> class foo = object (self: 'mytype) method another_me : 'mytype -> unit = fun obj -> ... end
14:07:34 <Tommytom> but
14:07:35 <Tommytom> here
14:07:39 <Tommytom> method sendOtherPck c =
14:07:39 <Tommytom> let i = 0 in
14:07:39 <Tommytom> while (i < (List.length c#list_pck)) do
14:07:54 <Tommytom> Where c is the object
14:10:14 <thelema_> the key is the (self: 'mytype) after `object` combined with marking the argument as mytype
14:10:33 <thelema_> but why don't you want the inferred type?
14:11:14 <Tommytom> I don't know what it is inferred type.
14:16:23 <thelema_> if you just use c as an object, its type will be inferred based on how you use it, including what methods it needs and the type of those methods
14:16:44 <thelema_> you don't need to do anything special
14:22:21 <Tommytom> mmh okok
14:22:32 <gildor> thomasga: hg repository for ocaml-installer: ssh://
14:22:43 <gildor> thomasga: but latest commit is pretty old
14:23:13 <thomasga> ok thanks
14:25:35 <Dalida> helo, were can i find a list of projects based on ocaml, and what are best and most recent books on this language?
14:28:55 <thelema_> Dalida: has many ocaml projects
14:35:01 <rproust> Tommytom: you seem to be using the i as a variable in you pasted example
14:35:50 <rproust> `let i = 0 in while (i< e1) do e2 done` either loops indefinitely or does nothing but evaluating e1
14:36:08 <rproust> ohh
14:36:11 <rproust> my mistake
14:36:29 <rproust> nevermind
14:42:04 <f[x]> thelema_, what is used as package name in url - findlib name or what?
14:42:25 <f[x]> see - pkg/info/oUnit and dev/dist/ounit
14:44:44 <gildor> thelema_: mathlib -> indeed useful, but I was more thinking about prime number generator
14:45:22 <gildor> thelema_: BTW, int for factorial is a bit an "underestimate" for euleur problmes ;-)
14:45:38 <gildor> thelema_: big_int is the least we can expect
14:45:45 <gildor> (e.g. 100!)
14:50:09 <thelema_> gildor: true
14:51:56 <thelema_> f[x]: findlib name or executable name is used as package name. If a package provides multiple findlib names, it's available under all of them
14:53:30 <f[x]> 500 ->
14:53:33 <f[x]> 200 ->
14:54:00 <f[x]> 404 ->
14:54:05 <f[x]> 200 ->
14:54:25 <thelema_> f[x]: yes, odb uses the findlib name for its info files
14:55:07 <thelema_> It might be useful to expose this somewhere, as it's not necessarily obvious from the /dev/dist/name
14:55:14 <f[x]> after getting info - what to put in dev/dist/___ ?
14:56:22 <thelema_> I guess gildor could put the dev/dist/<id> into the info files
14:56:26 <gildor> f[x]: why do you want the latest tarball ?
14:58:47 <f[x]> because I want to quickly setup environment for ocaml (manually), with some curl curl curl make make make
14:58:58 <f[x]> without launching browser and remembering all upstream sites
14:59:00 <gildor> ok
15:01:11 <thelema_> f[x]: you've rejected using odb for this?
15:04:26 <f[x]> it does too much
15:04:32 <f[x]> odb_home
15:04:35 <f[x]> chdir at install
15:04:42 <f[x]> automatic sudo !
15:05:39 <f[x]> all I need is - download - make all - make install (ocamlfind is configured beforehand)
15:07:42 <f[x]> ok, sudo is configurable
15:08:24 <thelema_> chdir at install?
15:08:49 <thelema_> as for odb_home, you'd prefer it use the current directory as working dir?
15:11:52 <f[x]> no, I mean --prefix odb_home
15:12:18 <f[x]> otoh automatic deps reinstall looks interesting
15:17:58 <thelema_> ah, because without sudo, it assumes a local install.
15:18:33 <thelema_> that's easily fixable, now which way to fix it.
15:19:06 <thelema_> configurable --prefix? or auto-detect permissions for using default prefix...
15:19:23 <thelema_> is it reasonable to assume default prefix is /usr/local/?
15:19:41 <f[x]> why do you need to care about prefix?
15:20:05 <f[x]> everybody _should_ install with ocamlfind
15:21:03 <thelema_> because I need it to do a local install in my home dir on some systems
15:21:27 <thelema_> and one of my test cases was oasis, which has lots of deps, some of which aren't findlib packages, but are programs
15:23:02 <adrien> I haven't followed the whole conversation but I like to be able to select different prefix: I currently have a godi toolchain in /opt/ocaml/ and one in ~/test and maybe a third one somewhere in my home
15:23:03 <f[x]> I guess there is no good soultion for prefix for same program compiled with multiple ocaml versions
15:23:38 <thelema_> well, if it's a program, it shouldn't matter which ocaml version it's compiled with
15:23:56 <thelema_> adrien: TODO noted
15:26:23 <adrien> and I'd like to do automated testing of everything on a variety of different environment, so that'd help :P
15:26:41 <adrien> anyway, be back later
15:26:44 <f[x]> probably
15:26:51 <thelema_> adrien: I'm making the prefix thing happen now
15:27:02 <adrien> oh, great :-)
15:27:21 <thelema_> f[x]: and I'm making the "don't sudo and don't use --prefix" now too
15:28:22 <thelema_> --have-perms
15:43:54 <thelema_> adrien: I assume you want OCAMLFIND_DESTDIR repointed with a different --prefix?
15:44:49 <f[x]> better OCAMLFIND_CONF and PATH
15:45:54 <thelema_> f[x]: thanks, that is better
15:46:29 <f[x]> (but then again I would argue that it is probably out of scope of odb)
15:47:40 <thelema_> if a small tweak increases the scope of odb, I don't mind. If it's not so simple and rarely used, it doesn't go in
15:48:16 <gnuvince|work> What is the "usual" build tool for OCaml projects?
15:48:27 <thelema_> hmm, maybe `OCAMLFIND_CONF=... ocaml --have-perms foo` is better than adding prefix support
15:48:29 <gnuvince|work> I've seen OCamlBuild, OMake, OASIS, etc.
15:48:33 <gnuvince|work> Lots of choices
15:48:43 <f[x]> thelema_, that's what I wanted to say :)
15:49:05 <gildor> gnuvince|work: OASIS is not really a build tool, it is mostly a wrapper around ocamlbuild
15:49:06 <thelema_> gnuvince|work: Oasis isn't exactly a build system, it'll generate a build system for you (assuming you can describe the build system to it)
15:49:33 <thelema_> gnuvince|work: the most common build tools are ocamlbuild and make
15:49:41 <gnuvince|work> Plain old make?
15:49:42 * f[x] has a simple utility to select ocaml environment via these variables, all other tools seem to work ok with such setup
15:50:13 <thelema_> gnuvince|work: well, there's a nice ocamlmake file that you can include to improve usability of plain old make
15:50:20 <gildor> gnuvince|work: I would choose ocamlbuild alone if you don't intend to distribute your project or oasis if you intend to distribute it
15:50:33 * thelema_ agrees with gildor
15:50:47 <gnuvince|work> ok
15:50:52 <gnuvince|work> I'll look into ocamlbuild
15:50:54 <gnuvince|work> thanks
15:51:07 <gildor> gnuvince|work: though, oasis can be nice for not public project since it ease some steps wrt to setting up ocamlbuild
15:51:33 <thelema_> gnuvince|work: that said, I still use a simple makefile to run ocamlbuild, as typing `make` is easier than typing `ocamlbuild projectname.native`
15:51:41 <gildor> (e.g. generates default and a lot of required stuff for ocambuild that you'll end up setting by yourself)
15:52:08 <gnuvince|work> Great
15:52:17 <gildor> gnuvince|work: and the Plugin: DevFiles in _oasis can generate a Makefile that call the right command
15:52:29 <gnuvince|work> I don't really intend to publish this project
15:52:40 <gnuvince|work> Just a small utility for some friends and myself.
15:52:53 <gnuvince|work> I'll probably actually just give them the executable file
15:55:05 <zorun> For a small project, I usually write a small Makefile that calls ocamlbuild
15:55:49 <avsm> just download OCamlMakefile gnuvince|work
15:55:57 <avsm> it takes about 5 seconds to configure, and you can get on with coding
15:56:02 <avsm> for quick projects, thats what i use
15:56:26 <avsm> when I'm feeling like a mental workout, I switch to ocamlbuild :)
15:57:08 <thelema_> f[x]: ok, new odb with --have-perms option to turn off both sudo and any --prefix stuff
15:57:35 <thelema_> avsm: why is ocamlbuild a mental workout? because of _tags?
15:58:49 <avsm> well, when something goes wrong debugging an ocamlbuild setup can take a lot of time
15:59:11 <avsm> i just like that you define 4 variables (RESULT, SOURCES, PACKS, PREDS) and ocamlmakefile just works
15:59:38 <avsm> having said that, I've ported Mirage to be fully ocamlbuild and it's lovely now. parallel builds are great.
16:03:16 <gildor> avsm: OCamlMakefile is great for very small projects, when you start digging a little bit in it, you can go through several stages of headache
16:03:24 <gildor> avsm: esp. when something goes wrong
16:03:32 <gildor> avsm: Makefile debugging can be a nightmare
16:04:17 <rproust> imho ocamlbuild complexity/documentation ratio is way too high
16:04:26 <avsm> sure, but he wanted something small
16:05:02 <thelema_> rproust: granted, but once you figure out enough (and use the right, building becomes pretty easy
16:05:27 <thelema_> avsm: I often use ocamlbuild for single-file projects
16:07:22 <avsm> darn, still no -pack support in ocamlbuild
16:07:36 <rproust> I'll eventually have to learn it… and then I'll be too lazy writing documentation/tutorial, and I'll watch other complain, and I'll sparsly distribute tips on request
16:07:38 <avsm> that sinking feeling of going through the changelog with increasing eagerness, and then falling off the end :)
16:08:03 <avsm> rproust: ha ha, yes… writing a tutorial on it is "on my list" too
16:08:23 <avsm> sorry, -pack support in ocamldoc i meant, not ocamlbuild
16:08:29 <thelema_> avsm: huh? batteries (pre 1.0) used packs extensively and did... ah
16:22:23 <thelema_> gildor: just for you:
16:22:53 <thelema_> gildor: also, I know I had some code for primality testing, I'm looking for it still
16:57:25 <Tommytom> In C#, there is an loop which is named foreach, are there an equivalent in OCamL for lists ?
16:58:13 <thelema_> List.iter
16:59:43 <Tommytom> mmh not exactly, but maybe that can help me, thx you
17:01:20 <thelema_> Tommytom: don't discriminate against it just because ocaml doesn't need it to be a builtin
17:02:00 <thelema_> how about: let foreach x f = List.iter f x in foreach [1;2;3;4] (fun x -> print_int x)
17:06:04 <Tommytom> I try your foreach
17:07:38 <NaCl> adrien: ah, cool
17:08:00 <Tommytom> Because I must use two foreach of one List
17:09:54 <thelema_> you have a list of lists?
17:13:33 <Tommytom> no, but a list of objects, and for each, i must compare with the others
17:14:27 <thelema_> ah, ok.
17:17:15 <Tommytom> I'm a little lost
17:17:57 <thelema_> foreach objects (fun o1 -> foreach objects (fun o2 -> o1#action o2));
17:18:56 <Tommytom> not need check if o1 != o2 ?
17:19:32 <thelema_> you can do that. you can probably do some check so that you don't do both x#act y and y#act x, if you want
17:20:47 <Tommytom> OK
17:20:48 <Tommytom> thx
18:19:06 <thelema_> gildor: I leave it up to you to lift this code to big_ints:
18:29:15 <_habnabit> Is there an operator that's unary negation? (-) is binary subtraction.
18:30:33 <_habnabit> (-) 0 works, I suppose.
18:35:33 <NaCl> _habnabit: (- 1) would work too
18:36:04 <NaCl> adrien: I am wondering... how much sense would it make to split the LWT package into parts that depend on lablgtk and those that don't?
18:36:05 <_habnabit> eh? that's a value.
18:36:13 <NaCl> oh
18:36:17 <NaCl> operator
18:37:15 <flux> _habnabit, ( ~- )
18:37:39 <_habnabit> ah, thanks.
18:37:47 <_habnabit> Does that apply for all unary operators?
18:39:04 <_habnabit> apparently not.
18:46:20 <gildor> thelema_: I would probably go for a fully fledged library rather than just an examples
18:46:38 <gildor> thelema_: but thx for the code, maybe it is time for me to dig further into batteries
18:52:11 <flux> _habnabit, but it does apply to -.
18:52:23 <flux> _habnabit, I think other unary operators work as is?
19:09:02 <thelema_> gildor: no problem. Enjoy both the code and the batteries
19:58:31 <EM03> standard library is all loaded by default just not opened by default into the current "namespace" correct?
19:58:38 <EM03> join #gnu-smalltalk
20:00:31 <rproust> EM03: Pervasive is opened, other modules are openable, accessible
20:01:04 <EM03> yes just noticed some modules you had to load and open while others you could just open
20:06:43 <Tommytom> thelema_ I work on foreach, what do you think about that: let myiter obj =
20:06:43 <Tommytom> if obj#need_send_update then
20:06:43 <Tommytom> List.iter (function c2 -> if (obj != c2) then c2#sendOtherPck obj#list_pck else () ) !list_clients
20:06:43 <Tommytom> else
20:06:43 <Tommytom> () in
20:06:44 <Tommytom> List.iter myiter !list_clients;;
20:07:01 <thelema_> Tommytom: use pastebin over pasting a bunch of code, please
20:07:40 <thelema_> the "else ()" can be omitted
20:08:12 <Tommytom> Excuse me
20:08:35 <Tommytom>
20:08:36 <thelema_> other than that, it looks good.
20:08:54 <Tommytom> and this: let list_clients = ref [];;
20:10:44 <thelema_> yup, looks like that'll call A#sendOtherPck B#list_pck for every pair of distinct A & B
20:12:12 <Tommytom> just if B#need_send_update == true
20:13:33 <thelema_> ues.
20:13:39 <thelema_> *yes
20:15:55 <Tommytom> Is it correct: let list_clients = ref [];; ?
20:16:44 <thelema_> the ocaml toplevel can give you an answer to that easily:
20:16:47 <zorun> from a functional point of view, this is bad style, but it is perfectly valid :)
20:17:08 <thelema_> $ ocaml
20:17:12 <thelema_> # let list_clients = ref [];;
20:17:12 <thelema_> val list_clients : '_a list Batteries.ref = {contents = []}
20:17:19 <Tommytom> damned, I have a probleme somewhere
20:17:21 <thelema_> (ignore the bit about batteries)
20:18:12 <thelema_> zorun: I've seen worse first steps into functional programming
20:18:44 <Tommytom> I used to program in C and C#, it's difficult CamL :p
20:18:58 <Tommytom> *i'm used
20:21:26 <thelema_> keep working at it - learning ocaml style takes some getting used to.
20:22:54 <Tommytom> but I work on translation of one of mine program written in C#, not very easy to begin
20:23:46 <zorun> hum, translating a program from one style to another is a bit similar to natural languages
20:24:38 <zorun> that is, the litteral translation is often awkward
20:24:59 <thelema_> OCaml is surprisingly flexible when it comes to many programming idioms, although there's usually better ways to do things in OCaml than the literal conversion
20:25:00 <Tommytom> Litteral to begin and optimization later
20:25:30 <thelema_> not just in terms of performance, but in terms of program structure.
20:25:40 <Tommytom> Yes of course
20:26:55 <Tommytom> can you look this function and give me the prototype ?
20:26:55 <Tommytom>
20:27:20 <thelema_> prototype?
20:27:53 <Tommytom> I don't know the name in Caml: 'a -> 'b
20:27:59 <thelema_> type
20:28:02 <Tommytom> type, ok
20:28:16 <thelema_> the type depends on teh type of #send_pck
20:28:33 <thelema_> it's a list of whatever takes, "tabchar"?
20:29:01 <Tommytom> tabchar: is an array of char
20:29:38 <Tommytom> method send_pck tab =
20:29:38 <Tommytom> send sock (tabchar_to_string tab) 0 (Array.length tab) [];
20:29:47 <thelema_> also, you probably meant to write "List.iter (fun e -> this#send_pck e; printf "Send: %s\n%!" (tabchar_to_char e)) li"
20:30:25 <thelema_> instead of L2-8
20:31:00 <Tommytom> Yes, now I learn iter because of you ;)
20:32:36 <Tommytom> more easier
20:36:34 <Tommytom> But caml say: sendOtherPck : '_a -> unit
20:37:09 <Tommytom> But with a List.iter is not possible
20:40:11 <thelema_> Tommytom: works for me: method sendOtherPck : char list list -> unit
20:42:35 <thelema_>
20:42:55 <thelema_> forgive the copy/paste formatting
20:45:18 <Tommytom> mmh tabchar is an array of char
20:45:56 <thelema_> just changing tabchar_to_string will change it from char list to char array
20:46:03 <Tommytom> okay
20:46:10 <Tommytom> So I agree with you
20:46:30 <Tommytom> The problem is here: val mutable list_pck = []
20:46:49 <Tommytom> Because caml say that: list_pck : '_a;
20:47:05 <thelema_> '_a list
20:47:40 <thelema_> yes, you need to use it as a list of tabchars somewhere
20:49:29 <Tommytom> I don't understand
20:49:58 <thelema_> mutable values can't be polymorphic
20:50:05 <Tommytom> Ok
20:50:25 <Tommytom> but why it say it is a '_a, not a '_a list ?
20:50:32 <thelema_> I dunno about that.
20:51:14 <thelema_> # object val mutable list_pck = [] end;;
20:51:14 <thelema_> - : < > = <obj>
20:51:16 <thelema_> huh.
20:51:27 <thelema_> # class c = object val mutable list_pck = [] end;;
20:51:27 <thelema_> class c : object val mutable list_pck : 'a list end
20:52:47 <thelema_> hmm...
20:52:54 <Tommytom> Heu...
20:53:35 <EM03> what is the general ocaml community stance on testing?
20:53:53 <EM03> do people go test crazy like in ruby? Or do it only when they think its needed?
20:54:11 <thelema_> ocaml is generally not test crazy, as the static typing helps catch most bugs without tests
20:55:35 <EM03> I think the TDD stuff is crazy
20:55:41 <EM03> a test won't prevent the unexpected
20:56:21 <thelema_> ocaml devs are generally on the side of preventing incorrect code from compiling when possible
20:56:34 <thelema_> and designing with that in mind
21:04:59 <krktz> i have troubles compiling the core lib from jane street ; where should i ask for help?
21:05:16 <Anarchos> krktz maybe to jane street ?
21:06:09 <krktz> don't you think they'll be upset of becoming an email from a poor and probably ignorant student? :D
21:06:20 <thelema_> krktz: it's got a lot of deps, do you have them all installed?
21:06:23 <krktz> i mean, maybe there's some forum or irc channel or something
21:06:29 <krktz> yes, it's during the build
21:07:28 <krktz> (here's the error:
21:07:40 <krktz> (so i guess no one can help but they)
21:08:08 <thelema_> looks like a missing c library
21:08:31 <thelema_> are you on linux?
21:08:39 <krktz> yes
21:08:44 <krktz> archlinux
21:09:20 <NaCl> it isn't linking against the unix module
21:09:38 <Tommytom> thx thelema_, I be back tomorrow.
21:09:42 <NaCl> no, I lied
21:09:56 * NaCl stopos talking
21:10:01 <thelema_> well, you're missing librt, I think
22:24:11 <adrien> NaCl: lwt's prefers libev so splitting probably makes sense
22:25:54 <NaCl> wonderful
22:27:09 <NaCl> more work for NaCl
22:30:08 <adrien> hahaha :P
23:59:42 <alexyk> I want to export a simple string value x in an mli, do I say it as: val x: string ?
Jump to Line
Something went wrong with that request. Please try again.