sponge45 changed the topic of #ocaml to: Discussions about the OCaml programming language | http://caml.inria.fr/
bluestorm_ has quit ["Konversation terminated!"]
cjeris has quit [Read error: 104 (Connection reset by peer)]
mnemonic has joined #ocaml
ikaros has quit ["Leaving"]
postalchris has quit [Read error: 110 (Connection timed out)]
love-pingoo has quit ["Connection reset by pear"]
smimou has quit ["bli"]
ikaros has joined #ocaml
joshcryer has quit [Connection timed out]
joshcryer has joined #ocaml
malc_ has quit ["leaving"]
postalchris has joined #ocaml
postalchris has quit [Client Quit]
pantsd has quit [Read error: 110 (Connection timed out)]
mnemonic has quit ["leaving"]
joshcryer has quit [Connection timed out]
a-priori has quit [Remote closed the connection]
a-priori has joined #ocaml
mefyl has quit [Read error: 110 (Connection timed out)]
jeffs has joined #ocaml
Mr_Awesome has quit ["...and the Awesome level drops"]
b00t has joined #ocaml
diffbavis has quit [Read error: 104 (Connection reset by peer)]
ludwig- has quit [Read error: 110 (Connection timed out)]
Submarine has joined #ocaml
malc_ has joined #ocaml
joshcryer has joined #ocaml
joshcryer has quit [Connection reset by peer]
Smerdyakov has quit ["Leaving"]
a-priori has quit [zelazny.freenode.net irc.freenode.net]
benny_ has quit [zelazny.freenode.net irc.freenode.net]
descender has quit [zelazny.freenode.net irc.freenode.net]
Oatmeat|umn has quit [zelazny.freenode.net irc.freenode.net]
gim has quit [zelazny.freenode.net irc.freenode.net]
ppsmimou has quit [zelazny.freenode.net irc.freenode.net]
gunark has quit [zelazny.freenode.net irc.freenode.net]
eradman has quit [zelazny.freenode.net irc.freenode.net]
a-priori has joined #ocaml
benny_ has joined #ocaml
descender has joined #ocaml
Oatmeat|umn has joined #ocaml
gim has joined #ocaml
ppsmimou has joined #ocaml
gunark has joined #ocaml
eradman has joined #ocaml
slipstream has quit [Read error: 104 (Connection reset by peer)]
gunark has quit [Connection timed out]
gunark has joined #ocaml
slipstream has joined #ocaml
malc_ has quit ["leaving"]
Saparok has joined #ocaml
Saparok has quit ["NO CARRIER"]
smimou has joined #ocaml
bluestorm has joined #ocaml
<cmvjk> i'm looking at this C binding code for ocaml, and there's a function in here that takes this enum type, then uses a case statement to return the exact number of each of the values, and then calls Int_val on that...
<cmvjk> is that necessary? I'm not familiar enough with C to know if enums are actually Ints, but wouldn't it be acceptable to just call Int_val directly on an enum type?
slipstream has quit [Read error: 104 (Connection reset by peer)]
<cmvjk> or rather, Val_int I mean.
<flux-> cmvjk, maybe it wants to use same (stable) numbers even if the C implementation changes
slipstream has joined #ocaml
<flux-> I'm assuming they eventually end up to an ocaml enumeration type
<flux-> and not just used as an opaque type that comes out and goes in to the library
<cmvjk> yeah, the return value becomes an ocaml enum type.
<flux-> so changing the order of enums in C won't break the bindings
<flux-> it might also want a warning from the compiler if it handle all the enumerations
<cmvjk> hmm. that's a good point.
<flux-> +doesn't
slipstream has quit [Read error: 110 (Connection timed out)]
<flux-> wish there were Hashtbl.change : ('a, 'b) t -> 'a -> ('b -> 'b) -> unit, it would save my half the hashing
<flux-> hm, with a default argument for 'not found'
smimou has quit ["bli"]
slipstream has joined #ocaml
<flux-> hmm.. how fast is Set.split?
<flux-> O(log n) best case, how about worst case?
slipstream has quit [Read error: 110 (Connection timed out)]
a-priori has quit [Remote closed the connection]
gunark has quit [Remote closed the connection]
gunark has joined #ocaml
a-priori has joined #ocaml
love-pingoo has joined #ocaml
jlouis_ has quit [Remote closed the connection]
bluestorm has quit [Remote closed the connection]
ludwig- has joined #ocaml
<love-pingoo> I've got questions about portability... it'd be perfect if there was somebody on a powerpc around.
<love-pingoo> Are OCaml ints always 31 bits and little endian ?
<love-pingoo> I've got some code translating two chars (read as little endian signed short int) into an int, and I'm wondering how portable it is..
<flux-> I don't think they are ever _smaller_ than 31 bits
<love-pingoo> flux-: I'm bothered by 64bit archs
<flux-> but endianess, no. but how do you detect endianess in ocaml?
<flux-> does the code use Obj.magic?
<love-pingoo> for example I used to do (0x7fff0000 lor i) to add the highest bits to i (which is the sum of the two bytes)
<love-pingoo> it wouldn't work for 63bit ints
<love-pingoo> flux-: Printf "%x\n" i ?
<flux-> love-pingoo, how do you determine endianess from that?
<love-pingoo> Actually I don't care about the internal representation, I just want to be sure that the operations that I used have a portable meaning.
<love-pingoo> flux-: I don't.. but I'd see if the int is 63bits
<flux-> love-pingoo, maybe you should use Int32.t and Int64.t if you 'abuse' their representation ;)
<flux-> but they are boxed..
<love-pingoo> that's not a bad idea
<love-pingoo> flux-: what's your architecture ?
<flux-> I'm on 32-bit x86
<love-pingoo> (I mean, what's the architecture of your computer, no offense)
<flux-> :-)
<love-pingoo> I'm not even sure about what test I should run..
<flux-> I have access to 64-bit sparcv9 though
<flux-> and it has ocamlc/ocamlopt
<love-pingoo> what's sparc endianness
<love-pingoo> my co-worker on amd64 is back so I already have 64bits little-endian
<flux-> sun machines are, like the internet, big endian
<flux-> I can copy/paste some ocamlc commands in if you want
<flux-> make that ocaml, not ocamlc..
<love-pingoo> Printf.printf "%x" (-1) ?
<flux-> hm, it says 7fffffff- : unit = ()
<flux-> I wonder if ocaml is compiled to be 64 bit
<ppsmimou> # Printf.printf "%x" (-1);;
<ppsmimou> 7fffffffffffffff- : unit = ()
<ppsmimou> on my 64LE
<love-pingoo> good
<flux-> ocamlopt says the same
<love-pingoo> ppsmimou: can you confirm that (-1) lxor 0xffff = -1 ?
<love-pingoo> that seems stupid...
* love-pingoo goes lunch
<ppsmimou> love-pingoo: raté !
<flux-> I wonder how I should fix that compilation
<ppsmimou> # (-1) lxor 0xffff;;
<ppsmimou> - : int = -65536
<flux-> ./configure -cc 'gcc -m64' is apparently a step to the right direction
<flux-> I wonder if it's worth the trouble, though :)
<flux-> it will break the byte code compatibility, right?
<flux-> with 32-bit archs
pstickne has quit [Read error: 145 (Connection timed out)]
ramkrsna has quit [Read error: 113 (No route to host)]
ikaros has quit ["segfault"]
jlouis has joined #ocaml
<love-pingoo> ppsmimou: I actually get the same...
<love-pingoo> I meant land
<love-pingoo> no
<love-pingoo> I did a stupid simplification
<love-pingoo> (-1 lxor 0xffff) lor 0xffff
<love-pingoo> which is now trivial
pstickne has joined #ocaml
ramkrsna has joined #ocaml
ikaros_ has joined #ocaml
b00t has quit [Remote closed the connection]
pango_ has quit [Remote closed the connection]
pango has quit [Remote closed the connection]
pango has joined #ocaml
pango_ has joined #ocaml
cmvjk has quit [Read error: 110 (Connection timed out)]
cmvjk has joined #ocaml
diffbavis has joined #ocaml
postalchris has joined #ocaml
cwenner has joined #ocaml
cwenner has left #ocaml []
paciek has joined #ocaml
Submarine has quit ["Leaving"]
cjeris has joined #ocaml
Smerdyakov has joined #ocaml
<postalchris> There's no string hash function in the standard library... what do you all do when you need one?
<Smerdyakov> The generic hash function does _something_.
<postalchris> You mean Hashtbl.hash?
<flux-> yes
<postalchris> Stupid. I didn't look there...
<flux-> I recently tried to implement cuckoo hashing in ocaml, but it requires two different hashes, and I didn't manage to produce those with the standard hashing functinos..
<postalchris> I've made that mistake in the past too... :-[
<flux-> and it's be pretty inconvenient to require the user to provide that
<flux-> s/s/d/
ocaml_newbie has joined #ocaml
<Smerdyakov> Good, the expert is here now. You can ask him.
<ocaml_newbie> Smerdyakov: What do you mean?
love-pingoo has quit ["Leaving"]
benny has joined #ocaml
<ocaml_newbie> could someone please explain to me the package/module system of ocaml. i installed ounit which works fine (at least make test tells me so). how do i have to compile a simple file (e.g. test.ml) which only contains "open OUnit" and another line with assert_failure "some text"'
<ocaml_newbie> if i run 'ocamlc test.ml', i will get a syntax error
<ocaml_newbie> the open clause seems to be alright, but assert_failure produces the syntax error
<jeffs> could you post it?
<ocaml_newbie> open OUnit
<ocaml_newbie> assert_failure "some text"
<ocaml_newbie> that's all
<ocaml_newbie> actually there's a new line between the both lines
<jeffs> that's fine
<ocaml_newbie> jeffs, should it work that easily by running 'ocamlc test.ml'?
<jeffs> so you compile it something like....
<jeffs> ocamlc ounit.cma test.ml ?
<jeffs> i'm not sure what ounit is
<jeffs> not that it matters, just as long as it's there
<ocaml_newbie> i don't get it :-(
<ocaml_newbie> what os are you using, jeffs?
<ocaml_newbie> i'm using debian.
<jeffs> right now i'm in windows, but i also use macos x
<ocaml_newbie> if you install a library, how do you use that?
<ocaml_newbie> or do you use the sources themselves?
<jeffs> you can compile from either
benny_ has quit [Read error: 110 (Connection timed out)]
<jeffs> try putting ;; after "open OUnit"
<jeffs> open OUnit;; assert_failure "some text"
<jeffs> well if the library is compiled and in my path I just do
<jeffs> ocamlc library.cma mycode.ml -o myexecutable
<ocaml_newbie> ok, now i'm getting: "Unbound module OUnit"
<jeffs> oooook
<jeffs> so either the name of the module is wrong, or it's not being given to the compiler
<ocaml_newbie> is the order of files important to the compiler?
<jeffs> yes
<cmvjk> you might have to do "-I +OUnit" also?
<cmvjk> to put the directory in the path? I don't know...i have to do that with lablgtk
<jeffs> ya, if the library isn't with the rest of the ocaml library you have to add "-I /path/to/library" to your compile command
<ocaml_newbie> hm, thanks
<ocaml_newbie> still does not work, but i have some pointers from you :-)
<jeffs> oen thing si
<jeffs> er
<jeffs> one thing is...
<ocaml_newbie> :-)
<jeffs> if the file is "ounit.ml" or "ounit.cma", the module that provedes will be called "Ounit"... only the first letter is capitalized
<ocaml_newbie> the file is oUnit.*
<jeffs> ah
<ocaml_newbie> i'm getting a step further
<jeffs> well as long as you do "ocamlc -I /path/to/library/ oUnit.cma mycode.ml" it should at least load the libray for use in your code
<ocaml_newbie> now i'm getting "Reference to undefined global `Unix'"
<jeffs> ah!
<ocaml_newbie> what do i have to include now?
<jeffs> put "unix.cma" before oUnit.cma, perhaps oUnit requires the Unix library
<ocaml_newbie> why in small letters?
<jeffs> "ocamlc -I /path/to/library/ unix.cma oUnit.cma mycode.ml"
<jeffs> unix.cma provides the module, Unix
<ocaml_newbie> thanks, jeffs, it works :-)
<jeffs> excellent!
<ocaml_newbie> that was really frustrating
<jeffs> i recommend trying to make your own little library so you can see how it works
<ocaml_newbie> i will do that
<jeffs> make a file called "add.ml" and put "let add x y = x+y" in it
<ocaml_newbie> are there any build tools you use?
<jeffs> naw, I just type everythign out. I dont make large projects
<ocaml_newbie> i already have a foo.ml containing a "let f x = x + 3;;" ;-)
<jeffs> so you can make add into a library by doing "ocamlc -a -o add.cma add.ml"
<ocaml_newbie> you said you're using lablgtk, can you recommend that?
<jeffs> then you can make a new file that uses the add library: "Add.add 1 3"
<jeffs> i dont build guis in ocaml either :)
<jeffs> that was someone else...
<cmvjk> i mentioned lablgtk; but I haven't messed with it at all yet. other than installing it...
<ocaml_newbie> ok, i will try it
<ocaml_newbie> thank you very much
<jeffs> man, good luck
<jeffs> afk
<ocaml_newbie> dito
mnemonic has joined #ocaml
hcarty has quit ["leaving"]
hcarty has joined #ocaml
hcarty has quit [Client Quit]
hcarty has joined #ocaml
LoneWolf1066 has joined #ocaml
diffbavis has quit [Read error: 104 (Connection reset by peer)]
<cmvjk> there's a function Wosize_val(v), in the C ocaml bindings, that returns the size, in words, of some block v, but
<cmvjk> (and this is a dumb question)
diffbavis has joined #ocaml
<cmvjk> how much is a word?
<cmvjk> is it just 32 bits on a 32 bit system, etc?
<cmvjk> ah, nevermind, i got it.
<cmvjk> i think that's right.
smimou has joined #ocaml
<mnemonic> hi
<jeffs> hi
jlouis has quit [Remote closed the connection]
love-pingoo has joined #ocaml
_JusSx_ has joined #ocaml
postalchris has quit [Read error: 145 (Connection timed out)]
love-pingoo has quit ["Connection reset by pear"]
rickardg has joined #ocaml
bluestorm_ has joined #ocaml
slipstream has joined #ocaml
ikaros_ has quit ["Leaving"]
jlouis has joined #ocaml
mbishop_ has joined #ocaml
mbishop has quit [Connection timed out]
malc_ has joined #ocaml
mbishop_ is now known as mbishop
malc__ has joined #ocaml
Ugarte has joined #ocaml
malc___ has joined #ocaml
malc_ has quit [Read error: 110 (Connection timed out)]
<ocaml_newbie> is there a library function to create a list containing of the first n natural numbers?
<mattam> nope
<ocaml_newbie> :-(
<cmvjk> like range or something?
<ocaml_newbie> yes
<cmvjk> range.
<cmvjk> doesn't that exist?
<ocaml_newbie> ???
pantsd has joined #ocaml
<mattam> i don't think so
<cmvjk> oh
<cmvjk> well, then.
malc_ has joined #ocaml
<mattam> it's a one liner though
<cmvjk> that's why i was thinking it existed, whatever ocaml tutorial i read defined it over and over again
malc__ has quit [Read error: 110 (Connection timed out)]
<mattam> The ocaml standard library has only the obvious things in it, maybe extlib has such things
<ocaml_newbie> would someone be so kind and write down the one-liner.
<ocaml_newbie> let rec range n = match n with 0 -> [] | _ (n :: range (n-1));;
<ocaml_newbie> that's my lousy attempt :-)
<jeffs> that looks like it should work fine
<ocaml_newbie> it doesn't
<jeffs> oh i see the mistake
<jeffs> let rec range n = match n with 0 -> [] | _ -> (n :: range (n-1));;
<jeffs> you missed the 2nd ->
<ocaml_newbie> thanks
<jeffs> np
<ocaml_newbie> and of course, i forgot to reverse the list
<mattam> maybe you want them in order
<ocaml_newbie> how?
<mattam> let rec to_n n = let rec aux = function n' with when n >= n' -> [] | n' -> n' :: aux (succ n') in aux 0
<ocaml_newbie> with append?
<mattam> this one is without accumulator
<mattam> let rec to_n n = let rec aux acc = function n' with when n >= n' -> List.rev acc | n' -> aux (n' :: acc) (succ n') in aux 0 []
<mattam> this one is the accumulator version, it is tail-recursive
<ocaml_newbie> i will have to digest that
<jeffs> the first one doesn't seem to work, mattam
<mattam> maybe that's a bit too much at your stae :)
<jeffs> also what's "with when"?
<ocaml_newbie> i don't know the when keyword
<jeffs> when is just an extra constraint on the pattern matching
<mattam> oh right syntax error
<mattam> let rec to_n n = let rec aux = function n' when n >= n' -> [] | n' -> n' :: aux (succ n') in aux 0
<jeffs> it still doesn't work :)
<ocaml_newbie> :-)
<jeffs> it gives an empty list every time
<ocaml_newbie> yes
<mattam> oh right >= should be replaced by <=
<jeffs> or there's this let to_n n =
<jeffs> let l = ref [] in
<jeffs> for i = n downto 1 do
<jeffs> l := i::!l;
<jeffs> done;
<jeffs> !l
malc___ has quit [Connection timed out]
<mattam> ouch :)
<ocaml_newbie> not very ocamlish (or what is the word that describes pythonic for ocaml)
<jeffs> it's perfectly ocaml
<jeffs> it's just imperative instead of functional
<mattam> let rec to_n n = let rec aux = function n' when n < n' -> [] | n' -> n' :: aux (succ n') in aux 1 is the one you want
<ocaml_newbie> thank you, mattam
<jeffs> what are those apostraphes doing, mattam?
<jeffs> oh
<jeffs> i see, just naming
<mattam> it's just part of the ident
<ocaml_newbie> but this little conversation shows that the range function should be in the standard libraries
<mattam> how is that ?
<pango> ocaml_newbie: what would you start learning the language with, then ;)
<jeffs> hehe true
<ocaml_newbie> :-)
<ocaml_newbie> hi pango
<pango> btw range can be written tail rec, and without List.rev (by building the list in reverse in the first place)
<pango> ocaml_newbie: hi
<ocaml_newbie> i just found camelia (http://camelia.sourceforge.net/), did someone of you try that?
<pango> ocaml_newbie: it's a very limited editor
<mattam> btw, you can probably replace your use of range with an explicit recursion on an int
<pango> ocaml_newbie: ok for learning syntax, but not for heavy duty (no support for multi-file projects, for one)
<ocaml_newbie> ok, so maybe the right tool for me now
malc_ has quit [Connection timed out]
<jeffs> I just use xemacs.
<ocaml_newbie> do you operate that by keyboard only? or do you also use the mouse?
<jeffs> I use whichever is easiest for a particular task
<jeffs> if I want to scroll a long ways i use the mouse
<ocaml_newbie> I don't like to switch to the mouse too often
<jeffs> xemacs can be operated from the keyboard 100%
<jeffs> if you really wanted
<ocaml_newbie> that's probably the reason i'm not using emacs
<jeffs> the only keyboard shortcuts I use are
<jeffs> ctrl-k, for deleteting to the end of the line
<ocaml_newbie> but the shortcuts aren't that short,often you have to use the meta-key plus several keystrokes
<jeffs> ctrl-alt-x for sending an expressinon to the ocaml toplevel
<jeffs> ya I dont use those long ones
<ocaml_newbie> sometime ago i wanted to do some lisp
<ocaml_newbie> and the way to go seems to be emacs
<jeffs> ya i bet emacs supports lisp editing very well
<ocaml_newbie> but a colleague of mine is a lisp guy who uses vi
<ocaml_newbie> and i would prefer vi
<jeffs> hehe, well, people have their preferences
<ocaml_newbie> for ocaml too
<jeffs> you can edit ocaml code in vi
<jeffs> there's even an ocaml mode if you wanted to use it
<jeffs> I've never tried it but i suppose it works well enough.
<ocaml_newbie> i'm not a vi expert, but i like it better than emacs
<pango> emacs has support for running the ocaml debugger, that you probably won't get with another editor
<ocaml_newbie> i already promised to try emacs, pango ;-)
<jeffs> if you can find out how to make vi and ocaml work well together, i say go for it
<hcarty> ocaml_newbie: omlet is a nice vim setup for ocaml
<ocaml_newbie> nice link, jeffs
<pango> not sure what other editor can use *.annot files too
<hcarty> The only reason I'm using emacs + tuareg rather than vim + omlet is that omlet seems to become very slow with longer OCaml source files
<jeffs> I've found tuareg has a couple bugs so I prefer the regular emacs ocaml mode.
<jeffs> In tuareg I get annoyed when it only sends part of my function to the toplevel.
<pango> avoid latest tuareg mode release, it's known to be buggy
<jeffs> ah
<ocaml_newbie> pango: what are *.annot files?
<jeffs> perhaps I should downgrade on my mac then
<pango> iirc 1.45 is fine, 1.46 is broken, something like that
<pango> ocaml_newbie: when you compile with -dtypes, ocamlc or ocamlopt generate *.annot files that contain the types inferred
<pango> ocaml_newbie: emacs known how to use that to show you the type of the element below the cursor
<ocaml_newbie> i see
<hcarty> ocaml_newbie: http://www.lix.polytechnique.fr/~dbaelde/productions/omlet.html if you want to stay in vim land for the time being
<jeffs> h really!
<jeffs> that's cool, I didn't know that
<ocaml_newbie> hcarty: thanks
<pango> jeffs: C-c C-t in tuareg-mode
<jeffs> i'll have to try that sometime
<jeffs> afk
dark_light has quit [Remote closed the connection]
<ocaml_newbie> bye
ocaml_newbie has quit [Remote closed the connection]
<pango> s/known/knows/
cmvjk has quit ["Leaving"]
pango_ has quit [Remote closed the connection]
pango has quit [Remote closed the connection]
pango has joined #ocaml
pango_ has joined #ocaml
bluestorm_ has quit ["Konversation terminated!"]
cjeris has quit [Read error: 104 (Connection reset by peer)]
love-pingoo has joined #ocaml
rickardg has quit [Remote closed the connection]
LoneWolf1066 has quit ["Leaving"]
pango_ has quit [Remote closed the connection]
pango has quit [Remote closed the connection]
pango_ has joined #ocaml
pango has joined #ocaml
postalchris has joined #ocaml
_JusSx_ has quit [Client Quit]