dark_light changed the topic of #ocaml to: OCaml 3.09.2 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/
smimou has quit ["bli"]
m3ga has joined #ocaml
m3ga has quit [Client Quit]
malc_ has quit ["leaving"]
fab_ has joined #ocaml
_fab has quit [Read error: 113 (No route to host)]
Skal has quit [Read error: 104 (Connection reset by peer)]
sponge45 has joined #ocaml
Demitar has quit ["Ex-Chat"]
Demitar has joined #ocaml
mikeX has quit [Read error: 110 (Connection timed out)]
danly has quit ["Leaving"]
danly has joined #ocaml
tsuyoshi has joined #ocaml
<tsuyoshi> hey.. you know what would be cool
<tsuyoshi> if you could subtype records
<tsuyoshi> like if you had { foo: string } and { foo: string; bar: int } the second one could be used like the first one
<sponge45> Yes that would be cool, but it wouldn't work given the current implementation of records. If foo is the first field of record { foo = "x" } but the second field of { bar = 1; foo = "abc" }, they can't be used as if they were of type { foo : string } because foo would be expected to be the first field, not the second one.
<sponge45> Otherwise you have objects, but they are implemented differently.
<Smerdyakov> sponge45, not so. The compiler could insert coercions.
<sponge45> ???
ithkuil has joined #ocaml
<Smerdyakov> sponge45, when you use a record of the wider record type as the narrower type, a coercion is inserted that actually _builds_ a record of the narrower type before proceeding.
<sponge45> It's not a typing problem.
<Smerdyakov> sponge45, sure it is. The type system gives the information needed to tell which coercions to insert and where.
<sponge45> OK, but that's not a coercion in the sense of :>
<Smerdyakov> I'm not even familiar enough with OCaml OO to talk about any OCaml-specific meaning of the word.
<sponge45> It's just a type conversion. No copy involved.
<tsuyoshi> sponge45: but what if the fields were in the same order
<tsuyoshi> the compiler can check that when you declare the types...
<tsuyoshi> and then if the name/type/order is compatible between two types, it can allow subtyping
<tsuyoshi> the reason I was thinking of this was because I saw you can do it with c
<sponge45> It's a question of field position, but hey, why not...
<tsuyoshi> you can have a function that takes 'a
<tsuyoshi> and then it can handle two different record types, since records look just like tuples in c
<sponge45> Just thinking aloud. How about a special field keyword that could be used to retrieve field number n of a given record?
<sponge45> or tuple
<tsuyoshi> hmm.. that you could do very easily
<sponge45> how safely?
<tsuyoshi> well.. if the compiler did it, it could be safe I think
<sponge45> :-)
<tsuyoshi> if you just did it as a function in c.. not safe at all
<sponge45> sure
pango_ has joined #ocaml
tylere has joined #ocaml
<tylere> Say I'm writing a little module, with a type t which is, for now, let's say, an int list. How can I get ocaml to type my modules fucntions as Module.t rather than int list?
<tsuyoshi> in the mli.. just put "type t"
<tsuyoshi> in the ml you can put "type t = int list"
<tylere> ahh, ok
<tylere> I'd avoided doing an mli up til now
pango has quit [Remote closed the connection]
<tylere> ack
<tylere> can't get the bloody module to work...can't get my main code to compile
<tylere> "Unbound value"
<tylere> I have to be missing something here
<tylere> I compile the mli
<tylere> compile the module ml
<tylere> and STILL my main file doesn't "see" it
<Smerdyakov> Definitions in mli files aren't available anywhere.
<tsuyoshi> doesn't see what?
<tylere> my function from my module
<tylere> so if I try to call MyMod.somefunc, which is in the mli, from my main progam, I get an "Unbound Value" error when trying to compile
<Smerdyakov> You shouldn't even be able to define functions in mli files.
<tylere> I don't mean define the function
<Smerdyakov> mli files just give type constraints that the corresponding ml files must satisfy.
<tylere> yes, yes
<Smerdyakov> They don't add ANYTHING new to the typing environment anywhere.
<tylere> I know
<Smerdyakov> Wittle your problem down to a minimally-sized example and post it somewhere.
<tylere> what I'm saying is I can't get the compiler to recognize thay my module even *exists*
<ithkuil> that's the way beautiful women always treat me
<tsuyoshi> tylere: are you including the module in the command line when you compile
<Smerdyakov> It's too hard to understand what you mean without an example.
<ithkuil> wouldnt it be nice if irc channels had a built in window for posting example code and stuff
<tsuyoshi> there's a thingy that #c uses..
<tylere> ok, give me a sec
<ithkuil> whats that?
<ithkuil> oh you mean the web page
<ithkuil> nomorepasting.com
<tsuyoshi> personally I prefer to flood the channel
<ithkuil> i want to build a chat system where there are two windows: one for text, and another for collaborative interaction with diagrams, code, etc.
<tsuyoshi> actually.. I'm supposed to be making something like that right now for a school project
<ithkuil> heh
<tsuyoshi> I haven't really started yet though
<ithkuil> figures
<tsuyoshi> we argued over languages for 4 weeks
<ithkuil> you made them do it in ocaml?
<tylere> I've taken the mli out of it for...
<ithkuil> the tough thing about introducing new chat clients is getting people to use them
<tsuyoshi> ithkuil: ah, no..
<tsuyoshi> I was trying to get them to do it in common lisp
<tsuyoshi> but we're doing it in ruby
<tylere> ruby isn't bad
<tylere> if they would ever get around to writing a decent interpreter...
<tsuyoshi> they other language they wanted was python.. which I can't stand
<tylere> like, python levels of performance even
<tylere> anyone look at my paste? This driving me nuts. doing something this simple shouldn't be thid hard
<tsuyoshi> ohh.. that's a weird way to do it
<tsuyoshi> if you have a file named board.ml, everything in the file is already in a module named Board
<tsuyoshi> I think the way you did it.. you just made a module Board.Board
<tsuyoshi> so t is Board.Board.t etc.
<tylere> oooooh
<tylere> that fixed it ;)
<tsuyoshi> cool
Snark has joined #ocaml
Smerdyakov has quit ["Leaving"]
tylere has quit [Read error: 148 (No route to host)]
_JusSx_ has joined #ocaml
ikaros_ has joined #ocaml
ikaros has quit [Read error: 110 (Connection timed out)]
buluca has quit [Read error: 131 (Connection reset by peer)]
ithkuil has quit []
buluca has joined #ocaml
beschmi has joined #ocaml
sponge45 has quit ["zzzzzzzzzz"]
pango_ has quit [Remote closed the connection]
pango has joined #ocaml
kowey has joined #ocaml
smimou has joined #ocaml
<kowey> a #haskell.fr channel has just be created, if anyone's interested :-)
<kowey> s/be/been/
<buluca> :)
jajs has joined #ocaml
fab_ has quit [Read error: 110 (Connection timed out)]
slipstream-- has joined #ocaml
slipstream has quit [Read error: 145 (Connection timed out)]
ikaros_ is now known as ikaros
beschmi has quit [Read error: 113 (No route to host)]
_JusSx_ has quit [Client Quit]
Skal has joined #ocaml
_JusSx_ has joined #ocaml
malc_ has joined #ocaml
dark_light has quit ["Ex-Chat"]
<stesch> kowey: And I saw a comp.lang.haskell this morning. New Usenet group.
<stesch> Don't know if this is real or just some Usenet fun.
<malc_> real, its creation was debated on c.l.f for a while
<kowey> saw the announcement on the mailing list recently re its creation
<stesch> But Haskell isn't my language, at the moment. Tried it once. But I did not inhale!
MisterC has joined #ocaml
* stesch is a bit in a limbo. I don't think I have a "my language" at all. All programming languages suck.
<malc_> yeah and all animals are equal
<stesch> malc_: Nope. Some taste like chicken. Others don't.
<malc_> i'll wait till you read some classic english literature
<stesch> There were computers on the Animal Farm?
<malc_> there were no signifcant chickens there thats for sure
Skal has quit [Connection timed out]
<stesch> OK, only for malc_: All programming languages suck. But some suck more.
<malc_> That's idealistic view on the world still. But whatever rocks your boat.
<ikaros> id say all programming languages are equal but some are more equal than others ;) to stay on topic
<malc_> equal based on what metric? turing compatibility? then logo is not equal to the rest of the crowd while still technically a PL..
<malc_> erm.. i have way too much time it seems
<pango> what's wrong with logo ? it's a FPL even
<malc_> what's wrong with logo? ... let's see, lack of printf
<pango> lol
<malc_> anyhow, as Oleg Kiselyov demonstrated even sendmail config files are turing complete
<ikaros> i was just directing to animal farm..
<stesch> And my complete Gentoo system is tuning complete!1!!1!!
<pango> obviously TC is a necessary, but not sufficient condition to be an "interesting" PL
<pango> lots of esoteric PL are TC too
<stesch> Nuns. No sense of humor.
<ikaros> =)
<malc_> #brainfuck or #intercall are the places to have humorous discussions, this swamp is not
<stesch> malc_: You tried to mention the book you read last week at school. Without any connection to the current topic. So don't tell me what swamp #ocaml is.
<malc_> aha flame wars.. good.
<malc_> however you are so off the mark w.r.t. my age it would be a pointless endevour
<_JusSx_> lol
mikeX has joined #ocaml
Leonidas has joined #ocaml
<malc_> can't belive it took so long to find:
kowey has quit ["Get MacIrssi - http://www.g1m0.se/macirssi/"]
swater has joined #ocaml
jajs has quit [Read error: 104 (Connection reset by peer)]
malc__ has joined #ocaml
malc_ has quit [Read error: 110 (Connection timed out)]
stesch has quit ["leaving"]
<_JusSx_> ss
<_JusSx_> ll
_JusSx_ has left #ocaml []
_JusSx_ has joined #ocaml
_JusSx_ has left #ocaml []
malc__ has quit ["leaving"]
_JusSx_ has joined #ocaml
dark_light has joined #ocaml
<_JusSx_> dfd
<dark_light> hi, can anyone tell me if this separation of db and db_request is valid at this snippet? http://nopaste.tshw.de/1162737873538b2/ , that is, i don't know if ocaml will pass a copy of hash table or just a reference for it, when passing the functions
<pango> anything but small enumerable types (ints, chars...) is passed by reference
<dark_light> fine
<dark_light> i could define db_loop inside db, but this would cost one identation level
_JusSx_ has quit ["leaving"]
<pango> instead of abstracting your player database with two closures, you could also have used a module or a class...
<dark_light> the db function is "the" abstraction.. because to modify the db i send a event (and that evread is just a function that i forgot to mention to read the event)... a module isn't too much?
<dark_light> the db_loop is just part of db, it's out of the function because i feel i will need many identation levels..
<pango> what do you mean by "too much" ? their syntax is rather light, they have no runtime overhead afaik, and they're the way to manage namespace in OCaml
tylere has joined #ocaml
<pango> your way of doing certainly works, it's just that it's less usual than either modules or classes, and that managing tuples of closures may not scale that nicely if you add more functions...
<dark_light> so i didn't understand, you mean i could define the hashtbl inside a module instead of defining inside the db function?
<pango> basically, you're using db to create an abstract datastructure with two "operations" on it
<pango> I'm not sure it's worth it btw, that whole code could be written much more simply, unless you want to reuse db_loop with different player database implementations
<dark_light> Hmmm.. i was defining the hashtable as a constant in the "base" namespace, and the operations too.. but i didn't think this was nice, i like to define things inside the functions..
<dark_light> defining inside a module seems ok, but i still like the idea of having multiple db's for each call of db
<pango> mmmh ? do you know Hashtbl module provides more than one hash table at once ? :)
<pango> that's definitely doable
<dark_light> didn't understand :P
<pango> your argument doesn't stand, with the right interface modules can provide more than one instance of the abstract datastructure they implement
<dark_light> you are saying, my module would have a "create" function, an "add" function, etc?
<pango> and declare an abstract type used for the values identifying the different instances
<dark_light> btw, this is exactly what hashtbl module does
<pango> yes
<dark_light> well hmm my intention in abstracting the add and remove operations was only defining the db_loop outside the db, nothing about the abstraction itself.. maybe i should pass the hashtabl itself for db_loop, so i have no scalability problems
<pango> yes, unless you want to abstract away the implementation of the players database, there's no need for those closures
<dark_light> and build the add_player and del_player functions inside db_loop..
ikaros has quit ["Leaving"]
<dark_light> do you know any way to reply to a event? maybe, hmm, the event may pass a channel for reply.. (it seems like C functions that passes pointers waiting the reply, and this isn't funny..)
<dark_light> i think i will build some functions to makes this a bit less painful..
<pango> I haven't worked with Event so far
ikaros has joined #ocaml
Sweetshark has joined #ocaml
* dark_light don't likes to working in a thing that is far from compiling
<dark_light> the toplevel has thread support? i can't even load the threads.cma or event.cma..
<pango> with Topfind, I just need #thread ;;
<pango> # #thread ;;
<pango> /usr/lib/ocaml/3.08.3/threads: added to search path
<pango> /usr/lib/ocaml/3.08.3/unix.cma: loaded
<pango> /usr/lib/ocaml/3.08.3/threads/threads.cma: loaded
<dark_light> topfind?
<pango> from findlib
<dark_light> how can i load it?
<dark_light> i think i have findlib installed
<pango> I use $ cat ~/.ocamlinit
<pango> #use "topfind" ;;
<dark_light> ocamlinit? hmm
<pango> so the toplevel loads topfind automatically
<dark_light> nice. i think i will make some alias to ledit ocaml, too
<pango> $ alias|grep ledit
<pango> locaml='ledit -h ~/.ocaml_history -x ocaml'
<dark_light> :)
jajs has joined #ocaml
<flux__> btw, I've found rlwrap to be nicer
<flux__> but maybe that's just personal preference
<flux__> it uses readline
<pango> (just noticed that the manual also mentions ocaml2, that seems to have died ? http://web.archive.org/web/20030622073651/http://www.taglib.co.kr/ocaml/index.html)
Sweetsha1k has quit [Read error: 110 (Connection timed out)]
<dark_light> flux__, rlwrap?
<buluca> ocaml2: ocaml with editable line history
<dark_light> i have some problems with ledit (basically it keeps all input in one line, it is nice for a terminal but not on X
<buluca> what would be like rlwrap ocaml
<buluca> dark_light: :-D
<pango> more than half of the time, I run the toplevel from within emacs anyway ;)
<buluca> pango: did you tried chamo?
<buluca> pango: ops sorry for that "english"
<dark_light> very nice that rlwrap
<pango> cameleon2 is not yet available on Sarge
<buluca> pango: neither it is on sid
<buluca> pango: (it is at 1.9.13 yet, gildor has some issue with packaging)
<buluca> pango: and even 1.9.16 doesn't compile so far
<buluca> pango: at least for me
<buluca> pango: btw, cameleon2 will not ever be available on sarge and etch's freeze is being slightly procrastinated...
<pango> I must be getting old, but I don't feel like compiling so much code just for testing
MisterC has quit [Remote closed the connection]
<buluca> pango: mmh looks cool anyway
Skal has joined #ocaml
tylere has quit [Read error: 113 (No route to host)]
<dark_light> there seems to be two ways of representing a value that may not be present: returning the value, raising a exception when not encountering it, or returing a option.. the first is quite annoying
tylere has joined #ocaml
<dark_light> it forces me sometimes to write a wrapper to option, what is very ugly.. like.. let read_player player = try Some (Hashtbl.find players player) with Not_found -> None
<pango> That's why Extlib has ExtHashtbl.find_option :)
_JusSx_ has joined #ocaml
<buluca> mmm without considering performance, an option seems to be the right thing: type `a mytipe = Nil | `a
<buluca> (maybe my syntax isn't correct ;) )
<buluca> pango: what does that function do?
<_JusSx_> buluca: post the funk
<pango> buluca: and using the predefined option type even more so ;)
<pango> type 'a option = None | Some of 'a
<pango> val find_option : ('a, 'b) Hashtbl.t -> 'a -> 'b option
<pango> probably implemented as a slightly more generic version of dark_light code above
<_JusSx_> where can i find the source code of that stuff?
<dark_light> _JusSx_, search for extlib in camlhump
<_JusSx_> i mean the whole source code of that you reported here
<_JusSx_> ok
<_JusSx_> i got it
<_JusSx_> thanx
Smerdyakov has joined #ocaml
<_JusSx_> sml lib has got functions for managing option type but ocaml hasn't
<pango> _JusSx_: yes, OCaml uses exceptions a lot more... I think it often gets in the way of writing concise (or correct) code
<dark_light> maybe exceptions is faster
<pango> I'd take correctness over slight speed benefit, if any
<_JusSx_> pango: you're right
<pango> specially since the facilities for tracing exceptions are not so great
<_JusSx_> what are the projects you are working on?
<dark_light> you who?
<_JusSx_> everybody else but you
<dark_light> :)
tylere has quit [Read error: 113 (No route to host)]
* pango is not working on anything specific atm
<_JusSx_> pango: have you ever partecipated to icfp?
<pango> nope
<dark_light> what is icfp?
<dark_light> nice
<dark_light> i wonder why functional programming is so.. "rare"
<dark_light> i find python evangelists saying a lot of structured and OOP..
<_JusSx_> because it's too high
<Smerdyakov> _JusSx_, please call it "the ICFP contest." ICFP primarily refers to the academic research conference.
<_JusSx_> Smerdyakov: you are right
<_JusSx_> and i'm lazy
<dark_light> but it is so funny too
<dark_light> s/funny/fun/ i think
<Smerdyakov> _JusSx_, well, as someone who has attended the conference twice and whose resume' depends on recognition of it for credibility, I think that's too bad. :P
<dark_light> no way so few programmer ever heard about functional programming :(
<_JusSx_> dark_light: ask to Smerdyakov
<dark_light> well, he may feel asked :) i am still not convinced
<Smerdyakov> dark_light, what?
<dark_light> <dark_light> i wonder why functional programming is so.. "rare"
<dark_light> the unique current mainstream programming language i find covering functional programming is python, and many python programmers just don't use functional programming at all
<buluca> pango: ops, I'm really an horrible beginner!
<dark_light> Event.send channel (Buffer.contents buffer) is specially a bad idea? since it involves copying the string.. i am considering using Buffer.output_buffer to a fifo and then reading in the other point.. but this involves copying strings too..
<dark_light> * The first place team's language is the programming language of choice for discriminating hackers, > ahahahahahhaha liked the ICFP contest
<_JusSx_> dark_light: which year?
<dark_light> i think the last, http://icfpcontest.org/rulesfaq.shtml
<dark_light> Damien did the most useful and complex ant program. > it's a hello world that i just can't find any hello nor world
<dark_light> specially useful :~)
Leonidas has quit ["An ideal world is left as an exercise to the reader"]
mikeX has quit ["leaving"]
jajs has quit [Remote closed the connection]
Skal has quit [Read error: 104 (Connection reset by peer)]
TaXules has quit ["update openbsd"]
bluestorm has joined #ocaml
bluestorm has quit [Remote closed the connection]
_JusSx_ has quit [Client Quit]
_JusSx_ has joined #ocaml
bluestorm has joined #ocaml
_JusSx_ has quit ["leaving"]
_JusSx_ has joined #ocaml
_JusSx_ has quit [Client Quit]
<dark_light> if i am compiling to bytecode and compile my various modules separated, i should compile them to .cma or .cmo ?
_JusSx_ has joined #ocaml
<pango> I don't think there's much difference... Maybe shorter compilation commands when you have tons of modules ?
jordan- has joined #ocaml
<jordan-> how can i take the nth element of an n-tuple?
<jordan-> i know fst and snd only work for pairs
<_JusSx_> jordan-: you need to know the size of the n-tuple
<pango> pattern matching
<pango> # let a, b, c, d = (1, "a", 'h', 24.) ;;
<_JusSx_> then (_, _, _, x) for binding 4th elements to x
<jordan-> ah, doh! forgot about that. thanks.
swater has quit ["Quat"]
<flux__> dark_light, you could simply pass the buffer itself, provided that you won't modify the buffer afterwards.. although there are no other means of retrieving stuff from it, so unless the target thread isn't going to extend the buffer, you might just go ahead and stringify the buffer when you send it :)
<flux__> or maybe you could write an alternative to Buffer, which would provide means for efficient duplication of the buffer
<dark_light> flux__, but after sending, i want to clear it and reuse it again.. i think
TaXules has joined #ocaml
<dark_light> pango, but, still, should I compile to .cma or .cmo? or, saying in other words, there are *any* differences between .cma and .cmo?
<dark_light> i think the same question would apply to C's .o and .a
<pango> I think I've read that even with .cma's, the compiler needs .cmo's...
<dark_light> so i will compile all support modules as .cma and then i will compile the main file .ml with the .cmas ..
<pango> (or was that .cmi's ?)
chessguy has joined #ocaml
bluestorm has quit [Remote closed the connection]
bluestorm has joined #ocaml
jajs has joined #ocaml
<dark_light> i am with an odd problem with Events.. i have this module for nice printing: http://nopaste.tshw.de/1162759917538b2/ and i initialize my threads with quickthread printer and quickthread fprinter .. i then use print "message" and output "message" and all works nicely, but when i call a function in a external module, it can trigger the print function, but the printer can't read from it..
<dark_light> if someone bother to take a look..:)
<dark_light> i think even the print_channel being defined as a constant, the function in the external module are seeing a different channel (?)
beschmi has joined #ocaml
Snark has quit ["Leaving"]
pango_ has joined #ocaml
pango has quit [Nick collision from services.]
pango_ is now known as pango
chessguy2 has joined #ocaml
chessguy has quit [Read error: 145 (Connection timed out)]
danly has quit [Remote closed the connection]
jajs has quit [Read error: 110 (Connection timed out)]
<jordan-> im having a very strange situation. i am calling a function recursively as follows: foo::(my_rec_f a b) and it works fine. if i try to add (List.append foo::(my_rec a b) (my_rec a t)) as the call, it complains (gives a type error) about the first argument to append, which worked ok on its own
bluestorm has quit [Remote closed the connection]
bluestorm has joined #ocaml
bluestorm has quit [Remote closed the connection]
<dark_light> jordan-, try (List.append (foo::(my_rec a b)) (my_rec a t))
<beschmi> jordan: function application binds tighter than ::, so you have to use List.append (foo::(my_rec a b)) ...
<dark_light> asking again: someone here has some experience with events? :(
<pango> or foo::(my_rec a b) @ (my_rec a t) ? (since, (a :: b) @ c == a :: (b @ c) )
<pango> evaluation order may be different, though
<beschmi> dark_light: can you some more details?
<dark_light> beschmi, well, hmm, i asked before you enter here..
<beschmi> i'll look it up in the logs
<dark_light> logs?
<dark_light> well i may re-ask
<dark_light> <dark_light> i am with an odd problem with Events.. i have this module for nice printing: http://nopaste.tshw.de/1162759917538b2/ and i initialize my threads with quickthread printer and quickthread fprinter .. i then use print "message" and output "message" and all works nicely, but when i call a function in a external module, it can trigger the print function, but the printer can't read from it..
<dark_light> i am considering abandoning this complex printing approach and just use normal functions..
<dark_light> but i am thinking, if i just can't make *this* work i think most of my others events will not work too
chessguy2 is now known as chessguy
<beschmi> dark_light: i've read the code now, but i don't understand the problem. Some function in an external module calls print, but the printer thread doesn't get an event?
<dark_light> beschmi, well, initially it gets, but when it passes the control to other function, it stops getting.. do you want the code to compile and run it yourself?
<dark_light> it has a makefile
<beschmi> yes, i can take a look
<dark_light> the code is at dlight.no-ip.biz/~dark/codigo/ocaml/hydra , the tarball at dlight.no-ip.biz/~dark/codigo/ocaml/hydra/hydra.tar.gz
<dark_light> to recompile you must remove the cma files and the hydra bytecode
<dark_light> (unhapply there are few comments and mostly in portuguese and the code is poor and.. :P)
_JusSx_ has quit [Client Quit]
johnnowak has joined #ocaml
chessguy has quit [" HydraIRC -> http://www.hydrairc.com <- Leading Edge IRC"]
smimou has quit ["bli"]