gildor changed the topic of #ocaml to: Discussions about the OCaml programming language | http://caml.inria.fr/ | OCaml 3.12.0 http://bit.ly/aNZBUp
<opla2> oh okey
<opla2> so f x y z does not have type () -> U option then?
<opla2> ...no i found now
<opla2> gah.. to bad.. should be an option not to apply those
<jm_ocaml> right, I've got an issue, too: how do I tell Menhir to load a library (e.g. batteries) before it goes away and type-checks my .mly file?
<opla2> im to n00bish for that
<jm_ocaml> That's not exactly a deeply intellectual question. In fact, I have just found the answer in the reference manual. How embarrasing!
myu2 has joined #ocaml
<jm_ocaml> Actually, I am lying. Or maybe the reference manual is. :(
jm_ocaml has quit [Remote host closed the connection]
munga has quit [Ping timeout: 240 seconds]
<opla2> is there a statement separator other than new line?
opla2 has quit [Ping timeout: 272 seconds]
opla2 has joined #ocaml
myu2 has quit [Remote host closed the connection]
myu2 has joined #ocaml
ikaros has quit [Quit: Leave the magic to Houdini]
myu2 has quit [Read error: Connection reset by peer]
undef`behavior has joined #ocaml
avsm1 has joined #ocaml
avsm has quit [Read error: Connection reset by peer]
lars9 has joined #ocaml
<lars9> is there nicer ocaml command line tool which support readline, autocompletion etc?
<adrien> you have at least two big wrappers: ledit and rlwrap, you can start them as "ledit ocaml" / "rlwrap ocaml"
<lars9> adrien: let me try:)
<adrien> there's also a modified toplevel from lwt and I've heard very good things but have never tried it myself
<lars9> adrien: do you know the name?
<adrien> the one from lwt? I'm not aware of a special name
opla2 is now known as Squarism
<lars9> rlwrap is good
mfp has quit [Ping timeout: 260 seconds]
lars9 has left #ocaml []
mfp has joined #ocaml
Squarism has quit [Ping timeout: 265 seconds]
Amorphous has quit [Ping timeout: 272 seconds]
undef`behavior has quit [Quit: sleeepp]
Amorphous has joined #ocaml
kaustuv has quit [Remote host closed the connection]
companion_cube has quit [Ping timeout: 240 seconds]
companion_cube has joined #ocaml
myu2 has joined #ocaml
willb has joined #ocaml
smerz has quit [Quit: Ex-Chat]
bzzbzz has joined #ocaml
ulfdoz has joined #ocaml
drunK has quit [Remote host closed the connection]
ygrek has joined #ocaml
ulfdoz has quit [Read error: Operation timed out]
hto has quit [Quit: Lost terminal]
hto has joined #ocaml
ygrek has quit [Remote host closed the connection]
ygrek has joined #ocaml
hto has quit [Quit: Lost terminal]
hto has joined #ocaml
hto has quit [Client Quit]
avsm1 has quit [Ping timeout: 245 seconds]
avsm has joined #ocaml
ttamttam has joined #ocaml
xl0 has quit [Read error: Operation timed out]
ygrek has quit [Remote host closed the connection]
xl0 has joined #ocaml
ygrek has joined #ocaml
ygrek has quit [Ping timeout: 245 seconds]
almaisan-away is now known as al-maisan
ftrvxmtrx has quit [Quit: Leaving]
_andre has joined #ocaml
ygrek has joined #ocaml
ftrvxmtrx has joined #ocaml
seafood_ has joined #ocaml
munga has joined #ocaml
nejimban has quit [Ping timeout: 250 seconds]
nejimban has joined #ocaml
myu2 has quit [Ping timeout: 245 seconds]
<f[x]> gildor, any way to check for is_native in _oasis?
<f[x]> I thought there was an uniform way to access variables from setup.data but apparently I fail to do so
<gildor> no during configuration step there is a limited number of available variables
<gildor> f[x]: ^^^
<gildor> (for is_native)
<al-maisan> I am using Args.parse and something like "program -r -n" works whereas "program -rn" results in "./program: unknown option `-rn'." although both command lines are equivalent. Is this correct Args.parse behaviour?
<gildor> I think I can generalize to variables accessible through ocamlc -config, but not further
<f[x]> gildor, ok, thanks
<f[x]> someone should definitely fix all those bugs :))
<gildor> working on oasis-db and forge.o.o right now
<f[x]> al-maisan, yes
<al-maisan> hmm .. this is not quite how many programs work .. most of them support the grouping of flags i.e. both "-r -n" and "-rn" is acceptable.
<al-maisan> example: rsync -a -v -z and rsync -avz etc.
init1 has joined #ocaml
<f[x]> there are alternative arg parsing modules
ttamttam has quit [Remote host closed the connection]
<al-maisan> ah, what are these?
<f[x]> iirc extlib has one
ikaros has joined #ocaml
<al-maisan> thanks, will take a look later.
_andre has quit [Quit: Lost terminal]
_andre has joined #ocaml
pdhborges has joined #ocaml
<pdhborges> Hi I have a question about tags and blocks
<pdhborges> the Is_long(x) macro checks if the lower bit of an mvalue is 1 or not
<pdhborges> but the tag of the header of a block might also have a lower bit == 1
<pdhborges> how does it distinguish a block from and int in that case?
munga has quit [Ping timeout: 264 seconds]
<f[x]> the pointer is not the header
<f[x]> it points to header
<pdhborges> f[x]: so ocaml blocks are never allocated at adresses ending in 0?
<pdhborges> s/0/1
<pdhborges> s/adresses/#define Is_long(x)
ygrek has quit [Ping timeout: 245 seconds]
<pdhborges> ups
<f[x]> yes, all allocations are aligned at 2 or 4 bytes (do not remember exactly)
<pdhborges> thanks!
munga has joined #ocaml
mnabil_ has joined #ocaml
<thelema> al-maisan: ocaml doesn't use gnu-style single-dash short arguments and double-dash long arguments, all arguments have one dash (thus, no grouping of short ones)
<thelema> f[x]: 4B (or 8B on 64-bit)
<al-maisan> thelema: thanks for the explanation!
* al-maisan is used to gnu-style command line args ..
<thelema> al-maisan: it's frustrating for me too, if you're still looking for a gnu-style command-line library, I've written one... somewhere...
<flux> what is the best command line argument processor library for ocaml, if the criteria are: 1) DRY 2) little code for new options 3) gnu-style?
<adrien> there's a getopt module from Alain Frisch too
<flux> I guess to optimize two first one might think of a syntax extension..
<adrien> gnu-style meaning -cJf is equivalent to -c -J -f ?
<al-maisan> adrien: yeah .. I saw that .. there's even a package on ubuntu for it (libgetopt-ocaml-dev); will play with that and see how it goes..
<al-maisan> adrien: gnu-style also means long "versions" of options e.g. --help
<flux> well, both --long-args and traditional and arg0 -cJf arg1 arg2 <=> arg0 -c arg1 -J -f arg2 <=> -c arg1 -J -f arg2 arg0 (-c and -f in this example take arguments)
<al-maisan> thelema: thanks for the pointer!
<thelema> flux: of course it's the one I (co-)wrote, arg2.ml
<adrien> -- is trivial to get compared to the compression of arguments
<flux> my parser doesn't really handle the 'floating' argument (the one that doesn't have a switch for it)
<thelema> flux: floating arguments seem best handled by just accepting a function to consume them
ttamttam has joined #ocaml
<adrien> I made mine so that all arguments accept a list of "sub"-arguments: you parse, find an arguments, start looking for possible sub-arguments and if you find an argument that is not in the list of possible sub-arguments, you say it belongs to the parent level, pretty much recursion
<thelema> adrien: eep
<flux> thelema, in practice, I would most often like to get them as a list
<flux> thelema, of course, one can collect them, but I'd rather the library do it for me ;-)
<flux> I can then afterwards nicely pattern match the list
init1 has quit [Quit: Quitte]
ztfw has joined #ocaml
<thelema> I guess the library could return a list when it's done parsing, and the collection function could be (string -> string option) so it could reject a value and instead put it on the list
<adrien> I find that it's easier to have the library only return a list and let you check everything is like you want it to be
<thelema> one thing I wanted to add to my library was a way to call a function on multiple arguments to handle one option with multiple parameters
<thelema> (with default values)
<thelema> right now I store the parsed parameters in ref cells, and call the function on those ref cells, but this is ugly
<thelema> there's probably a nice way to do it in my parser, I thuink
<flux> one problem with those parsers is that I'd like to get a record with my settings back
<flux> but that basically forces the argument handler to be a folding function
<flux> and the individual value changing functions are somewhat repetitive
<thelema> yes, at least refs can be passed individually, you'd have to pass modifier functions for each record field
<flux> after command line argument parsers I typically have this code: proceed { a = !a; b = !b; c = !c } etc
<flux> and the 3.12 extension { a; b; c } doesn't help at all with this :)
<adrien> was wishing for ~foo:!foo yesterday =)
WonTu has joined #ocaml
<adrien> rather, ~!foo
WonTu has left #ocaml []
<flux> hmm... { !a; !b; !c } ..
<thelema> mmm, much nicer: [in_files := Arg2.parse args usage_info descr notes; !main ()]
<thelema> here's some more complex usage of my library: https://github.com/thelema/tornadocaml/blob/master/testgraph.ml#L65
* al-maisan looks
<thelema> one subtlety is that there's two lists of argument handlers, for mandatory and optional arguments. The optional arguments need to be paired with unit functions to be called if there's no rg present
avsm has quit [Quit: Leaving.]
jm_ocaml has joined #ocaml
ftrvxmtrx_ has joined #ocaml
ftrvxmtrx has quit [Ping timeout: 276 seconds]
pdhborges has quit [Quit: pdhborges]
pikachuyann has joined #ocaml
pdhborges has joined #ocaml
pdhborges has quit [Quit: pdhborges]
mnabil_ has quit [Ping timeout: 272 seconds]
pdhborges has joined #ocaml
oriba has joined #ocaml
seafood_ has quit [Quit: seafood_]
Snark_ has joined #ocaml
Snark_ is now known as Snark
hto has joined #ocaml
<hcarty> thelema: Has a direction for exception handling in future releases of Batteries been decided on? Exceptionless by default, exceptions by default with Exceptionless modules (like now), or provide both functions (foo and foo_opt or foo_exn depending on default) in the same module?
<thelema> can't be exceptionless by default - backwards compatibility
<hcarty> thelema: I didn't expect any changes on this front until 2.0
<thelema> Exceptionless modules seems best to me, although we'll end up with top-level module explosion if we do (threads, no threads, threads exceptionless, nothreads exceptionless, + labeled variants (4))
<thelema> backwards compatibility with stdlib
<hcarty> Ah
myu2 has joined #ocaml
pikachuyann has quit [Remote host closed the connection]
pikachuyann has joined #ocaml
ttamttam has quit [Remote host closed the connection]
NaCl has joined #ocaml
* NaCl pokes adrien
<adrien> =)
* NaCl may hang out here more
alpounet has joined #ocaml
<pdhborges> Does anyone know of a C extension written in good style?
<pdhborges> I'm following cryptokit but some parts are written in totally diferent styles
<adrien> Unix from ocaml itself?
<adrien> may I ask what you are binding btw?
<pdhborges> zeromq
<thelema> pdhborges: what do you need help with, writing C that interfaces with ocaml, linking, something else?
<pdhborges> thelema: just the bindings style
<pdhborges> some bindings use return
<pdhborges> other use OCAMLreturn
<pdhborges> other do not use OCAMLparams
<thelema> then don't look at pycaml. unix is probably your best bet
<pdhborges> a ok
<pdhborges> :D
<pdhborges> s/other/others
<thelema> return vs. OCAMLreturn depends on whether that function allocates
<adrien> I'd stay safe and always use the CAML* macros
drunK has joined #ocaml
<pdhborges> k
<adrien> basically, you need the macros in the general case but sometimes you can skip them, that "sometime" is hard to get exactly, it's easy to make a mistake, especially if your code is often changing
<pdhborges> yeah
<pdhborges> the unix lib
<pdhborges> only returns longs and units
<pdhborges> so it's not that good for inspiration
<pdhborges> :\ I'm going to use the macros everywhere
<thelema> okay, more complex data structure examples? ml_cairo bindings: http://cgit.freedesktop.org/cairo-ocaml/tree/src/ml_cairo.c?id=4d202785ffebdc19d4564b2bc79e805f135dfc32
zzz_` has quit [Quit: zhengli]
zzz_ has joined #ocaml
hto has quit [Quit: Lost terminal]
<hcarty> pdhborges: The MPI bindings are older-fashioned (not a lot of use of the macros), but they may provide some inspiration - https://forge.ocamlcore.org/scm/browser.php?group_id=135
hto has joined #ocaml
ftrvxmtrx_ has quit [Quit: Leaving]
munga has quit [Ping timeout: 276 seconds]
hto has quit [Quit: Lost terminal]
drunK has quit [Read error: Connection reset by peer]
ygrek has joined #ocaml
opla2 has joined #ocaml
munga has joined #ocaml
ulfdoz has joined #ocaml
al-maisan is now known as almaisan-away
pdhborges has quit [Quit: pdhborges]
ulfdoz has quit [Ping timeout: 265 seconds]
ulfdoz has joined #ocaml
pdhborges has joined #ocaml
ftrvxmtrx has joined #ocaml
boscop_ has joined #ocaml
boscop has quit [Ping timeout: 245 seconds]
_andre has quit [Quit: leaving]
boscop_ is now known as boscop
hyperboreean has quit [Ping timeout: 265 seconds]
ikaros has quit [Quit: Leave the magic to Houdini]
hyperboreean has joined #ocaml
smerz has joined #ocaml
jeddhaberstro has joined #ocaml
<pdhborges> Hi again
<pdhborges> ok I finished the bindings prototype
<pdhborges> and compiled a cma sucessfully
<pdhborges> but when I try to load it in the repl I get
<pdhborges> dlopen(./dllzeromq.so, 138): Symbol not found: _zmq_bind
<hcarty> pdhborges: Getting linking right for C bindings can be tricky. If you haven't read it yet, this is an excellent reference: http://www.linux-nantes.org/~fmonnier/OCaml/ocaml-wrapping-c.php
<hcarty> pdhborges: I'd offer more direct assistance, but I'm unable to at the moment :-)
<pdhborges> okay
<pdhborges> thanks for the link I going to read it
<thelema> pdhborges: also look into making a custom toplevel - this may be needed to do what you want
<adrien> OCamlMakefile also automates quite a lot of work here =)
<adrien> (will have to look again at oasis too, maybe next week)
<hcarty> adrien: Seconded! I was typing that out when you sent it :-)
<hcarty> pdhborges: http://www.ocaml.info/home/ocaml_sources.html - ocaml-make on that page
<hcarty> It has special targets for custom toplevels and lots of other goodies.
<pdhborges> :|
<pdhborges> I tried the first link but no go
khia0 has joined #ocaml
khia0 has left #ocaml []
<pdhborges> Now I linked the cma statically
<pdhborges> and I get caml_zmq_init
<pdhborges> not available
<hcarty> pdhborges: I recommend adrien's suggestion - OCamlMakefile
<hcarty> Particularly during early development
<hcarty> It includes a nice example of C bindings
<pdhborges> I wnated to understand every step
<hcarty> Example of compiling C bindings with OCamlMakefile, that is
<pdhborges> :|
<pdhborges> the example in the first page works
<pdhborges> I'm making mistake somewhere
<hcarty> pdhborges: I think it has a "verbose" option, which may help. But I understand wanting to know why things are or are not working.
<alpounet> hey hcarty :)
<adrien> pdhborges: you could use OCamlMakefile and see exactly what it does: since it's a makefile, it'll output each command called
<hcarty> alpounet: Hello
<pdhborges> adrien: I have the log of one oasis instalation
<alpounet> what's up
<pdhborges> (cryptkit)
<pdhborges> grrr
<pdhborges> I must be a retarded because I following every setep from the example (which works)
<pdhborges> and with my bindings it doesn't woek
<oriba> short question on ocamlnet... I used Http_client.Convenience for some web-get-retrievals... now I need to send a Referrer and maybe later handle Cookies
<oriba> how to do that?
<oriba> seems that the Convenient module does not offer such possibilities
<adrien> I've always been under the impression that C bindings are heavily impacted by the current weather ;-)
<oriba> but does ocamlnet offer it?
<oriba> which module?
<adrien> oriba: Http_client itself?
<hcarty> oriba: ocurl maybe? I don't know about ocamlnet.
<pdhborges> this are my bindings http://paste.pocoo.org/show/35RtXrqwwPyHyoRMychT/
<hcarty> Or what adrien said :-)
Snark has quit [Quit: Ex-Chat]
<pdhborges> I know no error checking but that will eventually be implemented
<oriba> adrien, how to do it?
<pdhborges> this is the ocmal module http://paste.pocoo.org/show/hfocaB3FY8ntgMYbS9oL/
<hcarty> pdhborges: It really is tricky to get right. OCamlMakefile is quite straightforward to try, and it may help locate the error.
<pdhborges> okay
<pdhborges> I'm going to eat and then
<pdhborges> I'll try the omake
<hcarty> pdhborges: Just for clarification - omake and OCamlMakefile/ocaml-make are two different things.
<pdhborges> yes I know
<pdhborges> :D
<pdhborges> just trying to abreviate
<adrien> oriba: don't know, from what I've seen it's with the Nethttp.Header module but that's all I can say right now
<oriba> ok adrien thx
<oriba> adrien, can that Nethttp.Header can be used together with Convenient module also?
<adrien> that, I don't know
<oriba> aha ok
<oriba> I try it
ulfdoz has quit [Ping timeout: 260 seconds]
ftrvxmtrx has quit [Quit: Leaving]
ftrvxmtrx has joined #ocaml
opla2 has quit [Ping timeout: 265 seconds]
<kerneis> new server for caml-list, "professionnal" team managing it and... more spam! WTF?
rixed_ has quit [Ping timeout: 240 seconds]
<pdhborges> ok I figured out where the problem is
<pdhborges> the libzmq is not linked with the binding
<adrien> so you have to explicitely link against it when building your app?
ftrvxmtrx has quit [Quit: Leaving]
<pdhborges> yes
<pdhborges> but how to make it work with the repl?
<adrien> custom repl?
<pdhborges> does the reple have a -cclib option?
<thelema> no, -cclib inicates a library to pass to the c compiler
<thelema> (/ linker, I think)
<pdhborges> the problem I have is this
<pdhborges> the cma has a reference to the stubs dynlib
<pdhborges> but the dynlib have funtions that need to be linked with lzmq
<pdhborges> s/have/has
<gildor> pdhborges: what the problem with oasis ?
<pdhborges> I guess none haven't tryed it yet
<gildor> what ?
<gildor> pdhborges: try what ?
<pdhborges> oasis
<gildor> you mean none have tried oasis ?
<pdhborges> No
<gildor> I hope not
<pdhborges> I meant no problems since I havent tried it
<thelema> "I guess none" "haven't tryed it yet"
<gildor> pdhborges: you said "adrien: I have the log of one oasis instalation"
<gildor> do you want me to have a look at it?
<pdhborges> erm I have the log from another lib
<pdhborges> I'm trying to figure out out to compile my lib from that log
ftrvxmtrx has joined #ocaml
<gildor> what was the lib in question ?
<pdhborges> bindings for zeromq
<gildor> URL ?
<pdhborges> no url yet I just finished the alpha version
<ygrek> pdhborges, use ocamlmklib
<ygrek> see the example in manual - it is straightforward
<ygrek> if you want to understand how it works
<pdhborges> no
<pdhborges> :
<pdhborges> :D
<gildor> and you want to compile that file (+ the C files coming with it)
<pdhborges> yes
<pdhborges> into a cma lib
<gildor> without oasis, if I understand
<pdhborges> yes
<gildor> ocamlc -c foo.ml
<gildor> ocamlc -c foo_stub.c ( + -I to access .h files)
<pdhborges> OMG I did it!!!!
<gildor> ocamlmklib -cclib -lzmq -a foo.cmo foo_stub.o
<gildor> ocamlmklib -cclib -lzmq -o foo foo.cmo foo_stub.o, I mean
<gildor> (AFAIR)
ygrek has quit [Ping timeout: 245 seconds]
<gildor> create a META file, install the generated object
<gildor> and use #load "topfind";;
<gildor> + #require "foo";;
opla2 has joined #ocaml
<pikachuyann> Bonne nuit / Good night
pikachuyann has quit [Quit: Quitte]
<pdhborges> I need to put this paste somewhere safe :p
<thelema> pdhborges: it's in the #ocaml logs
<pdhborges> ^^
oriba_ has joined #ocaml
<thelema> of course, now you have to put that link somewhere safe... :)
<pdhborges> dropbox
<pdhborges> ;)
oriba has quit [Ping timeout: 276 seconds]
<gildor> pdhborges: if you'd use oasis, You will just have Library zeromq
<gildor> CSources: zeromq_stubs.c
<gildor> Modules: Zeromq
<gildor> and that is all
<adrien> ^ ^
<gildor> ah maybe also CCLib -lzmq
<gildor> and DllLib: -lzeromq
<gildor> (but in v0.3.0, it will just be: BuildDepends: zeromq (pkg_config)
munga has quit [Ping timeout: 240 seconds]
munga has joined #ocaml
<pdhborges> gildor: tomorrow
<pdhborges> if I have time I will learn some oasis awsomeness
<pdhborges> ^^
<pdhborges> well the bindings are working
<pdhborges> except for the error checking
<pdhborges> the socket options
<pdhborges> and the message lenght
<adrien> now, call 'Gc.compact ()' at various places in your code :p
<pdhborges> :X
<pdhborges> mos of the memory is allocated inside lzmq
<pdhborges> I don't htink compacting will do much diference
<pdhborges> :p
<adrien> C bindings with bugs often crash during the gc calls
<adrien> so it's a kind of test
<pdhborges> o
<pdhborges> tomorrow I'll fix the message size/copying and then
<pdhborges> I'll use your debuging trick
<pdhborges> thanks for the help everyone!
ztfw has quit [Remote host closed the connection]
jm_ocaml has quit [Remote host closed the connection]
munga has quit [Ping timeout: 240 seconds]
pdhborges has quit [Quit: pdhborges]
lamawithonel_ has quit [Remote host closed the connection]
oriba_ has quit [Remote host closed the connection]