smkl changed the topic of #ocaml to: OCaml 3.07 ! -- Archive of Caml Weekly News: http://pauillac.inria.fr/~aschmitt/cwn, A tutorial: http://merjis.com/richj/computers/ocaml/tutorial/, A free book: http://cristal.inria.fr/~remy/cours/appsem, Mailing List (best ml ever for any computer language): http://caml.inria.fr/bin/wilma/caml-list
<vertigo> No docs with the install.
<vertigo> Thanks for the url :-)
vertigo has quit ["Lost terminal"]
Nutssh has quit ["Client exiting"]
maihem has quit ["Client exiting"]
noss has quit ["hej då"]
Kinners has joined #ocaml
Nutssh has joined #ocaml
cjohnson has quit ["Drawn beyond the lines of reason"]
housetier has quit ["#breaks @ irc.highteq.de"]
gim has quit ["Zz."]
mimosa has quit ["J'ai fini."]
door has quit [kornbluth.freenode.net irc.freenode.net]
The-Fixer has quit [kornbluth.freenode.net irc.freenode.net]
axolotl has quit [kornbluth.freenode.net irc.freenode.net]
smkl has quit [kornbluth.freenode.net irc.freenode.net]
door has joined #ocaml
The-Fixer has joined #ocaml
axolotl has joined #ocaml
smkl has joined #ocaml
buggs^z has joined #ocaml
buggs has quit [Read error: 60 (Operation timed out)]
Kinners has left #ocaml []
The-Fixer has quit ["Goodbye"]
The-Fixer has joined #ocaml
The-Fixer has quit ["Goodbye"]
The-Fixer has joined #ocaml
Nate1975 has joined #ocaml
The-Fixer has quit ["Goodbye"]
Nutssh has quit ["Client exiting"]
The-Fixer has joined #ocaml
Nate1975 has quit ["using sirc version 2.211+KSIRC/1.2.4"]
The-Fixer has quit ["Goodbye"]
fjb has quit [Remote closed the connection]
gt2_ has joined #ocaml
ChoJin has joined #ocaml
<ChoJin> hello
Kinners has joined #ocaml
det has quit ["Eat right, exercise regularly, die anyway."]
det has joined #ocaml
ChoJin has quit ["Client exiting"]
The-Fixer has joined #ocaml
The-Fixer has quit []
The-Fixer has joined #ocaml
Kinners has left #ocaml []
karryall has joined #ocaml
wats`tralali has joined #ocaml
mimosa has joined #ocaml
gim has joined #ocaml
wazze has quit [Read error: 110 (Connection timed out)]
cjohnson has joined #ocaml
The-Fixer has quit ["Goodbye"]
housetier has joined #ocaml
fatchoumakou has joined #ocaml
vegai has joined #ocaml
fatchoumakou has quit [Client Quit]
wazze has joined #ocaml
wats`tralali has quit [Read error: 60 (Operation timed out)]
ejt_ is now known as ejt
wats`tralali has joined #ocaml
wazze has quit [Read error: 60 (Operation timed out)]
<vegai> hmm, I wonder what's going on here...
<vegai> bash-2.05b$ ocamlfind ocamlc -package equeue testing.ml
<vegai> Error while linking testing.cmo: Reference to undefined global `Equeue'
<vegai> the same works in the interpreter if I use #use "topfind";; #require "equeue"
<karryall> use -v to see the actual command line
<karryall> it might give you an idea what's wrong
<karryall> I know what's wrong: you forgot -linkpkg
<vegai> ah, yes. Thanks
<vegai> that's an undocumented switch?
<karryall> no, that's documented :)
<vegai> then I looked in wrong places... (manpage, -h)
<Demitar> vegai, it's all in there but it's in the help for the ocaml(c|opt|mktop|...).
<Demitar> Umm, ocamlfind ocaml(c|opt|mktop|...) that is.
<vegai> ohh, it was ocamlfind's switch. Ok
CosmicRay has joined #ocaml
<CosmicRay> good morning everyone
<CosmicRay> is there an ocaml equivolent of asctime() anywhere?
<karryall> godd afternoon CosmicRay
<karryall> hum what's asctime ?
<CosmicRay> asctime is a function that will take seconds-since-epoch and return a human-readable string (such as "Sun 2 Mar 2003 13:15:03" or some such)
<karryall> there's no equivalent I believe
<CosmicRay> that's annoying.
<Demitar> There probably is one hiding somewhere.
<karryall> but there are things about this in the hump I am sure
<CosmicRay> the Unix module has pretty much all the other familiar time functions
<CosmicRay> but not asctime, strptime, or strftime... which is puzzling
<Demitar> Imo the Unix module could use some work getting it more friendly.
<Demitar> CosmicRay, it doesn't have htonl with friends either.
<CosmicRay> ouch.
* Demitar ponders ExtUnix.
<Demitar> CosmicRay, it's not too bad, creating external wrappers is quite simple.
<Demitar> That is I wrapped htonl and ntohl using 2 lines of ocaml and 5 lines of C.
<CosmicRay> well I suppose that does mitigate the problem somewhat...
<CosmicRay> but as someone that has come from Python, which has a very complete interface to standard Unix functions, that's a downer.
<Demitar> Yes, I felt that too. The interface to unix stuff in python is a breeze. Which is why I'm pondering extending it at some point, but I've got too much to do already. :)
<Demitar> The best part of the unix interface in python is that it's so expressive.
<CosmicRay> so how can I find out the magic 2 lines of ocaml and 5lines of C incantation to do this myself? :-)
* CosmicRay finds it a little tough to understand what "expressive" means in terms of languages
<CosmicRay> does it mean "easy to use"?
<CosmicRay> thanks mellum
<mellum> All you need is something like value htonl_c(value v) { return Val_int(htonl(Long_val(v))); }
<karryall> CosmicRay: if you want to do lots of Unix scripting stuff a la python, you might be interested in Cash: http://pauillac.inria.fr/cash/
<mellum> since there's no memory aloocation going on
<mellum> Oh wait, you probably want to pass 32 bit ints and not just 31 bit ints.
<Demitar> mellum, except that I used Int32.t. :)
<Demitar> I'm not sure if I'm leaking but I did: return copy_int32(htonl(Int32_val(v)));
<karryall> that's fine
<mellum> But hey, who cares about lowly 32 bit platforms ;)
<Maddas> oo
<Maddas> Can O'Caml integers hold values up to 2^63 on 64-bit platforms?
<Maddas> er, 2^62 I guess (since they are signed)
<mellum> Maddas: yes
<Maddas> Cool :)
<mellum> Maddas: makes a lot of sense, too :)
<Maddas> yes :)
<Maddas> I wish my laptop weren't still 32 bit, though
<mellum> It's really nice, with just 30 bit into the positive plain ints are really limited for a lot of things like file sizes, but with 62 bit you can count about everything
cjohnson has quit ["Drawn beyond the lines of reason"]
<Maddas> Yeah
<mellum> OTOH, it takes twice as much memory :)
smkl has quit [Read error: 60 (Operation timed out)]
smkl has joined #ocaml
Defcon7 has quit ["changing servers"]
Defcon7 has joined #ocaml
Nutssh has joined #ocaml
wats`tralali has quit ["Ein Dieb ist jemand, der die Angewohnheit hat, Dinge zu finden, bevor andere Leute sie verlieren"]
phubuh has joined #ocaml
gt2_ has quit [Connection timed out]
<CosmicRay> Question about matching... I can use something like "match foo with x :: 5 :: xs -> bar" but not "match bar with x ^ "|" ^ xs -> baz"...
<CosmicRay> why is that, and what am I doing wrong here?
<steele> ^ is a function, :: a type constructor
<CosmicRay> hmmph. Is there any way I can do what I'm trying to do here?
<Smerdyakov> The confusion comes from the fact that all constructors are functions, but not vice versa.
<CosmicRay> matching based on string patterns
<Smerdyakov> CosmicRay, no.
<Smerdyakov> CosmicRay, you can use a regular expression engine implemented inside OCaml or something similar, though.
<CosmicRay> rats. Closest I've been able to come is Str.split, which requires regexps and stuff...
<CosmicRay> yeah but that's a more heavyweight solution and doesn't do the error checking I'd like
<Smerdyakov> Yeah. It's kind of lame that the OCaml standard library doesn't have a function to split on a character, like String.tokens in the SML Basis.
* CosmicRay is coming to the unfortunate conclusion that there are a lot of lame things about the OCaml standard library.
<karryall> Smerdyakov: constructor are not functions
<CosmicRay> also... why can I write:
<CosmicRay> let data = filter (isntip ip) (slurpchan rchan []) in
<CosmicRay> but not:
<CosmicRay> let data = filter (not (isip ip)) (slurpchan rchan []) in
<vegai> Smerdyakov: you know if there's something like equeue done in SML?
<Smerdyakov> karryall, oh, right. Funny OCaml. They are in SML.
<Smerdyakov> vegai, what's equeue?
<Smerdyakov> CosmicRay, look at the types.
<Smerdyakov> CosmicRay, not takes a bool as a parameter and you are passing it a function..
<vegai> Smerdyakov: a small eventhandling framework
<CosmicRay> hmm.
<CosmicRay> Smerdyakov: what should I be doing here?
<Smerdyakov> vegai, then I don't know of any SML equivalent.
<Smerdyakov> CosmicRay, composition instead of application
<CosmicRay> Smerdyakov: I don't quite follow...
<Smerdyakov> CosmicRay, do you know what function composition is?
<CosmicRay> Smerdyakov: on a theoretical level, yes, but I don't quite understand how to apply it to this situation. actually I thought that it what I was doing :-)
<CosmicRay> I thought that my "not" syntax would yield "a function that takes the bool from isip, negates it, and returns that"
<Smerdyakov> CosmicRay, so in algebra you feel that, when f and g are functions, f(g) and f o g are the same?
<CosmicRay> I *think* I am following you
<CosmicRay> "f o g" is "f following g"?
<Smerdyakov> Yes, that is the standard notation in math.
<CosmicRay> it's been a long while since I've worked with the mathematical notation for these :-)
<CosmicRay> anyway, go ahead...
<Smerdyakov> Do you understand what you are doing wrong now, even if you don't know how to fix it?
<CosmicRay> Yes.
<Smerdyakov> So what would you need to know to know how to fix it?
<CosmicRay> I would need a function that takes a 'a -> bool function as an arg, instead of a bool as an arg.
<CosmicRay> but I don't know how to write such a thing....
<Smerdyakov> Well, think at a higher level than that. That is what you want, but there is a very simple sort of function that prevents you from having to think about that intermediate stage, via currying.
<CosmicRay> I'm not sure what I want at a higher level.
<Smerdyakov> What kind of function would be useful in composing two functions?
<CosmicRay> ah, something along the lines of: let compose f g = f g;; compose not (isip foo) ?
<karryall> CosmicRay: of course you want a higher level
<Smerdyakov> Almost. Clearly the definition of compose is wrong, since that way of doing it is what got you into trouble in the first place. :D
<CosmicRay> karryall: forgive me, I was trained on Pascal. :-)
<CosmicRay> Smerdyakov: OK, I want a widget that takes two functions, and returns f o g, and in my case f is "not" and g is "isip"... yes?
<Smerdyakov> CosmicRay, g is (isip foo).
<CosmicRay> right
<CosmicRay> I see this on google:
<CosmicRay> let compose fg = fun x -> f(g(x));;
<Smerdyakov> Cheater!! ;)
<CosmicRay> but I don't understand the "fun x" syntax
<CosmicRay> hehe
<Smerdyakov> Ah, so what you just said is "I'm trying to learn OCaml without reading a book/tutorial on it." ;)
<CosmicRay> no actually I've already read 2 tutorials and have printed (!) the book.
<CosmicRay> it is just a lot to seep into my grey matter :-)
<Smerdyakov> And you've never encountered the fun keyword?
<CosmicRay> no, I've seen both that and the function keyword
<CosmicRay> but far more often just "let funcname args = args + 1" or whatnot
<Smerdyakov> OK, then what don't you understand, since I assume you mean you understadn what these keywords mean...
<CosmicRay> I have merely forgotton what the keywords do :-)
<Smerdyakov> Ah. Then you can find them again in your copious sources of OCaml reading. :P
<CosmicRay> That's what i'm doing right now in the other window
<Smerdyakov> Trust me. It's worth doing, since these are probably THE central keywords for understanding functional programming.
<CosmicRay> unfortunately both of the tutorials I have, have crappy indices
<CosmicRay> ok, but in let compose fg = fun x -> f(g(x));;
* Smerdyakov leaves.
<Smerdyakov> Good luck. :)
<CosmicRay> what exactly is "fg" and where do "f" and "g" come from?
<CosmicRay> Smerdyakov: is there a compose operator built in that does what I'm looking for?
<whee> I think that really should be "let compose f g [everything else]"
<CosmicRay> Smerdyakov: btw thanks for your help
<Smerdyakov> I don't know, but you should understand how to write it anyway.
<CosmicRay> Smerdyakov: I'm just not a fan of wheel reinvention :-)
<karryall> CosmicRay: it's compose f g
<karryall> there's a typo
<CosmicRay> ah.
<CosmicRay> so that statement is equivolent to let compose f g x = f(g(x));; ?
<karryall> exactly
<CosmicRay> ahh. ok, that clicks.
<karryall> now smthg better
<karryall> let ( $ ) f g = fun x -> f (g x)
<CosmicRay> whoa. ok, what does the $ operator do normally?
<karryall> nothing
<karryall> so this defines it as compose
<karryall> but it is an infix operator
<karryall> much nicer than `compose'
<CosmicRay> oh! I forgot you can define operators here...
<CosmicRay> so being infix, that means I could say "f $ g"?
<karryall> yes
<CosmicRay> slick.
<CosmicRay> very slick.
whiskas has joined #ocaml
<CosmicRay> Do exception handlers interfere with making functions tail-recursive?
<karryall> yes they do
<CosmicRay> rats, I was afraid of that :-)
<CosmicRay> let rec slurpchan chan accum =
<CosmicRay> try
<CosmicRay> slurpchan chan ((readline chan) :: accum)
<CosmicRay> with
<CosmicRay> End_of_file -> accum;;
<CosmicRay> That's what I'm doing that is probably wrong.
<CosmicRay> I can't quite figure out how to get the scoping right any other way... for instance if I did "try let foo = readline chan with End_of_file -> accum"... I could not read foo outside the handler to pass it down, plus it wouldn't really return accum like I'd like
<karryall> the trick is to usually use an option somewhere
<karryall> match try Some (readline chan) with End_of_file -> None
<karryall> | Some s -> slurpchan chan (s :: accum)
<karryall> | None -> accum
<CosmicRay> ooh.
<karryall> or List.rev accum
<karryall> the other option is to get rid of the recursion
<karryall> let accum = ref []
<karryall> bgin while true do accum := (readline chan) :: !accum done end with End_of_file -> List.rev !accum
whiskas has quit ["Pa / Bye."]
<CosmicRay> in your match above... "match" and "try" both usually take a "with", but you have only one. is that a typo or a feature?
<karryall> a typo
<CosmicRay> k
<CosmicRay> Is match generally the only way to get the "x" out of "Some x"?
Nutssh has quit ["Client exiting"]
<karryall> yes
<karryall> although you can define a function to do it and fail with the value is None
<karryall> the second piece of code I typed is a bit broken actually
<CosmicRay> that's ok
<CosmicRay> I can figure out how to fix it. I wanted to write the loop functionally though, to learn how.
<CosmicRay> s/functionally/recursively/
<CosmicRay> argh. no ipv6 support in ocaml. that sucks.
<whee> CosmicRay: it's a good idea to not have recursive try blocks too
<vegai> CosmicRay: google reveals a patch though
<whee> at least in this case, anyway, since that won't be tail call optimized
<CosmicRay> vegai: yes, but unfortunately with it not being part of the standard system I can't rely on users having that available
<CosmicRay> whee: yeah, and in my case all those extra exception handlers on the stack do nothing, since the exception will not be kicked back up.
<karryall> CosmicRay: there are patches floating around for Ipv6
<CosmicRay> yeah I see that, but like I said, if I have an IPv6 program, Joe Random User that has "apt-get install ocaml" in Debian or "make install" in NetBSD will not be able to use it.
<CosmicRay> unless they patch too
<karryall> yes, people have asked for this on caml-list but there was no reply from the dev team IIRC
karryall has quit ["going"]
Nutssh has joined #ocaml
Nutssh has quit ["Client exiting"]
The-Fixer has joined #ocaml
cjohnson has joined #ocaml
maihem has joined #ocaml
gt2_ has joined #ocaml
gt2_ has quit [Read error: 60 (Operation timed out)]
gt2_ has joined #ocaml
gt2__ has joined #ocaml
Nutssh has joined #ocaml
gt2 has joined #ocaml
gt2__ has quit [Read error: 60 (Operation timed out)]
housetier has quit ["#breaks @ irc.highteq.de"]
housetier has joined #ocaml
gt2_ has quit [Connection timed out]
lordjim has quit [Read error: 110 (Connection timed out)]
_JusSx_ has joined #ocaml
karryall has joined #ocaml
_JusSx__ has joined #ocaml
_JusSx__ has quit [Client Quit]
_JusSx_ has quit [Read error: 110 (Connection timed out)]
Nutssh has quit ["Client exiting"]
lordjim has joined #ocaml
gt2 has quit [Connection timed out]
buggs^z is now known as buggs
Nutssh has joined #ocaml
karryall has quit [kornbluth.freenode.net irc.freenode.net]
det has quit [kornbluth.freenode.net irc.freenode.net]
karryall has joined #ocaml
Demitar has quit [kornbluth.freenode.net irc.freenode.net]
CosmicRay has quit ["Client exiting"]
Demitar has joined #ocaml
maihem has quit [kornbluth.freenode.net irc.freenode.net]
phubuh has quit [kornbluth.freenode.net irc.freenode.net]
hf_ has quit [kornbluth.freenode.net irc.freenode.net]
themus has quit [kornbluth.freenode.net irc.freenode.net]
Hadaka has quit [kornbluth.freenode.net irc.freenode.net]
maihem has joined #ocaml
phubuh has joined #ocaml
hf_ has joined #ocaml
Hadaka has joined #ocaml
themus has joined #ocaml
phubuh has quit [Remote closed the connection]
buggs has quit [kornbluth.freenode.net irc.freenode.net]
buggs has joined #ocaml
The-Fixer has quit ["Goodbye"]
The-Fixer has joined #ocaml
door has quit [Read error: 60 (Operation timed out)]
door has joined #ocaml
door has quit ["leaving"]
Nutssh has quit ["Client exiting"]