smimou changed the topic of #ocaml to: OCaml 3.08.3 available! | Archive of Caml Weekly News: http://sardes.inrialpes.fr/~aschmitt/cwn/ | A free book: http://cristal.inria.fr/~remy/cours/appsem/ | Mailing List: http://caml.inria.fr/bin/wilma/caml-list/ | Cookbook: http://pleac.sourceforge.net/
ianxek has quit ["Leaving"]
Sonarman has joined #ocaml
Sonarman has quit [Client Quit]
Sonarman has joined #ocaml
araujo has joined #ocaml
<araujo> Hello.
ulfdoz has joined #ocaml
ulfdoz_ has quit [Read error: 60 (Operation timed out)]
vdrab has joined #ocaml
haakonn__ has joined #ocaml
haakonn has quit [Read error: 113 (No route to host)]
angagon has joined #ocaml
<Nutssh> Hi.
Sonarman has quit ["leaving"]
<ulfdoz> re
<araujo> There exist a shell written in O'caml?
Herrchen has joined #ocaml
Snark has joined #ocaml
<araujo> mm...
<araujo> probably i should take that as no :-)
pango has quit [Remote closed the connection]
pango has joined #ocaml
smimou has joined #ocaml
ejt has joined #ocaml
<ejt> hi, I'm about to start writing a gui app (chess client) in ocaml. I was wondering if anyone has any advice on what widget toolkit to use (gtk, qt ?) ?
<Snark> ejt: lablgtk2 works good here
<Snark> ejt: are there ocaml bindings for qt anyway?
<ejt> re: qt, I don't know, I'm googling gtk bindings ATM
* ejt is not normally a gui programmer :)
<ejt> I'm also tempted to write it all in openGL
<Snark> directly!?
<ejt> I'm not sure how many standard widgets I need, I plan to bolt some graphics primitives onto my ocaml-scheme extension language and go from there (ie. follow an emacs style implementation)
kinners has joined #ocaml
<ejt> Snark: lablgtk2 looks good, thx for the pointer
<Snark> ejt: gtk is really easier to use with ocaml than with c
<ejt> k
<ejt> I'm also wondering about using SDL - I guess it's lower level so scares me less
<Snark> SDL is lower level indeed
vodka-goo has joined #ocaml
<araujo> Doesn't ocaml have gui libraries?
<Snark> tk, I think
mlh_ has joined #ocaml
<smimou> lablgtk2 is much better
<araujo> is it part of the language?
<smimou> no it's an external library
<smimou> tk is part of the language though
vdrab has quit ["bye"]
kinners has quit ["leaving"]
<araujo> Why this doesn't work:
<araujo> # let rec fact = function
<araujo> n when n <= 1 -> n
<araujo> | _ -> n * fact (n - 1);;
<araujo> I thought function -keyword took one argument by default.
<mrvn> Unbound value n
<araujo> yeah..
<mrvn> | n -> n * fact (n - 1);;
<araujo> mm.. i think i get it, is it because of the wildcard?
<araujo> yeah
<mrvn> The first n is only bound for the first case.
<araujo> I see.
<araujo> This is interesting, i see i can use the wildcard with match.. with
<araujo> I suppose it is because the match .. with bound the variable for all the pattern matching cases right?
<mrvn> _ is just a special variable denoting to throw the value away.
<mrvn> there is nothing bound for all the cases, each case binds it's own n.
<mrvn> let rec fact = function
<mrvn> x when x <= 1 -> x
<mrvn> | y -> < * fact (y-1);;
<mrvn> 2 totaly seperate bindings.
<araujo> How this works then: let rec fact n = match n with n when n <= 1 -> n | _ -> n * fact(n - 1);;
<mrvn> s/</y/
<mrvn> let rec fact x = match x with y when y <= 1 -> y | _ -> x * fact (x-1)
<mrvn> but that would be stupid code
<araujo> why?
<mrvn> let rec fact n = if n <= 1 then n else fact (n-1)
<mrvn> no point in using pattern matching there
<araujo> i really don't care if ther eis a point, i am just testing :-)
<araujo> So, why exactly works with the wildcard using match .. with?
<mrvn> araujo: look what is x and what is y
<araujo> yes, i thought match .. with bound the varable to the pattern
<mrvn> No. The pattern binds something, match x doesn't.
<araujo> Ok.
<mrvn> The y is bound and _ but x comes from the let
<araujo> i see
<araujo> thanks
<araujo> bye
araujo has quit ["Programs must be written for people to read, and only incidentally for machines to execute"]
bzzbzz has joined #ocaml
_JusSx_ has joined #ocaml
* Snark wonders how to clean his Makefile
vezenchio has quit [""Under democracy one party always devotes its chief energies to trying to prove that the other party is unfit to rule—and bot]
bzzbzz has quit ["leaving"]
Snark has quit [Read error: 60 (Operation timed out)]
raboof has joined #ocaml
mlh_ has quit [Client Quit]
krishna_ has joined #ocaml
<krishna_> hi all!
<raboof> hi krishna_
<krishna_> any free online books on ML, functional programming ?
<raboof> i'm going through http://merjis.com/developers/ocaml_tutorial now, but i've been using ocaml for about 30 minutes now, so there are probably people here who can point you at better resources :)
mrvn_ has joined #ocaml
<mrvn_> the O'Riley book
ejt has quit [Read error: 110 (Connection timed out)]
<krishna_> I plan to start with that.
<krishna_> the language is very terse...
* raboof already knew another functional language, Clean, so that helps
* krishna_ was simply blown off by the performance of the compiler.
aefkei has joined #ocaml
<krishna_> coming from a C/C++ background, adjusting to the fp style is a bit difficult...
<raboof> hmm. so in ocaml `then foo ; bar else' won't work, that must be `then (foo ; bar) else'?
<mrvn_> # if 1 = 1 then 1; 2 else 3;;
<mrvn_> Syntax error
<mrvn_> # if 1 = 1 then (1; 2) else 3;;
<mrvn_> Warning: this expression should have type unit.
<mrvn_> - : int = 2
<aefkei> Hi all. I'm looking for pointers to good documentation / tutorials on the "Format" library.
<aefkei> Any ideas besides the official docs?
<mrvn_> As in Printf.printf "%d + %d = %d\n" 1 2 3;;?
Snark has joined #ocaml
<aefkei> As in open Format ;; open_hbox () ; open_vbox 0 ; print_string "text1" ; close_box () ; close_box ();;
<mrvn_> For a gentle introduction to the basics of prety-printing using Format, read the FAQ at http://caml.inria.fr/FAQ/format-eng.html.
<aefkei> Yep. But this url no longer exists... I dug in a little but couldn't find it.
mrvn has quit [Read error: 110 (Connection timed out)]
mrvn has joined #ocaml
<aefkei> okay. Found it : it's now hosted by PAUILLAC.inria.fr...
mrvn_ has quit [Read error: 60 (Operation timed out)]
aefkei has quit ["ybe"]
krishna_ has quit [Read error: 113 (No route to host)]
nlv11757_ has joined #ocaml
<nlv11757_> what do one actually do when saying; "let S = module SSA"
<nlv11757_> sorry
<nlv11757_> "module S = SSA"
<mellum> Save typing, since now S is an alias for SSA.
<nlv11757_> ok then i have another question;
<nlv11757_> in ssa.ml there is a type definition; type cfgIntro = { name:string;}
<nlv11757_> what is the meaning of saying; "let ci = {S.name = "bla") in ..."
<vodka-goo> name isn't known, except in Ssa=S, so it's just a S.cfgIntro with name="bla"
<nlv11757_> that S. in front of name is confusing me
<vodka-goo> you have to prefix labels
<nlv11757_> ow ok, i thought this is where that OO came in
<nlv11757_> i was getting scared :)
<vincenz> recurods are not oo
<vodka-goo> it's a bit confusing I agree
<vincenz> records even
<vodka-goo> but type inference needs to know which "name" it is, so we need to tell it that's the "name" defined in Ssa
<vodka-goo> so it knows you've got a Ssa.cfgIntro
<nlv11757_> otherwise it could have been a Foo.foo if there is a 'type foo = { name : int }' in module Foo for example?
<vodka-goo> exactly
* vincenz nods
<vincenz> this is also the reason why labels have to be unique within a module
<nlv11757_> because of this mechanism recordfields dont have to be unique right?
<vincenz> recordfields this is
<vincenz> nlv11757_: yes
<nlv11757_> ah i understand
<vincenz> if you have them in different modules
<nlv11757_> ofcourse, qualified unique so to say i meant
<vodka-goo> actually, caml could be smarter with that, for example, identifying two identically defined records, as it does for modules... I'm not sure if it's possible theoretically, anyway it isn't currently.
<nlv11757_> structural equality you mean?
<vodka-goo> yeah, if the type definitions are the same, types should be identified
<vincenz> vodka-goo: do you expect people to often make identical records?
<vodka-goo> vincenz: it happens
<mrvn> I would rather not have ocaml mix records from different modules. If I wanted them mixed I would have made a common type.
<vincenz> Me too
<vodka-goo> in my current project we've got many definitions of what's a metadata { title : string ; track : int ... }
<mrvn> What if I change the type of one of them? Suddenly lots of stuff stops working.
<nlv11757_> it makes a bit of juggling impression on me
<vincenz> vodka-goo: to be honest, sounds like bad design
<vodka-goo> well actually, we removed that now.. but it can happen
<vincenz> a good design would abstract this into noe module
<vincenz> vodka-goo: it badly designed code, anything can happen
<vodka-goo> vincenz: what if you want to design ocaml-vorbis and ocaml-mp3id3 separetely and then merge them into a big project ?
<vincenz> vodka-goo: reuse modules
<vodka-goo> so you ask the user to install ocaml-abstract-metadata-def, one more lib
<vodka-goo> it's a bit annoying
<vodka-goo> actually, vorbis metadatas are (string*string) hashtbl.t, so there's no problem
<vodka-goo> I was just trying to make an example
<vincenz> vodka-goo: I assume that if they are two diferent programs, it matters little
<vincenz> vodka-goo: and I don't ask them to install another lib
<vincenz> vodka-goo: it's a compile time module, it gets compiled INTO the different applications
<vincenz> You're reaching to find an example... I would hope that proves something
<vodka-goo> vincenz: it's two different libs, but one may expect them to be merged easily in another app
<vodka-goo> libs are expected to be compiled once, then installed, then used
<vincenz> vodka-goo: modules are not per se compiled to libs
<vincenz> vodka-goo: moduels are like .cpp files
<vincenz> you compile a bunch of them into one lib or app
<vincenz> and there good design dictates....one datatype, one .cpp and not a dozen classes
<vodka-goo> ok but it's still annoying to make another library package for that common interface
<nlv11757_> btw anyone here ever worked with static single assignment form?
<vincenz> who's talking about library packages?
<vodka-goo> me :)
<vincenz> MODULE != LIB
<vincenz> we were talking about records...in a module
<vincenz> nlv11757_: why not go with dsa?
<vodka-goo> yes, and I'm explaining that in some cases (two libs used in a same app), a type defined twice (once in each lib) isn't recognized as being a single type
<nlv11757_> vincenz; in CIL there's a ssa module which i want to use, but im figuring out how since it wasnt integrated really
<vincenz> oh, haven't erally used CIL, I looked at it briefly
<vincenz> vodka-goo: no you're mixing binary and sourcecode
<nlv11757_> vincenz, but its a ssa question actually
<vincenz> vodka-goo: types are defined in sourcecode, not in ilbs
<vincenz> libs don't contain types
<nlv11757_> why would there only be a function transforming function definitions to ssa versions.
<mrvn> You put the type into one lib and the other depends on the first.
<vodka-goo> I'm talking of libs as ocaml-libraries, coming with interfaces
<vincenz> vodka-goo: you're mixing issues
<vodka-goo> mrvn: that's the solution, yes, but it's painful
<vincenz> vodka-goo: you can compile a few modules of code WITH the one module of the type definition in one lib
<vincenz> vodka-goo: then you compile another bunch of code with the module of the type definition in another lib
<vincenz> they share the representation
<vodka-goo> it doesn't matter so much, I'm just saying that there are examples where identifying would be useful
<mrvn> vodka-goo: normaly when you use a type of another lib you also use some of its functions. So that comes naturaly.
<vincenz> vodka-goo: imho, you're reaching to make a point
<mrvn> You can also just merge the two libs into one.
<vodka-goo> splitting is better
<vodka-goo> you want people to install only what they want
<vodka-goo> but splitting to much is annoying, you get many tiny packages (one per module)
<vincenz> vodka-goo: nothing prohibits REUSING a module in multiple libs
<vincenz> hey! it's called software reuse
<vincenz> and thereby removing the need to find identical record TYPES at compile time
<vodka-goo> vincenz: if I've module A coming with two libs, an error occurs if I compile my app against those two libs
<vodka-goo> you must call them A1 and A2 and then some identical things are different for caml
<vincenz> so therefore you'd rather duplicate the code and make two different records and then hope the compiler finds them equal, but yet still have two diffrent recorsd in the two libs?
<vodka-goo> in some cases I would do so, yes
<vodka-goo> hopefully there was no such problem really arising in our project
<vodka-goo> (but I wouldn't hope anything, I would write a dummy translation function)
CLxyz has quit [Read error: 145 (Connection timed out)]
<vincenz> I think that if you're duplicating code just because you'd like a lib less (not a package, a lib), the...
<vincenz> then... even
<vodka-goo> I would have to package that lib separately, cause two different packages would depend on it
<vodka-goo> I think we understood each other :)
<nlv11757_> can anyone guess why there's only a 'functiondefinition_to_ssa' function....
<vincenz> my point is, from a source code design point of view, there is no good reason to duplicate code, in fact it's a typically frowned upon practice...
<nlv11757_> surely that doesnt suffices
<vodka-goo> vincenz: practice is a bad guy.. you're right.
<vodka-goo> packages and modules should be the same
<vincenz> I wouldn't go that far...you don't make a lib for each .cpp file in a c++ project
<vincenz> And in fact some modules are not even usable, codewise without other modules to generate them (functors)
<vincenz> mrvn: you ever played around with monads in ocaml?
<mrvn> no
<mrvn> ocaml doesn't have true monads.
<mrvn> no callcc
<vincenz> monads and continuations are two different things
<mrvn> you can do callcc with monads
<vincenz> yes you -can-
<vincenz> but that is an application of monads
<vincenz> you can do callcc with ocaml too...just make sure everything rests on top of something that can save continuation poitn
<mrvn> and you can't do callcc in ocaml due to the stack
<vincenz> o.O
<vincenz> sure you could
<vincenz> if you put all the computations in something similar to monads..
<mrvn> ok, if you totaly transform your program to e.g. cps style.
<vincenz> that is what monads do to get callcc
<mrvn> In haskell that is somehow buildin
<vincenz> noep
<vincenz> the -library- has monads which allow one to more easily do callcc
<mrvn> but you don't need to rewrite your coding style for it in haskel.
<vincenz> it's les work
<vincenz> but I wonder whether it's possible to rewrite the standard ocaml library so it's fully monadic
<mrvn> doesn't work naturally in ocaml.
<vincenz> if so then it would be just as much effort in ocaml
<mrvn> let foo = (bar ()) + (blub ())
<mrvn> that already destroys continuation mondas.
<mrvn> anything non tailrecursive will with the current compiler.
<vincenz> I'm saying rewrite the entire library
<vincenz> so + also works on monads
<vincenz> as well as calling stuff
<mrvn> write a new compiler. sure go ahead.
<vincenz> no the library
<vincenz> nm
<mrvn> I could be wrong but I think recursive calls are part of the compiler.
<raboof> does ocaml have hashtables built-in?
<vodka-goo> yes
<vodka-goo> module Hashtbl
<mellum> well, that's not exactly built-in
<raboof> yeah, but good enough for me ;)
<mrvn> basically nothing is built-in
<mrvn> (which I like)
<Smerdyakov> Polymorphic hashing is either built-in or implemented by a naughty C library, which are effectively equivalent.
<mrvn> part of the stdlib anyway.
<Smerdyakov> Polymorphic hashing is fundamentally a hack. I'd even argue it could be considered a language flaw if a library could implement it.
<mrvn> why? then marshaling and Obj.* is also a flaw.
Gueben has joined #ocaml
<vincenz> they are hacks
<Smerdyakov> Yup, they are.
<mrvn> you could define a buildin hash function that gets automatically derived from the type definition instead of poking into the memory representation.
<mrvn> having it in a normal library is nicer I think.
<Smerdyakov> Haskell-style type classes provide a better mechanism.
<mrvn> bah, go join #haskell
<mrvn> :)
<vincenz> Smerdyakov: how would you react to this statement "monads don't work properly in non-lazy languages"
<Smerdyakov> Doesn't seem fundamentally true to me.
<Smerdyakov> (From what I know now)
<vincenz> well the case that's in my mind is this....
<vincenz> in haskell if you do IO, then it must return an IO monad
<mrvn> asm is non-lazy, right? So how come haskell monads work?
<vincenz> print : String -> IO () for isntance
<vincenz> however...
<vincenz> fun s -> let a = print s in ()
<vincenz> this function has type signature String -> () even though it does IO
<vincenz> in haskell this wont' work as let is lazy and since a is not used, print will not run
<mrvn> fun s = function () -> let a = print s in ()
<Smerdyakov> vincenz, it doesn't _use_ IO. It just builds a value of type IO ().
<Smerdyakov> vincenz, and then discards it.
<vincenz> right...
<Smerdyakov> vincenz, so no problem there.
<vincenz> well one of the nice parts of monads in haskell is that as soon as you DO io, it must return a value of type IO
<mrvn> vincenz: thats just a matter of having all I/O functions of that type.
<Smerdyakov> vincenz, you're using the wrong formalism, I think. "Doing IO" and constructing values of IO are separate.
<mrvn> vincenz: can you do "ignore (print_int 1)" in haskell?
<vincenz> Smerdyakov: very true...but the way that io monads are written in haskell, you can only do IO when you return a value of type IO
<vincenz> mrvn: maybe...but it will not print due to the lazyness
<vincenz> they use these sort of assumptions a lot in haskell
<mrvn> vincenz: yes, due to the monads you wouldn't see anything.
<Smerdyakov> vincenz, rather, there is no concept of "doing IO" in Haskell....
<mrvn> vincenz: assume all ocaml IO functions would just append to a string and at the end you return that string.
<Smerdyakov> vincenz, and I don't believe this is fundamentally tied to built-in layzness, since closures provide all you need to implement it in ML.
<vincenz> true but you can bypass em
<Smerdyakov> No.
<Smerdyakov> You are assuming that the OCaml standard library is unchanged, and you just want to assign some new types to library members.
<mrvn> vincenz: replace the normal I/O functions with nomadic I/O and you can't anymore.
<Smerdyakov> That's fundamentally impossible, but it doesn't mean ML (the language(s)) doesn't support monadic IO just as well as Haskell does.
<vincenz> Smerdyakov: even if it is changed, the let x = doio in don'tusex...
<vincenz> breaks out of the IO monad... The idea of hasekll is that once you're in a monad you can't get back out of it
<Smerdyakov> vincenz, again, you're confusing things.
<Smerdyakov> vincenz, think of x as a program that you write dynamically.
<Smerdyakov> vincenz, it has no effect until you execute it.
<Smerdyakov> vincenz, exactly the same semantics as in Haskell.
<vincenz> so you're basically moving to lazienss
<Smerdyakov> Sure.
<raboof> so i'm extending a program to gather some statistics.
<raboof> basically i put the statistics in a hashtable while the program is running, and provide a method for printing them
<raboof> http://rafb.net/paste/results/soIC6C29.html - does this make any sense? the `printstats' isn't correct yet i think.
<raboof> (i've worked with imperative and pure functional languages before, i haven't quite gotten my head around ocaml yet :))
<mellum> You need to terminate the lets with ;;.
<mellum> Or not at all.
<mrvn> only in the cli
<mellum> Well, if you just add ";", then the second one gets subordinated to the first one and isn't global./
nlv11757_ has left #ocaml []
<mrvn> "" or ";;". ";" is something else
<raboof> clear
<Smerdyakov> I agree with mellum.
<raboof> ah, i needed to add `()' after `printstats'
araujo has joined #ocaml
<araujo> Hello.
pango has quit ["Leaving"]
TeXitoi has quit ["Lost terminal"]
angagon has quit ["Download Gaim: http://gaim.sourceforge.net/"]
<dan2> I love ocaml
<dan2> :)
<dan2> mrvn: wheres epoll support?
raboof has left #ocaml []
<mrvn> on my todo list
Herrchen has quit ["god night"]
<dan2> mrvn: I've really grown to like libevent
<dan2> mrvn: like epoll, its passes you a pointer to your data when an event is triggered
araujo has quit ["Programs must be written for people to read, and only incidentally for machines to execute"]
<dan2> mrvn: it has interfaces to select, poll, epoll, kqueue...
<dan2> it selects the one appropriate for your system at build time
CLxyz has joined #ocaml
dan2 has quit [Remote closed the connection]
Gueben has quit ["Leaving"]
angagon has joined #ocaml
Snark has quit ["Leaving"]
_JusSx_ has quit ["leaving"]
vodka-goo has quit []
vodka-goo has joined #ocaml
vodka-goo has quit [Client Quit]
dan2 has joined #ocaml
angagon has quit [Read error: 110 (Connection timed out)]
<ulfdoz> Ich demonstrier mal.
<ulfdoz> ECHAN, sorry
<ulfdoz> cya
vezenchio has joined #ocaml