sponge45 changed the topic of #ocaml to: Discussions about the OCaml programming language | http://caml.inria.fr/
<bluestorm> hum
<bluestorm> # [1; 2; 3] % map float % fold_left ( +. ) 0.;;
<bluestorm> %%
<bluestorm> ( let % a b = b a )
<bluestorm> a "reverse $" operator
<pango> apc (http://www.boblycat.org/~malc/apc/) uses |> and |<
<malc_> aka the best thing since sliced bread
<malc_> and credit were it's due |> |< were seen on Don Syme's ch9 video and stolen from there
<malc_> s;were;where
<pango> I like this notation too
<malc_> Dear to unixish plummers
<malc_> s;plummers;plumbers
<malc_> not my day apparently
<mbishop> dockapp support for icewm eh? neat
<malc_> and in ocaml too, can you imagine?
<mbishop> :)
* mbishop checks the source
<mbishop> I like :D
<malc_> i share the sentiment
smimou has quit [Remote closed the connection]
bluestorm has quit ["Konversation terminated!"]
mbishop has quit [Remote closed the connection]
mbishop has joined #ocaml
malc_ has quit ["leaving"]
tapple has joined #ocaml
mbishop has quit ["Leaving"]
mbishop has joined #ocaml
mbishop has quit ["Leaving"]
mbishop has joined #ocaml
Smergo has quit [Read error: 110 (Connection timed out)]
mbishop has quit ["Leaving"]
mbishop has joined #ocaml
<mbishop> How do I destroy a dialog without destroying the parent in lablgtk2?
shawn has quit [Read error: 110 (Connection timed out)]
Smerdyakov has quit ["Leaving"]
diffbavis has quit [Read error: 54 (Connection reset by peer)]
Mr_Awesome has joined #ocaml
diffbavis has joined #ocaml
<mbishop> Can someone help me with the Unix module? I can't seem to get execvp to take any arguments
Mr_Awesome has quit ["...and the Awesome level drops"]
<tsuyoshi> how are you calling it
Jules__ has joined #ocaml
pants1 has quit [Read error: 110 (Connection timed out)]
slipstream has joined #ocaml
Jules__ has quit ["Leaving"]
shawn has joined #ocaml
johnnowak has joined #ocaml
diffbavis has quit [Read error: 54 (Connection reset by peer)]
Lacrimosa has joined #ocaml
<Lacrimosa> Hello, World!
<Lacrimosa> ha!, it works!
Lacrimosa has left #ocaml []
<flux-> mbishop, are you aware how the system call execvp works?
<mbishop> not really
<flux-> mbishop, you are supposed to pass the program name as the first (number 0) argument
<flux-> which can be easy to miss
<mbishop> oh you mean the string array needs to include the program name as well?
<flux-> yes
<mbishop> Ah, that explains it
<mbishop> thanks :)
<flux-> execvp("program", [| "some name - doesn't need to be the real one"; "arg1" |])
<flux-> that's what you see as the process' name in the ps list
pstickne has quit ["Leaving"]
bluestorm has joined #ocaml
Riesz has joined #ocaml
Smergo has joined #ocaml
johnnowak has quit []
zagzig has quit ["abandonado"]
cmeme has quit [Remote closed the connection]
cmeme has joined #ocaml
bluestorm has quit ["Konversation terminated!"]
ikaros has quit [Read error: 110 (Connection timed out)]
ikaros has joined #ocaml
mnemonic has joined #ocaml
<mnemonic> yo
love-pingoo has joined #ocaml
swater has joined #ocaml
diffbavis has joined #ocaml
_JusSx_ has joined #ocaml
zygomatik has joined #ocaml
<zygomatik> hi it sometimes happen that ocaml toplevel complains like : blabla has type t but it is here used with type t. With the same t ! What is it trying to tell me ?
<jlouis> zygomatik quick guess: the t's lives in different modules?
<zygomatik> jlouis, nope same module
<jlouis> um
<jlouis> then we need to see code I guess
<zygomatik> ok i'll try to extract the pieces from it
<zygomatik> or is there a way I can copy and paste it somewhere without annoying everybody (it's 150 lines long)
<zygomatik> ok I have an idea i'll post it on a file server
<zygomatik> well hum I cooked the file to post it but then I'm unable to reproduce the weirdness I was talking about :)
<zygomatik> it all works fine
<zygomatik> weird
<zygomatik> but good
<zygomatik> :)
<zygomatik> But as far as I remember it's not the first time this weird error happens. Am I alone in the world :( ?
<zygomatik> anyway thanks jlouis
<zygomatik> While I'm here i have another question why this let stat = Graphics.wait_next_event [ Graphics.Button_down ] in
<zygomatik> let x1,y1 = stat.mouse_x,stat.mouse_y
<zygomatik> doesnt work
<zygomatik> More precisely
<zygomatik> it complains that mouse_x are not fields of stat
<zygomatik> but recognizes them when I open the Graphics module
<zygomatik> i dont understand
<pango> <zygomatik> But as far as I remember it's not the first time this weird error happens. Am I alone in the world :( ?
<pango> where would you go to check that ?
<pango> it's in the FAQs
<pango> if you "redefine" a type, the old one is shadowed
<pango> and for your second question, field names are in their respective module namespaces, like other definitions
<zygomatik> ok thank you pango
<pango> so if you don't open the Graphics module, you need to write stat.Graphics.mouse_x, stat.Graphics.mouse_y
<zygomatik> I see
<pango> weird but true ;)
<zygomatik> yes a little weird
<zygomatik> but i understand
<zygomatik> could you give me the link for the FAQ because i can only find the one of caml-light
<pango> actually it's not in the FAQ, it's in the user manual... http://caml.inria.fr/pub/docs/manual-ocaml/manual022.html#s:comp-errors
<zygomatik> thanks again
<pango> np
bluestorm has joined #ocaml
<pango> about stat.Graphics.mouse_x, etc. another common trick if you want to avoid opening modules, is to use module aliases
<pango> module G = Graphics ...stats.G.mouse_x, stats.G.mouse_y
<pango> so it's in the faq too :)
<zygomatik> i get it
<zygomatik> yes they describe exactly what i did : reload many times the same file
malc_ has joined #ocaml
diffbavis has quit [Read error: 54 (Connection reset by peer)]
ikaros has quit [Read error: 113 (No route to host)]
ikaros has joined #ocaml
Smerdyakov has joined #ocaml
<flux-> nice, I converted synchronous network handling to asynchronous (separate thread splitting incoming messages either to responses or spotaneous queues), and it worked the first time it compiled!
<flux-> although I cannot totally give the credit to ocaml (its static typing doesn't cover thread synchronization etc), it still has a big part in it ;)
<malc_> spotaneous?
<malc_> interesting
pango has quit [Remote closed the connection]
pango has joined #ocaml
<vorago> What would you use for sockets? Unix module?
<vorago> Will it be portable? Or should I use rather ocamlnet?
<Smerdyakov> Use SML instead, where the standard library has a much nicer socket interface. ;)
<vorago> Hey, but I'm writting it to learn ocaml.;)
swater_ has joined #ocaml
<vorago> So I'll go with Unix.*
swater has quit [Read error: 60 (Operation timed out)]
benny has joined #ocaml
benny_ has quit [Read error: 110 (Connection timed out)]
diffbavis has joined #ocaml
tapple has left #ocaml []
<vorago> Smerdyakov, this interface is not so bad; I haven't seen open_connection and friends.
<Smerdyakov> vorago, I consider it horrible, because it uses the generic type 'file_descr' for sockets.
<vorago> Hm. I see this rather normal; But it might be a negative for strongly-typed langage.
<Smerdyakov> Yes, it's horrible because ML type systems let you do much better.
<jlouis> Smerdyakov, what is file_descr? An int?
<Smerdyakov> jlouis, abstract
<jlouis> ah, the UNIX approach was used I see
<Smerdyakov> Almost. UNIX exposes file descriptors as ints, in my experience.
<vorago> But the same for sockets, files, fifos, ...
<vorago> I see your point.
<Smerdyakov> vorago, see the SML type system for a use of phantom types to prevent mix-ups between which sockets are used for listening and which for active connections.
<Smerdyakov> Er, see the SML Standard Basis, that is.
<vorago> Maybe someday; Today i'm trying to learn a bit more ocaml.
<vorago> I've written already one program: gtk fractal generator. If somebody is willing to take a look and comment i would be grateful. (-;
<vorago> Before ocaml I started with SML; but gave it up. Ocaml seems nicer for me. Maybe it's just ocamlopt.
<vorago> Or imperative+functional+objective combo.
<Smerdyakov> What about 'ocamlopt' is 'nicer'?
<vorago> Native code compilation is nice.
<Smerdyakov> All the major SML compilers produce native code.
<Smerdyakov> And the best (MLton) produces significantly more efficient native code than OCaml does.
<jlouis> Smerdyakov, I am not sure I agree too much with that. Ocamls native compiler tend to produce extremely effective code
<vorago> Ok - i've misunderstood you. Thought SML is SmallTalk.
<Smerdyakov> jlouis, this is trivial to see looking at any large project that uses abstraction and modularity. No local optimizer can touch whole-program.
<jlouis> Smerdyakov, on the other hand, we know that for any substantially big program there will be a small area taking up all of the computation. This is rarely cross-module
<Smerdyakov> jlouis, it is in my experience, using many higher-order functions from the Basis and elsewhere.
<jlouis> there are some advantages to whole-program compilation which ocaml cannot gain. But this is only one stone out of many.
<Smerdyakov> I'm not aware of any other "stone" where OCaml has an advantage over SML.
<jlouis> vorago, SML is Standard ML, which is one of the major ML dialects
<vorago> I've checked already; But thanks. ;)
<bluestorm> Smerdyakov: Object extension ? :-°
<Smerdyakov> bluestorm, we were talking about compilation techniques.
<bluestorm> aah
<bluestorm> hum, doesn't ocaml do a clever modular compilation thing ?
<Smerdyakov> I don
<Smerdyakov> I don
<Smerdyakov> I don't understand what you mean.
<vorago> For each .ml there's once called ocamlopt.
<vorago> So it CAN'T optimize ,,whole-program''.
<bluestorm> Smerdyakov: you do not have to compile the modules that didn't change
<Smerdyakov> bluestorm, maybe I should also make it clear that I'm talking about efficiency of the resulting binaries, not the compilation process.
<bluestorm> hum
<bluestorm> ok
<bluestorm> but this is a "compilation technique", altought not efficiency-oriented
<jlouis> oh it is efficiency-oriented
<bluestorm> (although)
<Smerdyakov> Then feel free to pretend I said "efficiency of resulting binaries" instead of "compilation techniques."
<Smerdyakov> Also, of course, SML has separate compilation, too.
<bluestorm> hum
<Smerdyakov> Like every other language with a compiler in existence. ;)
<bluestorm> but you can't have both separate and whole-program compilation, can you ?
<Smerdyakov> You can have implementations of both for the same language, which is SML's situation.
<jlouis> MLton only does whole-program compilation
<bluestorm> ok
<bluestorm> hum
<jlouis> SML/NJ can do separate compilation. As can MLKit if I remember correctly
<bluestorm> btw i recently failed to compile SML/NJ
<bluestorm> but it's another story ^^
<Smerdyakov> I've never had problems compiling SML/NJ.
<jlouis> The choice of whole-program compilation gives you certain advantages later on. It more or less guides a number of choices later on in the compilation phase
malc__ has joined #ocaml
smimou has joined #ocaml
malc_ has quit [Read error: 110 (Connection timed out)]
<mbishop> What's the easiest way to fill the string array if parsing input to give to Unix.execvp?
<pango> it's often easier to build a string list, then use Array.of_list
<mbishop> ahh, yeah I was figuring that, I'll use String.split and split at spaces I suppose
<mbishop> Also, are compiler warnings normal with lablgtk?
<malc__> yep
<malc__> -w y will silence (most of) them
<mbishop> Ah nice, thanks
johnnowak has joined #ocaml
<vorago> Uhm; Lame question; Can function return invariant type? If so how?
<vorago> I have a function that returns pair - two channels, but might fail with error and return string description...
<vorago> Should I rather use exception for this task?
<malc__> let func () = try `Ok (Unix.pipe ()) with exn -> `Exn exn
<Smerdyakov> Don't use polymorphic variants for such junk!
<jlouis> vorago, what is your going to do in the case of the error? If it is just passing it on further up the call-stack, then there is no reason not to raise an exception on it.
<flux-> smerdyakov, why not?
<flux-> hm, if two of my topmost functions in gprof are mark_slice and sweep_slice, it is gc that's consuming the time, right?
<flux-> any helpful suggestions what to do about it?-) maybe I could use mutable records instead of tuples to reduce memory allocation
<pango> flux-: those are functions of the gc, yes
<jlouis> flux-, exactly. You need to lower the memory pressure. Can you do allocation profiling in OCaml?
<flux-> I'm wondering though why that happens - maybe I have a genuine bug there too, but my program doesn't appear to increase its resident size very much from the number before the stalling begins
<flux-> jlouis, I don't know a tool for that.
<pango> there's a compiler patch... http://www.pps.jussieu.fr/~smimram/, ocaml-memprof
<jlouis> seems like MLton fares much better in that respect...
<jlouis> it even produces nice dot-call-graphs for you, heh
<flux-> actually, there were two bugs, it wasn't only the gc which had work to do.. but I don't still understand why the rest of the work didn't appear in gprof
<vorago> I'm back; reading.
<vorago> jlouis, well; I'm making a connection. If everything is all right - I must store somewhere in module them for further use.
<vorago> jlouis, uhm; I must store two 'pipes'. If there's an error -- I would like to print a message and quit or retry.
<vorago> However action depends on main program and not this module.
<vorago> Ok, i can do this with exception; Is there a method of returning variant without using polymorphic methods as Smerdyakov says?
<Smerdyakov> Of course.
<Smerdyakov> type 'a lalala = Good of 'a | Exception of exn
<vorago> Hm. (-;
<Smerdyakov> Why "(-;"?
<vorago> It's a smiley, not ocaml syntax. ;-)
<vorago> Now I just create function, and return exception or anything at all.
<Smerdyakov> But why did you choose to apply it to that line?
<vorago> Couse i find it tricky. And, personally would never work out the use of 'a here.
<vorago> Cause.
<vorago> I was trying with: type stream = Error of string | Channels of in_channel * out_channel;;
<Smerdyakov> I would call that very basic OCaml.
<Smerdyakov> So it would be worthwhile getting to the point where you don't find it tricky.
<vorago> I'm writting my second program.
<vorago> And I'm actually trying to reach that level.
<vorago> ;)
<vorago> Could you tell me why my version woudn't work? Ocaml inferred my func as returning that pair; And when I'm trying to return a string it finds an error.
<vorago> I don't know how to force returned type.
<mbishop> Can I use String to split a string by spaces, or should I just use Str?
<Smerdyakov> vorago, let me guess. You tried to return a string without using the Error constructor.
<vorago> You're right; I will show you: http://temp.thera.be/IRC.ml
<Smerdyakov> So read the manual.
<Smerdyakov> Read the whole tutorial before writing a single line of code.
<Smerdyakov> You obviously haven't read about variants.
<vorago> Em, thanks.
<vorago> (works)
zeeeeee has joined #ocaml
love-pingoo has quit ["Connection reset by pear"]
malc_ has joined #ocaml
malc__ has quit [Read error: 110 (Connection timed out)]
<mbishop> I wrote a simple run dialog thinger in ocaml, here's the source: http://mbishop.esoteriq.org/code/orun.ml
<mbishop> suggestions for improvements to the code are wanted :)
malc_ has quit [Read error: 110 (Connection timed out)]
<pango> ocaml{c,opt} doesn't report "unused identifier" warnings for identifiers that start with a _
<pango> so you can also remove warnings using let _label = GMisc.label ~text:msg ~packing:diag#vbox#add () in ... etc
<mbishop> ah
<mbishop> thanks for that :)
huyga has quit ["I WILL BE BACK"]
<pango> regexp " +" works just fine
<pango> you get a (caught) exception with List.hd when the input field is left empty
<mbishop> any better way to handle that?
<pango> you could match the list against the usual [] and h :: q
<pango> and report some error in [] case
<mbishop> that exception is uncaught over here
<mbishop> anyway yeah, good idea
<pango> you could report more detailed unix errors:
<pango> | Unix_error (e,f,p) ->
<pango> cmd_error (Printf.sprintf "%s(%s): %s" f p (error_message e))
<mbishop> Er
<mbishop> I'm having a hard time trying to figure out how to match cmd only if there is a head/tail
<pango> match pinput with
<pango> | [] -> cmd_error "No command entered."
<pango> | cmd :: _ -> (* code as before *)
<mbishop> ahhh right, thank you
<mbishop> this is great, learning a lot :)
fax has joined #ocaml
<fax> hi
<pango> mbishop: as you start linking more modules, you may find ocamlfind convenient: ocamlfind ocamlopt -package lablgtk2,unix,str -linkpkg gtkInit.cmx orun.ml -o orun
<mbishop> might just be easier for me to use an if heh
<pango> mbishop: pattern matching is usually shorter, in my opinion more readable, and the compiler gives you warnings if you forget cases
<mbishop> if input#text = "" then
<mbishop> cmd_error "No input."
<mbishop> else
<mbishop> seems shorter to me heh
<pango> if your command line parsing gets smarter (trim spaces before/after command,...) testing whether the input string is empty won't be exactly the same thing
<mbishop> match input#text with
<mbishop> | "" -> cmd_error "No input."
<mbishop> | _ ->
<mbishop> seems to work too
zygomatik has left #ocaml []
<mbishop> in fact, I should check before pinput shouldn't I?
<pango> what for, if that case is already handled correctly it's no longer a special case
<mbishop> hmm?
<mbishop> I think I should check input befor trying to split it
<pango> I doubt Str.split on an empty string is a heavy cpu task ;)
<pango> (btw I was wrong, Str.split already handles delimiters at the beginning and end of string)
<mbishop> wrong about what?
<pango> your current version already handles correctly commands made only of spaces, for example
<pango> and would react correctly... Something testing input#text against "" doesn't catch
<pango> personally I'm against adding code to handle special cases that don't exist; It's just another occasion to add bugs
<mbishop> well I changed it to the pattern match you suggested anyway
mnemonic has quit ["leaving"]
<mbishop> Anything else you suggest? (I don't care too much about specific unix_error cases, at least not right now)
<pango> not really... looks fine as-is. Maybe some lablgtk2 guru will have other suggestions, validate command with return key, etc.
<mbishop> Ah, that is something I wanted to do heh, have enter run the command...I thought I might need to focus the button or something, so enter presses Run
* mbishop shrugs
<mbishop> anyway, thanks for all the help :D
<pango> np
<mbishop> pango: for that ocamlfind suggestion from earlier, why do I still have to link gtkInit, but not the others?
bluestorm has quit [Remote closed the connection]
<pango> IIRC, gtkInit is not part of default lablgtk2; it's just a small additional module that provides a default main loop, or something
<mbishop> ah
<mbishop> that makes sense
<pango> it's not required if you write your own
<mbishop> Is anyone still working on wxOcaml?
<pango> (* Does the initialization for toplevels *)
<pango> let locale = GtkMain.Main.init ()
<pango> that's roughly what gtkInit is all about :)
_JusSx_ has quit [Client Quit]
<mbishop> heh
smimou has quit ["bli"]
cypher23 has quit [Read error: 110 (Connection timed out)]
<fax> gr
<fax> I just installed ocaml and glcaml
<fax> I triedf the example off wrikipedia but it doesnt work
<fax> does anyonee have a really minimal example for glcaml?