flux changed the topic of #ocaml to: Discussions about the OCaml programming language | http://caml.inria.fr/ | 3.11.0 out now! Get yours from http://caml.inria.fr/ocaml/release.html
chickenzilla has quit ["J'y trouve un goût d'pomme."]
oriba has joined #ocaml
dira has joined #ocaml
<dira> I`m new to F.
<dira> *I`m new to F.P. , and I`v always wondered how is it possible to model state in functional way , like how do you program push down automata to check number of parentheses ? or how do you model logic circuit in functional way where it pertains Flip-Flops as object with state?
<mrvn> you push the state as argument to the functions
<mrvn> and return the new state
hkBst has quit [Read error: 104 (Connection reset by peer)]
<mrvn> let check str = let rec check num_open = function [] -> num_open | '('::xs -> check (num_open + 1) xs | ')'::xs when num_open = 0 -> raise (Invalid_argument("too many closing )")) | ')'::xs -> check (num_open - 1) xs in let left_open = check 0 (string_to_char_list str) in if left_open > 0 then raise (Invalid_argument("Too many ("))
<dira> mrvn: That`s nice , thanks
<mrvn> totaly from the top of my head. You have to fix errors yourself.
<dira> sure , just wanted the general image , thanks
<dira> which IDE do you suggest for ocaml ? I`v seen plugins for eclipse , which one do you suggest?
<mrvn> I'm using xemacs with tuareg mode
slash_ has quit ["leaving"]
angerman has joined #ocaml
ofaurax has quit ["Leaving"]
oriba has quit ["Verlassend"]
<Yoric[DT]> 'night
Yoric[DT] has quit ["Ex-Chat"]
kaustuv has quit [Read error: 113 (No route to host)]
angerman has quit []
bhampkl has quit [Remote closed the connection]
ched_ has quit [Read error: 110 (Connection timed out)]
ched_ has joined #ocaml
angerman has joined #ocaml
ched__ has joined #ocaml
ched_ has quit [Read error: 101 (Network is unreachable)]
caligula__ has quit ["Konversation terminated!"]
bzzbzz has quit ["leaving"]
angerman has quit []
angerman has joined #ocaml
angerman has quit [Client Quit]
seafood has quit []
jeddhaberstro has quit []
Demitar has joined #ocaml
AxleLonghorn has joined #ocaml
wsmith85 has quit [Read error: 110 (Connection timed out)]
Camarade_Tux has joined #ocaml
angerman has joined #ocaml
sysop_fb has joined #ocaml
Moca has joined #ocaml
schme has quit ["leaving"]
schme has joined #ocaml
_zack has joined #ocaml
kaustuv has joined #ocaml
ttamttam has joined #ocaml
kaustuv has left #ocaml []
angerman has left #ocaml []
hkBst has joined #ocaml
ttamttam has left #ocaml []
sysop_fb has quit []
chickenzilla has joined #ocaml
Snark has joined #ocaml
dira has quit ["ChatZilla 0.9.84 [Firefox 3.0.7/2009021910]"]
dartelin has joined #ocaml
<dartelin> hello
<dartelin> i have a problem
<dartelin> how can i check if 2 lists are of the same length without using List.length ? i have to use pattern matching
<Camarade_Tux> dartelin, pattern match the two lists at the same time as in 'match l1, l2 with', I'll let you find the match clauses though
<dartelin> yes, but what should the pattern look like ?
<mrvn> I prefer (l1, l2) to make the tuple more visible.
slash_ has joined #ocaml
<mrvn> dartelin: I give you the thrid pattern : _ -> false
chickenzilla has quit ["J'y trouve un goût d'pomme."]
zerny has joined #ocaml
schmx has joined #ocaml
schme has quit [Read error: 110 (Connection timed out)]
animist has joined #ocaml
seafood has joined #ocaml
verte has quit ["http://coyotos.org/"]
seafood has quit [Client Quit]
oriba has joined #ocaml
oriba has quit [Read error: 104 (Connection reset by peer)]
|jedai| has joined #ocaml
|jedai| is now known as jedai
dartelin has quit [Read error: 148 (No route to host)]
Yoric[DT] has joined #ocaml
<Yoric[DT]> hi
tclineks has left #ocaml []
<flux> hey, I figured a succinct way other than using List.length: List.map ignore a = List.map ignore b :)
<tsuyoshi> why would you want to avoid List.length anyway
<flux> looked like homw work to me
<flux> mrvn, so your fuse bindings work now, it's the filesystem you're working on now?
<mrvn> flux: They work more and more. I'm adding bindngs as I implement the code in my FS.
<flux> mrvn, what kind of fs are you writing?
<mrvn> Similar to btrfs. Spanning multiple disks with configurable redundancy and checksumming and COW operations.
<mrvn> Everything is stored in one big B-Tree and every change creates a new root. Verry functional.
<flux> I've been thinking something similar, except it would be backed by regular filesystem
<flux> (possibly on multiple nodes and multiple networks)
<flux> perhaps not that similar after all :)
<mrvn> Why on filesystems?
<flux> because it is easier?-)
<flux> and you can put it on a regular fs without explicit partitioning/voluming
<mrvn> flux: look at glusterfs.
<mrvn> Only thing glusterfs doesn't have is a raid5/6 plugin.
schmx has quit ["Lost terminal"]
schme has joined #ocaml
_zack has left #ocaml []
Associat0r has joined #ocaml
<tsuyoshi> every change creates a new root? isn't that kind of slow?
<mrvn> tsuyoshi: not every change is synced to disk.
<mrvn> So on disk a change can contain quite a few write requests or mkdir or rm.
<mrvn> If something writes 1G of data and then the system crahses I don't mind loosing that 1G. Only if the file is fsync()ed or close()ed and the filesystem has reported the data as correctly written must the file be crash resistant.
<mrvn> And if there wasn't a fsync() or close() in a while the FS will sync the root as well so not too much data is kept on the fly.
<mrvn> (or for too long)
<mrvn> The nicest thing about having a new root all the time is that creating a snapshot just means keeping the root around.
Associat0r has quit []
<tsuyoshi> so you can have multiple changes but only save one root, on the last change?
<tsuyoshi> I imagine that would be a little tricky to do right
<mrvn> tsuyoshi: why? Every in-memory root represents a consistent snapshot of the filesystem at that time. Any one of them can be saved to disk to give a valid filesystem on disk.
<mrvn> The thing that makes this easy is the copy-on-write semantic. Anything that changes something reads the relevant block into memory, allocates an empty block on the disk, changes the in memory data, flags the block as dirty and tells the parent about the new location (which makes the parent dirty too as something there changes).
<tsuyoshi> yeah.. that sounds slow to me
<mrvn> Two things are tricky: 1) finding blocks that are no longer referenced and 2) make this fast.
<tsuyoshi> don't you basically need to garbage collect that
<mrvn> yep
<mrvn> or ref-count.
<tsuyoshi> oh, this is a nice quote
<tsuyoshi> "Haskell is the Ron Paul of programming languages."
<mrvn> If I don't allow hardlinks between directories than I have a non-cylic directed graph. Afaik ref-counting is enough for that.
<bjorkintosh> it's a stupid one.
<mrvn> tsuyoshi: I have a sample implementation in C for the FS without any preallocation and delayed write tricks and it manages ~5MB/s. I need at least twice that to saturate my 100MBit network when fetching files.
<tsuyoshi> you did it in c first?
<mrvn> yes. I had no fuse bindings for ocaml.
<tsuyoshi> so what turned out to be harder, doing the fs in c, or doing the bindings?
<mrvn> tsuyoshi: getting C not to leak memory or use uninitialized/obsolete pointers.
<tsuyoshi> yeah.. that's what c is like
<mrvn> tsuyoshi: One thing I already know. I will never get this to run with more than 27MB/s. Less counting the redundany. The checksumming alone clocks at 27MB/s on the slow cpu my fileserver has.
<mrvn> 1.2GHz VIA Eden isn't that powerfull.
<flux> iirc I got only 2 MB/s with ocaml-based reed salomon -algorithms :)
<mrvn> flux: hehe. I'm not going to do sha1 checksumming in ocaml.
<flux> (which give you m data devices and n redundancy devices, any n devices can fail to recover the data of m devices)
<mrvn> flux: for that I have to convert ras into libras and add ocaml bindings.
<flux> there's a redundancy library around? nice
<mrvn> Package: ras
<mrvn> Description: Adds redundancy files to archives for data recovery.
<mrvn> Ras is a program that adds m extra files to a set of n files, such that the contents of the n original files can be regenerated from any n of the n+m original files and extra files.
<flux> is it internally in library form?
<flux> or do you need to librariefy it first
<mrvn> Nope. But that shouldn't be too hard.
<flux> indeed
<mrvn> And maybe find someone to write an SSE2 version of it or something for speedup.
<mrvn> So say I do get 10MB/s then I have ~40% cpu for sha1 checksumming and ~40% for reed salomon which leaves ~20% for updating the B-tree and read/write.
<mrvn> That will be really hard to get.
<flux> it is times like these you'd like ocaml to have support for multiple cores?
<flux> ;)
<mrvn> flux: well, sah and reed salomon will be done in C and can run in their own thread. If only I had cores.
<flux> ah, right, it should be relatively easy to make it use more cores then
<mrvn> A simple matter of calling leave_blocking_section(); before the library and enter_blocking_section(); after.
<flux> well, keep it in mind, but worry about the optimizations later
<mrvn> Which I do in all my bindings for anything that takes time.
<mrvn> flux: It would be nice if I could get access to the kernels raid5/raid6 algorithm somehow. That would automatically pick the best for the cpu and maybe even utilize an hardware engine.
<flux> I don't think they expose them at that level
<flux> you could just copy the implementations, though
<mrvn> No. that would need a new kernel interface similar to fuse. Would be generally usefull though. For the aes and other crypto algorithms too.
<flux> also the raid6 of kernel doesn't support (or atleast didn't support the time I last looked) a custom number of redundancy devices, but that might not bother you
<mrvn> flux: raid6 is for exactly 2.
<flux> it does use the same algorithms that would work for any number of devices, though
<flux> but it just isn't written to support them
<mrvn> Most people don't have that many disks.
Alpounet has joined #ocaml
Associat0r has joined #ocaml
ofaurax has joined #ocaml
ttamttam has joined #ocaml
ttamttam has left #ocaml []
jeddhaberstro has joined #ocaml
Associ8or has joined #ocaml
Associat0r has quit [Connection timed out]
wsmith85 has joined #ocaml
AxleLonghorn has quit [Read error: 110 (Connection timed out)]
Alpounet has quit [Read error: 104 (Connection reset by peer)]
ttamttam has joined #ocaml
ttamttam has left #ocaml []
AxleLonghorn has joined #ocaml
AxleLonghorn has left #ocaml []
Alpounet has joined #ocaml
ertai_ has quit ["leaving"]
ertai has joined #ocaml
wsmith85 has quit [Read error: 110 (Connection timed out)]
peper has joined #ocaml
<peper> hello
<peper> foo#blah ~a ~b
<peper> what does ~ mean here?
<hcarty> peper: Labeled arguments. ~a is an argument with the label "a"
wsmith85 has joined #ocaml
<Alpounet> foo is an object, blah a method
<peper> hcarty: so ~a, is short for ~a:a ?
<hcarty> peper: Yes
<hcarty> peper: ~a:foo would pass foo as the ~a argument instead
<hcarty> But if you have a value with the same name as a label, then you can use that shorthand
wsmith85 has quit [Read error: 60 (Operation timed out)]
<peper> yeah, i get it now. wasn't aware of the shortcut form
<peper> anyway
<peper> let triangle = [(x - 10, y - 10); (x + 10, y - 10); (x, y+20)] in
<peper> !backing#polygon ~filled:true triangle ();
<peper> I get: This function is applied to too many arguments,
<peper> oh, () is not necessary
<mrvn> () is only neccessary/used when there is no non-optional argument at the end. you need to have at least one argument there afaik.
<peper> oh i see, makes sense
<mrvn> and for methods that should never be used
<peper> btw. im getting a fair amount of Warning S: this expression should have type unit.
<peper> should i care?
<mrvn> yes
<mrvn> Usualy things have a return value for a reason.
<peper> window#connect#destroy ~callback:GMain.Main.quit;
<Camarade_Tux> he, lablgtk, it builds with that type of warning disabled iirc, but mrvn is right, warnings shouldn't be ignore in most cases
<Camarade_Tux> now, that one, I don't remember, I think it can be ignored safely but don't generalize to all warnings of the type
<Camarade_Tux> s/it builds/it is built/
<mrvn> I always check each case and then add "ignore" where appropriate.
vpalle has joined #ocaml
<peper> hmm
<peper> how do i ignore warnings from a line?
vpalle has quit [Client Quit]
vpalle has joined #ocaml
<peper> they all seem to be triggered by callback registration
<Camarade_Tux> # ignore;;
<Camarade_Tux> - : 'a -> unit = <fun>
<Camarade_Tux> just use 'ignore (window#connect#destroy ~callback:GMain.Main.quit)'
<Camarade_Tux> afk-laundry or I'll have to be naked on tomorrow...
<peper> thanks
<mrvn> don't you unregister your callbacks at the end?
chickenzilla has joined #ocaml
<Camarade_Tux> you don't have to unregister that one : your program just exits ;)
<peper> btw. what would you use for drawing stuff like http://www.red3d.com/cwr/steer/LeaderFollow.html ?
<hcarty> peper: You could use the Cairo, SDL or OpenGL bindings
<peper> hcarty: which one would you choose?
<peper> I was a bit confused how to use cairo with lablgtk
<hcarty> peper: Depends on the application and your purpose in writing it. All of them are useful.
<hcarty> Cairo is the slowest
<hcarty> But it makes very nice looking graphics and you can easily switch between different rendering targets
<Alpounet> for an implementation of Turing Machines in OCaml, do you think using streams would be a good idea ?
<peper> hcarty: i want to make a simple boids simulation
<hcarty> peper: OpenGL or SDL most likely then
<peper> hcarty: for cairo i need http://cairographics.org/cairo-ocaml/ ?
<hcarty> Perhaps Cairo if you want to wrap a Gtk+ gui around it
<hcarty> peper: Yes
<hcarty> What OS are you using?
<peper> Linux
<hcarty> And what version/distribution of OCaml
<peper> 3.10.2
<hcarty> Did you build it your self, use GODI or packages from your Linux distribution?
<peper> packages from my distribution
<peper> well, sort of as it's a source based one
<hcarty> If it has the Cairo bindings as a package then that's probably the easiest
<peper> so i built it from sources with build instructions from my distro (Gentoo)
<hcarty> way to go
<hcarty> Ah
<hcarty> I don't know if Gentoo has the Cairo bindings packaged or no
<hcarty> s/no/not/
<peper> hcarty: i have created the "package" myself and managed to install it
<peper> hcarty: http://rafb.net/p/OF0PtF11.html - these are the installed files
<hcarty> If you go with Cairo, the included examples should help you out
<peper> but when trying to build caboodle i get: Unbound type constructor Cairo.point
<peper> hcarty: which examples do you have in mind?
<peper> i have only seen the on on http://cairographics.org/cairo-ocaml/
<peper> *the one
<hcarty> In the tests (or maybe test) directory in the source tree
<peper> ah i see
<peper> hcarty: is there an example for using it with lablgtk?
<hcarty> Yes
<peper> ah the tests seem to be using lablgtk
<peper> hmm Unbound value Cairo.move_to
<peper> i have added -I +cairo cairo.cmxa
ttamttam has joined #ocaml
<hcarty> peper: You may have to play around with it a bit on your system. An official release of the bindings has never been made. The build system may have a few bugs lurking around.
r0bby has quit [Read error: 104 (Connection reset by peer)]
r0bby has joined #ocaml
<peper> hcarty: hmm, it installs the files as i showed you. not sure what;s wrong
<peper> can i somehow see what are the installed files defning?
<peper> i.e. checkt whether Cairo.move_to is there
ttamttam has left #ocaml []
<peper> can i make ocamplopt error if it doesn't find a library?
<peper> i'm not sure whether it doesn't load cairo or the lib itself is broken
<peper> hcarty: hmm i can't get it working ;/ any hints on how to use opengl with lablgtk?
<hcarty> peper: If the compiler doesn't find the library then it should give you an error
<hcarty> The problems I have had with the Cairo bindings have all been compile time problems, and mostly with the native code compiler
<peper> hcarty: i tried names like foo and it still didn';t
<hcarty> You could try ocamlc rather than ocamlopt
<hcarty> I haven't used any of the OpenGL bindings with lablgtk
<hcarty> Cairo.move_to should be there ... you can check the sources to be sure, but unless something very strange happened it should be there
<peper> and how do i tell ocamlc to use cairo?
<peper> it's in the sources, but i still can't get it working
<peper> hcarty: and btw. which opengl bindings would you recommend? http://wwwfun.kurims.kyoto-u.ac.jp/soft/olabl/lablgl.html ?
<hcarty> peper: You can use ocamlc the same way you use ocamlopt, but use the .cma rather than the .cmxa
<hcarty> Regarding OpenGL bindings, I don't know
<hcarty> lablgl seems to be fairly popular
<flux> the gl2 bindings are less ocaml-like, but they support the more modern feature sof opengl
<hcarty> Yoric[DT], thelema: What is the purpose of the "--with-godi" Batteries configuration option?
th5 has joined #ocaml
<hcarty> It seems to break compilation due to a Makefile mistype
<peper> hcarty: still getting unbound Cairo.* errors
Moca has quit ["http://www.mibbit.com ajax IRC Client"]
<hcarty> peper: I'm not sure what to suggest then. It works here, and the Debian and Fedora packages work
Snark has quit ["Ex-Chat"]
<hcarty> Perhaps taking a peak at their source packages may offer some ideas
<flux> peper, do you have ocamlfind installed?
<flux> although I cannot compile at the moment because my cairo installation is broken ;-) I believe this should work: echo let _ = Cairo.move_to > foo.ml; ocamlfind ocamlc -package -cairo -linkpkg foo.ml
<peper> flux: in which package is ocamlfind?
<flux> findlib
<peper> ok, installing
<peper> ocamlfind: Package `-cairo' not found
<flux> whops, make that plain cairo
<flux> well?
<peper> Error on dynamically loaded library: /usr/lib64/ocaml/site-packages/cairo/dllmlcairo.so: /usr/lib64/ocaml/site-packages/cairo/dllmlcairo.so: undefined symbol: caml_ba_byte_size
<flux> I think I'm forming an opinion that either the cairo package for ocaml is broken, or the ocaml installation is
<flux> but I'm going to sleep, good luck making it work
<peper> my money is on cairo package as im installing it myself
<hcarty> peper: Try "ocamlfind ocamlc -package bigarray,cairo -linkpkg foo.ml"
<hcarty> That may not be any better, but I think the Cairo bindings depend on the Bigarray library
<flux> my META-file for Cairo lists bigarray, but it could well be hand-built or otherwise non-standard
ttamttam has joined #ocaml
<peper> bigarray,cairo worked!
<peper> ta
<bjorkintosh> is ocamlfind not a debian package?
<hcarty> flux: I don't think the OCaml Cairo bindings come with a META file. The Debian folks wrote one, and I think Fedora based theirs off of the Debian one
<animist> bjorkintosh: ocamlfind could be found in ocaml-findlib package
<bjorkintosh> ah. that's why apt-get findlib didn't work. thanks.
_zack has joined #ocaml
schme has quit ["leaving"]
dartelin has joined #ocaml
ttamttam has left #ocaml []
th5 has quit []
seafood has joined #ocaml
ofaurax has quit ["Leaving"]
Ka1Wr3n has joined #ocaml
vpalle has quit [Read error: 110 (Connection timed out)]
Ka1Wr3n has quit ["http://blog.sidu.in"]
Associ8or has quit []
hkBst has quit [Read error: 104 (Connection reset by peer)]
<peper> are there vector math operations available somewhere?
<peper> s/math/algebraic/
animist has quit ["Leaving"]
zerny has quit [Remote closed the connection]
<Alpounet> peper, you mean 2D/3D "dumb" vectors ?
<Alpounet> or abstract vector spaces ?
<peper> Alpounet: dumb vectors will do :)
<Alpounet> have you searched the ocaml hump for that ?
<peper> Alpounet: ocaml hump?
dartelin has quit []
<peper> oh i thought it might be built-in and im just missing it
<Alpounet> In standard there is nothing.
<Alpounet> But it might be part of a OCaml module in OCaml Batteries Included, if I take enough time to work on it
<Alpounet> do anyone know where I can find the grammar of OCaml ?
<Alpounet> I mean the formal grammar.
<peper> hmm
<peper> any idea how would you do it?
<peper> let add2 (x1, y1) (x2, y2) = (x1 +. x2, y1 +. y2)
<peper> :)
_zack has quit ["Leaving."]
chickenzilla` has joined #ocaml
<Alpounet> it seems correct, why ?
<Alpounet> In fact, I've started such work. The question is more about if I'll continue it.
<peper> Alpounet: would be nice if it could be done for universally for n-vectors
<Alpounet> I know
<Alpounet> that's the way I thought of it
<Alpounet> it'd be functorized for dimensions and coords types related informations
jlouis has quit [Read error: 110 (Connection timed out)]
chickenzilla has quit [Read error: 110 (Connection timed out)]
chickenzilla` has quit ["J'y trouve un goût d'pomme."]