Alpounet changed the topic of #ocaml to: Discussions about the OCaml programming language | http://caml.inria.fr/ | 3.11.1 out now! Get yours from http://caml.inria.fr/ocaml/release.html
<palomer> actually, make that
<palomer> 'a foo -> 'b foo -> ... -> ('a,...,'b) t foo
<palomer> actually, it should be 'a foo -> ... -> 'b foo -> ('a,...,'b) t foo
<mrvn> and that is a string?
<palomer> type_of_t is some type encoding
<palomer> something like int list list
<mrvn> That doesn't make sense. types are a tree
<palomer> so int would have the associated encoding [[3]]
<mrvn> and int list list list ... list?
<palomer> and int list would have [[5],[3]]
<palomer> and int * int * int would have [[7],[3],[3]]
<palomer> 3 is the uid of int
<palomer> 5 is the uid of list
<palomer> and 7 is the uid 7
<palomer> err, 7 is the uid of * *
<palomer> here, I'll give you the exact encoding:
<mrvn> why only 2 3s?
<palomer> sorry, make that 3 3s
<palomer> http://pastebin.org/70395 <--here's my actual encoding
<mrvn> what is int list list?
<palomer> with my int list list encoding it would be [[5],[[5],[3]]]
<mrvn> that isn't an int list list anymore.
<palomer> good point:)
<mrvn> But your type_encoding is a recursive type so that works.
<palomer> hrmph, can't believe I forgot how to do a cheap type encoding
<palomer> right, so my challenge is generating the int in the FixedType constructor
<mrvn> What if you transform every variable v into (type_of_v, v)?
<palomer> every variable where?
<mrvn> type_of_v : unit -> type_encoding
<mrvn> palomer: in the code camlp4 parses
<palomer> I'm not doing it for EVERY variable
<mrvn> oh. thought that was your goal.
<mrvn> anyway, I'm heading for bed now. see you tomorrow.
<palomer> night!
* palomer bites the bullet
Narrenschiff_ has joined #ocaml
Narrenschiff has quit [Read error: 60 (Operation timed out)]
Narrenschiff_ is now known as Narrenschiff
tmaeda is now known as tmaedaZ
ikaros has quit ["Leave the magic to Houdini"]
efarrar has quit [Remote closed the connection]
efarrar has joined #ocaml
derenrich has quit [Read error: 110 (Connection timed out)]
evud has joined #ocaml
evud has left #ocaml []
Narrenschiff has quit []
Narrenschiff has joined #ocaml
eldragon has left #ocaml []
efarrar has quit [Read error: 113 (No route to host)]
mfp has quit [Read error: 104 (Connection reset by peer)]
mfp has joined #ocaml
ulfdoz_ has joined #ocaml
maskd has quit ["leaving"]
ulfdoz has quit [Read error: 60 (Operation timed out)]
ulfdoz_ is now known as ulfdoz
struktured has joined #ocaml
Narrenschiff has quit []
derenrich has joined #ocaml
_unK has quit [Remote closed the connection]
struktured has quit [Connection timed out]
optimizer has joined #ocaml
<optimizer> in what areas do ocaml libraies lack compared to java libraries?
<dark> i once wanted a synthesizer
<dark> for playing sounds with a "font" (piano, guitar) etc
<dark> i found in java, found none in ocaml
<dark> surprisingly many areas that java woldn't be the language of choice naturally are seeing a great use, eg. artificial intelligence
<dark> i think that in many areas if you don't find an ocaml library, and there is one in C, you probably would find a java one too
<dark> optimizer, but there is an interface to C
<dark> optimizer, so there is little problem if you are willing to write some glue code
<optimizer> how does ocaml's ffi compare to java's jni?
<dark> i don't know
<dark> optimizer, many ocaml libraries you find on net are really interfaces to C libraries
<dark> others, are interfaces to already existing apis (for object-orientedness, etc)
<dark> optimizer, there is batteries and extlib, with often-requisited libraries that isn't in the standard library for a reason or another
<dark> they are like boost
optimizer has quit ["Lost terminal"]
caligula_ has joined #ocaml
mfp has quit [Read error: 104 (Connection reset by peer)]
caligula has quit [Read error: 110 (Connection timed out)]
demitar has joined #ocaml
ski_ has quit ["Lost terminal"]
<Gertm> I must say, I wish every language had the documentation of OCaml.
<Gertm> level of*
<dark> hmmm
ksson has joined #ocaml
<Gertm> I've installed the ocaml-book in debian, is that still relevant? Still a good way to learn?
<dark> hmm
<dark> there is another
<Gertm> I think that's the one yea
<Gertm> yepn that's it
<Gertm> what's the other book?
<dark> i am searching..
<Gertm> thank you
<dark> :)
<dark> these are great books and largely relevant
<dark> there are the manual, of course. http://caml.inria.fr/pub/docs/ seems nice
<Gertm> yeah, I was meaning to start with the OReilly one and the reference manual
<Gertm> ok,that should get me started :)
tmaedaZ is now known as tmaeda
ttamttam has joined #ocaml
ikaros has joined #ocaml
_zack has joined #ocaml
cloudhead has joined #ocaml
<Camarade_Tux> I have a thread that dies with an uncaught exception, is it possible to print a backtrace for it? I can't really access it since the thread is created by lablgtk2
<flux> is it your function that's running in the thread?
<flux> you can have something like: let show_backtrace f = try f () with exn -> Printexc.print_stacktrace () (* or something *); rais exn
<flux> but that's the limit of what you can do. so if you can't insert that function anywhere, you're out of luck, AFAIK
<Camarade_Tux> seems I'm stuck then, I'd have to edit lablgtk's code in order to show the trace
<dark> hmmm
<dark> doesn't ocaml have a debugger?
<flux> it does have ocamldebug
<flux> I'm not sure if gdb works, I think there was some discussion recently about providing it better debug information
<dark> the debugger cant print a stack?
<dark> .-.
<flux> I haven't really used it. I don't know if you can stop it on thrown exceptions.
<flux> nor if it supports multiple threads
itewsh has joined #ocaml
<Camarade_Tux> (bah, I hate wifi)
<Camarade_Tux> I can't really use ocamldebug: I'm running a program that starts another program which is the one with the error
<flux> don't hate is just because yours sucks ;)
<flux> s/is/it/
<Camarade_Tux> hehe :P
<Camarade_Tux> partly because my wifi card sometimes starts sleeping and dmesg gives me "MAC is in deep sleep" messages ><
* Camarade_Tux hugs his cat5
<Camarade_Tux> but I found something more "expected" for my bug: before the problematic function seemed to be (fun _ -> true) but it is actually in f [| `CAML (Obj.repr t |] (with f that I don't know yet) which makes much more sense
<Camarade_Tux> and the exception is raised by the failwith() at the end of this C code: http://vpaste.net/zot39?
mfp has joined #ocaml
<Camarade_Tux> wifi failed again, now on cat5, at least, it works
<flux> camarade_tux, can you patch the code to do abort() so it would produce a core dump? maybe gdb would tell backtrace on that?
itewsh has quit ["There are only 10 kinds of people: those who understand binary and those who don't"]
<Camarade_Tux> after reading the source, it seems I can't do what I wanted: I wanted to forward a signal (a C struct) to another widget but I'll have to forward it base value by base value (three ints rather than a struct with three ints)
<Camarade_Tux> lablgtk2 simple does not offer support for what I wanted
Yoric has joined #ocaml
mal`` has quit ["Coyote finally caught me"]
mal`` has joined #ocaml
Pimm has joined #ocaml
Yoric has quit []
maskd has joined #ocaml
<ksson> if a thread dies because of an uncaught exception, does the whole program die?
<flux> no
dark has quit [Read error: 104 (Connection reset by peer)]
<Camarade_Tux> you get something like: "In callback for signal key_press_event, uncaught exception: Failure("GObject.Value.set : argument type mismatch")"
<Camarade_Tux> btw, if I have a value that is a pointer to a C struct allocated by C code, can I marshall it, unmarshal it somewhere else in the main program and use it safely?
<flux> wouldn't you need to write your own marshalling code?
<flux> hmm, or not :)
<Camarade_Tux> if I'm only marshalling the pointer to the struct it's ok but I think I'll have problems since the struct may be freed while I'm using it
<Camarade_Tux> s/may/could/
Yoric has joined #ocaml
yziquel has joined #ocaml
daqeaq has joined #ocaml
daqeaq has quit [Client Quit]
<yziquel> http://paste.lisp.org/display/92912 I've got a dynamic loading issue with ocamlrun. how can i deal with that?
<yziquel> it's a binding to a .so that loads dynamically other .so files (and quite a lot...)
EliasAmaral has joined #ocaml
EliasAmaral is now known as dark
BiDOrD has quit [Read error: 60 (Operation timed out)]
BiDOrD has joined #ocaml
ikaros_ has joined #ocaml
Yoric has quit []
ikaros has quit [Read error: 110 (Connection timed out)]
dark has quit [Read error: 60 (Operation timed out)]
ksson has quit [Read error: 113 (No route to host)]
itewsh has joined #ocaml
Narrenschiff has joined #ocaml
yziquel has quit [Ping timeout: 180 seconds]
Tomsik has joined #ocaml
<Tomsik> Hi, how do I use "with" on records to change just one field?
<Tomsik> I can't find it on the internet and in my notes as well...
<julm> Tomsik: {your_record with field_of_your_record=new_value}
<julm> but be aware that it makes a copy of the record
<Tomsik> thanks, I was missing the { } all the time
<Tomsik> and yeah, I'm aware, I understand how this memory management thing works, it's kinda cool
<julm> if your_record is not an identifiant you must use parenthesis around
<julm> ex. { (f toto) with tit=tata }
palomer has quit [Read error: 110 (Connection timed out)]
<mrvn> identifiant, there is a new word
<thelema> identifier
<mrvn> I think I never used { (f toto) with ... yet.
derenrich has quit [Remote closed the connection]
Tomsik has quit [Read error: 110 (Connection timed out)]
Tomsik has joined #ocaml
palomer has joined #ocaml
<palomer> http://pastebin.org/70518 <-- weird value restriction
<mrvn> palomer: The FAQ from yesterday said that it it restricts when it can't proove that there will be no exception or allocation. That probably covers every function call.
<palomer> this example isn't a function call
<palomer> I understand that function calls cannot be generalized
<mrvn> palomer: "counter ()" is a function call
<palomer> baz is generalized
<palomer> but foo isn't
<mrvn> because between foo and baz there is counter ()
<palomer> im assigning foo to something clearly polymorphic
<palomer> but foo isn't polymorphic
<palomer> that seems a little strange
<mrvn> yes
<palomer> there is no intuitive reason for this
<palomer> it's a consequence of how the ocaml type system works
<mrvn> It seems that "let x = y" will always un-generalize y and then see if it can generalize it again.
<palomer> right
<mrvn> just an obversation though.
<palomer> which is a total bummer
<palomer> seems kind of pointless
<palomer> in that example bar will be monomorphic
<mrvn> between the let baz and returning baz the type of bar changes.
<palomer> it doesn't really change, since it was monomorphic from the start
<palomer> and baz is also monomorphic from the start
<palomer> in my example baz is polymorphic
<mrvn> val baz : 'a -> '_b list = <fun>
<palomer> right
<mrvn> half polymorphic :)
<palomer> ok, I meant not fully polymorphic:P
<mrvn> My point was that between the let baz and let foo other expressions cn alter things.
<mrvn> But you are right. not a good example as bar is monomorphic and becomes int.
<palomer> my example is perfectly safe
<mrvn> yeah. we had a few of those yesterday too.
<palomer> and it would work if ocaml didn't reify before regeneralizing
<mrvn> There is probably some ugly example where it needs to
<palomer> I dare you to find one
<palomer> I'm 100% sure that "ungeneralizing" before generalizing is pointless
<mrvn> All I can think of are already monomorphic like the ref []
<palomer> this kind of stuff is perfectly safe
<flux> just write it in Coq, extract the code, and you can trust its Obj.magic invocations :)
<palomer> mrvn, if we put everything on the toplevel it would work
<mrvn> You might have to go back to 1997 when they created the value restriction and find out why they did it.
<palomer> I know why they did it!
<palomer> the problem isn't the value restriction, the problem is ocaml being lazy
<palomer> they instantiate all the variables in baz (since it is an expression) before generalizing foo, which is pointless
<mrvn> The bad thing is that writing "let foo x = ..." means that counter is called on every invokation. Makes it slower and if counter has sideeffects it ruins the semantic.
<mrvn> and putting "let bar =" at the top level pollutes the namespace.
<palomer> right, I'm looking for a specific semantics where "foo the function" contains a unique identifier
<palomer> right, polluting the namespace is bad
<flux> another alternative: write it in C
<mrvn> palomer: best I can think of is to use something like let foo__id = counter () let foo = ...
<mrvn> Pepe_: i.e. make a rule that identifiers with __ are for camlp4 only
<mrvn> or rewrite the type inference in ocaml :)
<mrvn> s/pepe_/palomer/
<palomer> bah, I'll just pollute the namespace
<palomer> there's really no way I can win here
<mrvn> flux: he is generating the code with camlp4. No inline C/asm in ocaml :(
<julm> mrvn: yep identifier :P
joewilliams has quit [Remote closed the connection]
yziquel has joined #ocaml
maskd- has joined #ocaml
maskd has quit [Read error: 110 (Connection timed out)]
jeddhaberstro has joined #ocaml
avsm has joined #ocaml
maskd- is now known as maskd
Narrenschiff has quit []
jeddhaberstro has quit [Client Quit]
_zack has quit ["Leaving."]
jeddhaberstro has joined #ocaml
ksson has joined #ocaml
Pimm has quit [Read error: 104 (Connection reset by peer)]
<thelema> palomer: # let foo = let bar = counter () in fun x -> bar;;
<thelema> value foo : '_a -> int = <fun>
Amorphous has quit [Read error: 110 (Connection timed out)]
ksson has quit [Read error: 113 (No route to host)]
Amorphous has joined #ocaml
struktured has joined #ocaml
Yoric has joined #ocaml
_unK has joined #ocaml
Yoric has quit []
avsm has quit ["Leaving."]
CcSsNET has joined #ocaml
CcSsNET has quit [Remote closed the connection]
CcSsNET has joined #ocaml
BigJ has quit ["Leaving"]
<palomer> let foo = let bar = counter () in let baz = fun x -> x in baz <--should definitely be polymorphic
cloudhea has joined #ocaml
cloudhead has quit [Read error: 60 (Operation timed out)]
Pimm has joined #ocaml
quelqun_dautre has quit [Read error: 60 (Operation timed out)]
quelqun_dautre has joined #ocaml
Yoric has joined #ocaml
<palomer> Yoric, glad to see you're enjoying your vacation with us
<Camarade_Tux> wow, scribd seems to have lots of papers :o
<Camarade_Tux> in particular, it seems to have paper on R-Trees
<mrvn> Was ist ein R-Tree?
<mrvn> hmm, some form of octree it seems.
<Camarade_Tux> Wenn Sie ein 2D Datei...
<Camarade_Tux> giving up on german ;p
<Camarade_Tux> but yeah, basically, it's for efficient storage of 2D data
<mrvn> stupid site only lets you download the pdf when you sign up and displaying it needs flash.
<Camarade_Tux> yeah, it's quite annoying for that and sometimes there are restrictions on downloads but the database is pretty good
<mrvn> maybe someday someone will write a good free flash plugin.
<Camarade_Tux> you mean, something like gnash?
<mrvn> without the bugs
<mrvn> or missing features
<Camarade_Tux> well, I'm pretty optimistic: gnash has improved and flash too
<mrvn> there is hope
<Camarade_Tux> it leaks like hell but it's not as bad as it used to be (I have it disabled unless when I really need it)
<Camarade_Tux> oh, btw, scribd's flash is pretty inefficient: it can eat hundreds of MB of memory for long PDF files :-)
<Camarade_Tux> (and if anyone knows of a pdf reader in flash, I'm taking it: my "music" player runs flash)
Yoric_ has joined #ocaml
tmaeda is now known as tmaedaZ
aklt has joined #ocaml
<Leonidas> Hmm, I just installed camlzip, how can I open it in the toplevel?
<Leonidas> ocamlmktop -I $(ocamlfind query zip)
<Leonidas> did not produce a toplevel that knows Zlib
<flux> unfortunately you cannot (easily) add directories into search path with ocamlmktop
yakischloba has joined #ocaml
<flux> so basically you have an init file that you load to your new shiny toplevel
<flux> alternative solutions: maybe it's possible to write a module that makes use of the Toploop module to add the directory
<Camarade_Tux> Leonidas: and why not use 'ocamlfind ocamlmktop'?
<Leonidas> flux: ocaml -I $(ocamlfind query zip) worked
<flux> leonidas, it does, yes..
<flux> but, if there's a way to make a toplevel that incorporates -I -switches, I don't know it
<flux> I'd very much like to, though :)
<flux> (hey, maybe someone can research that Toploop-approach and report back? ..)
<Leonidas> Camarade_Tux: because that ocamltop does not know Zlib
<flux> leonidas, the -I only covers the need of ocamlmktop needing to find the files
Yoric__ has joined #ocaml
* Leonidas tries to write a deflate decompressor in ocaml but is surprised by what zlib spits out.
<flux> leonidas, ..hmh? but you are just using ocamlfind to find zip?
<Leonidas> flux: yep, and that has a binding to Zlib.
<Leonidas> i tried the zlib binding in python and the results are... interesting.
<Leonidas> ''.join(bin(ord(c))[2:].zfill(8) for c in zlib.compress('Blah blah blah blah blah!'))
<Leonidas> results in a seemingly invalid output
<flux> how do you determine that?
<flux> how about: zlib.uncompress (or whatever)(zlib.compress("blab") ?
<orbitz> Hrm, I just learned of Nitrogeon in Erlang, reminds me of OPA
<Leonidas> flux: my code results in a '01111000100111000111001111001010010010011100110001010000010010001100001000100100000101000000000101101111000110010000100001110101'
Yoric has quit [Read error: 110 (Connection timed out)]
Yoric__ is now known as Yoric
<Leonidas> flux: first 3 bits = 011, so 0 = not last block, and 11 = reserved
<Leonidas> and this puzzles me.
<orbitz> hey yoric
lagenar has joined #ocaml
<palomer> Leonidas, you can remove the -I with ocamlfind query -i-format
<Leonidas> oh, indeed. nice.
_unK has quit [Remote closed the connection]
Pepe___ has joined #ocaml
Yoric_ has quit [Read error: 113 (No route to host)]
Pepe_ has quit [Read error: 113 (No route to host)]
Pepe___ is now known as Pepe_
thieusoai has quit ["leaving"]
cloudhea has quit [Client Quit]
cloudhead has joined #ocaml
wormphlegm has joined #ocaml
wormphlegm has quit [Client Quit]
ccasin has joined #ocaml
Tomsik has quit [Read error: 60 (Operation timed out)]
lagenar has left #ocaml []
cloudhead has quit [Connection timed out]
itewsh has quit ["There are only 10 kinds of people: those who understand binary and those who don't"]
Yoric has quit []
<yziquel> I run a binding in bytecode (there's no problem in native code). This loads a .so library, which in turns loads other .so libraries. It seems to me that I've got symbols in the BSS (uninitialised data section) that gets loaded, but in a memory zone that is not cleared to 0.
<yziquel> and the .so library's code relies on BSS --> uninitialised to 0.
<yziquel> does ocaml set BSS to 0 when dynamically loading .so from bytecode?
Amorphous has quit [farmer.freenode.net irc.freenode.net]
flux has quit [farmer.freenode.net irc.freenode.net]
sgnb` has quit [farmer.freenode.net irc.freenode.net]
noj has quit [farmer.freenode.net irc.freenode.net]
ttamttam has quit ["Leaving."]
Amorphous has joined #ocaml
flux has joined #ocaml
sgnb` has joined #ocaml
noj has joined #ocaml
<mrvn> yziquel: BSS segments get allocated and the dynamic linker should zero them
<yziquel> mrvn: followed machine code instruction step by step, and i get box[i] != NULL statement which evaluates to true, with box uninitialised.
<yziquel> mrvn: so there's obviously an issue somewhere.
<mrvn> and box[] is a global array?
<yziquel> mrvn: a global uninitialised array.
<mrvn> as in void* box[10];?
<yziquel> #define MAXSPACES 64
<yziquel> Box box[MAXSPACES];
<yziquel> and Box is a typedefed pointer, indeed,
<yziquel> .