systems changed the topic of #ocaml to: Archive of Caml Weekly News http://pauillac.inria.fr/~aschmitt/cwn/ | ICFP Programming Contest 2003 http://www.dtek.chalmers.se/groups/icfpcontest/ | A tutorial http://merjis.com/richj/computers/ocaml/tutorial/ | Good free book http://cristal.inria.fr/~remy/cours/appsem/ | Mailing list (best mailing list ever for any computer language) http://caml.inria.fr/bin/wilma/caml-list
malc has quit [Read error: 110 (Connection timed out)]
polin8 has quit [Read error: 104 (Connection reset by peer)]
Smerdyakov has quit ["Client exiting"]
Smerdyakov has joined #ocaml
teratorn has quit [Remote closed the connection]
teratorn has joined #ocaml
Kinners has joined #ocaml
jdrake has joined #ocaml
Kinners has left #ocaml []
* jdrake thinks this channel is always dead
<teratorn> mostly, yeah :(
<jdrake> have you a second?
<jdrake> i am reading a tutorial and am sort of puzzled by something
<jdrake> let double x = x * 2 in List.map double [ 1; 2; 3 ];; to me this almost looks like a recursive function
<Maddas> it is
<jdrake> but I know that a doubled list comes out of it
<jdrake> why doesn't it have a let rec
<Maddas> oh
<Maddas> it's not recursive at all
<Maddas> sorry
<Maddas> let double x = x * 2 is the declaration
<Maddas> anything recursive about that? no
<Maddas> "in" only shows scope
<jdrake> but doesn't 'in' extend it
<Maddas> no
<jdrake> i am not sure exactly what you mean
<Maddas> if you indent it correctly, you'll see what it means
<Maddas> do you program in any other languages?
<jdrake> i have a properly intended version
<jdrake> i understand what it does, just not the exact functioning of it
<jdrake> yes, i do
<Maddas> which language?
<jdrake> (s)
<jdrake> objective C
<jdrake> C
<Maddas> ObjC is nice :)
<jdrake> C++ a bit ago (I hate it now ;-)
<jdrake> python
<jdrake> ruby
<Maddas> anyway, just imagine that the 'in' doesn't mean much ;p
<jdrake> have used perl
<Maddas> it just shows that the function 'double' is defined in the following block
<jdrake> have touched into lisp style
<Maddas> :)
<jdrake> and forth :-)
<phubuh> let double x = x * 2 is a separate function, and it's only declared inside the in block
<Maddas> yeah
<Maddas> in just shows the scope of double, so to speak ;)
<phubuh> sub { sub double ($) { shift * 2 } map { double } (1, 2, 3) }
<phubuh> :)
<Maddas> exactly :)
<Maddas> imagine like it's a set of { } around the following block, and the 'let' is only valid in that block
<jdrake> so in evil pseudo... do { function double(x) = x*2; for each in [1;2;3] do double; }
<phubuh> yeah
<Maddas> yeah!
<Maddas> you can try it easily
<Maddas> (sorry for the short paste)
<Maddas> # let double x = x * 2 in List.map double [ 1; 2; 3 ];;
<Maddas> - : int list = [2; 4; 6]
<Maddas> # List.map double [ 1; 2; 3 ];;
<Maddas> Unbound value double
<Maddas> :)
<jdrake> ah
<jdrake> in the type section of the tutorial, i have to pass over a lot of it so i can get a better working knowledge of the language
<phubuh> yeah, i had to do that as well
<Maddas> yeah
<Maddas> I'm still in that part :)
<Maddas> Trying to get some handy examples done
<jdrake> i have seen enough that would make it not impossible to make a reasonable objc bridge without wierd syntax
<phubuh> i remember being very confused by the difference between types and type constructors :)
<Maddas> heh
<Maddas> I still am ;)
<jdrake> may I take it you guys like ocaml?
<Maddas> is OcamlNet still developed?
<Maddas> jdrake: I was struggling like hell, but it's getting better now
<Maddas> Had a hard time picking it up :)
<teratorn> Maddas: not that i've seen
<Maddas> What a pity
<teratorn> Maddas: the last release is pretty old, iirc (?)
<Maddas> yeah, 2002 it looks like
<Maddas> and no news since then
<jdrake> the problem I will have is finding things to do with it, without needing everything, but not being evil problem
<Maddas> I thought of doing a FTP client in O'Caml
<teratorn> Maddas: :/
<teratorn> please don't encourage the use of ftp. =)
<Maddas> why?
<jdrake> everybody knows tftp is the future
<teratorn> it's a broken protocol!
<Maddas> huh?
<Maddas> it works fine for me, so far :)
<teratorn> well, s/broken/horrible
<teratorn> it can work, yes.
<Maddas> Fulfills my requirements!
<Maddas> And then, I don't know any better alternative :)
<teratorn> perhaps!
<Maddas> Any proposals?
<jdrake> never use broken with an RFC protocol, only use broken with microsoft protocols
<Maddas> Haha jdrake
<teratorn> Maddas: scp. rsync.
<jdrake> irc client in cocoa
<Maddas> Cocoa rocks
<Maddas> teratorn: I'll have a look
<Maddas> But it looks like just for my "upload something when you aren't home" purposes, FTP is easiest to maintain and best supported
<jdrake> Cocoa -rocks: YES
<teratorn> scp is limited in a couple ways. but useful when you just want to zip little files here and there.
<teratorn> Maddas: also, insecure!
<Maddas> That reminds me, I should phone and ask if the new PowerBook arrived already :)
<jdrake> scp can't resume
<Maddas> teratorn: yes, you've got a point there. I use TLS myself
<jdrake> rsync is beautiful
<teratorn> see, you can run rsync over ssh.
<jdrake> saved my ass many times
<teratorn> jdrake: right, that's one of the limitation i refer to.
<Maddas> But I think implementing ftp-TLS in OCaml is over my head now
<Maddas> Although it was pretty trivial in Perl :)
<jdrake> what do you do when you downloaded a 650mb iso, but got the old one, when the updated a few things in the new one...
<jdrake> rsync it for the differences
<teratorn> jdrake: yay!
<Maddas> Heh
<jdrake> perfect for bittorrent too
<Maddas> I gues I don't use FTP heavily enough to miss the advantages :-)
<Maddas> guess, even
<Maddas> and hey, it's easy to parse compared to other things, I would imagine
<jdrake> if my cousin and I are downloading the same thing and one finishes first, rsync it to the other for the remaining
<Maddas> Sounds very cool
<Maddas> but then, the server needs to support rsync and all, doesn't it
* Maddas reads up
<jdrake> no
<jdrake> it *CAN*, but can just use a shell over telnet/ssh
<Maddas> Ah, cool
<jdrake> rsync: is the dedicated shell, the other formats isn't
<jdrake> well, i have to go to bed before I fall over
<Maddas> So I can use rsync to get files from the shell
<Maddas> sounds very useful
<Maddas> ok, good night :)
<teratorn> 'night
<jdrake> nice speaking in here, I shall do it more often
<jdrake> definately people in here to learn together at some rate with
<mrvn> If you and your brother download something use bittorrent
<Maddas> Not too many people talk here, but always somebody around if you have a problem :-)
<mrvn> s/brother/cusin/
<jdrake> between each other we are faster than bittorrent network usually
<jdrake> you can't exactly offer selective ip transfers
<mrvn> jdrake: bittorrent will connect you both directly.
<jdrake> with some setup yes, but when there are other users on the network it won't work like we want
<jdrake> making a new torrent file for the download takes time
<jdrake> rsync i know how to use right now
<mrvn> depening on the number of users and number of connects you allow or the client.
<jdrake> rsync is more mature than bittorrent as wel
<jdrake> well, sleepy, night
<mrvn> jdrake: rsync and bittorent need to be mixed with ras into one good tool
<mrvn> rsync has some nasty bugs nobody can find.
<jdrake> i have ran into them more than once
<mrvn> sleep well
<Maddas> oh
<Maddas> jdrake: you still there?
<Maddas> You should check out the book from caltech, it's nice. Google for ocaml and book.pdf :)
<jdrake> me be
<jdrake> sleep now though :-)
jdrake has quit ["Oops. This machine just fell asleep"]
async has quit ["Lost terminal"]
foxster has joined #ocaml
foxster has quit [Client Quit]
<Maddas> hug
<Maddas> I would like to "dynamically" check if a module is available, and if yes, then load it
<Maddas> I have the string with the module name, how would I proceed to try to Open it? :)
<Maddas> Would this break type intereference?
mrvn_ has joined #ocaml
<Maddas> How would I 'read' a directory with OCaml?
<Maddas> I need to traverse directories recursively, I'm looking for files of a certain type
<Maddas> The Unix Module looks good
mrvn has quit [Read error: 110 (Connection timed out)]
<mrvn_> yep, unix module
mrvn_ is now known as mrvn
<Maddas> :)
bk_ has joined #ocaml
Demitar has joined #ocaml
polin8 has joined #ocaml
Demitar has quit ["Bubbles everywhere!"]
bk_ has quit ["I'll be back"]
polin8 has quit [Read error: 110 (Connection timed out)]
mattam_ has joined #ocaml
mattam has quit [Read error: 110 (Connection timed out)]
<phubuh> shouldn't type constructors be curriable?
bk_ has joined #ocaml
<mattam_> ?
<Maddas> phubuh: was that with regards to my question?
mattam_ is now known as mattam
<phubuh> Maddas, nope
<mattam> what do you mean phubuh ?
<phubuh> example:
<phubuh> type foo = Foo of string;;
<phubuh> let make_foos xs = List.map Foo xs;;
<phubuh> make_foos ["hi"; "ho"] = [Foo "hi"; Foo "ho"]
<mattam> well, adding (fun x -> ) isn't to much hassle, and it's not a common thing
<phubuh> in this particular case, i have a pretty long list, and (fun s -> On_something s) is duplicated a lot :/
<mattam> you mean you've got lot of different On_something ?
<phubuh> yeah
<mattam> hmmm, maybe using Variants could help then
<phubuh> ah, you mean `These_things?
<mattam> yep
<phubuh> i should read about them :/
<mattam> if you can, you could have a big fun like: fun construct v s = match v with `ThisOne -> `ThisOne s | `Another -> `Another s) and call List.map (construct `ThisOne) list
<phubuh> ah
<phubuh> yeah, that might be possible
<phubuh> hmm. how would i make a function that calls another one and returns true if it did not raise a specific exception, and false if it did?
<mattam> (fun f -> try f (); true with Exc -> false) ?
<phubuh> ah, of course! thanks!
* mattam is prompt and happy at coding caml as he worked on asm routines all day long
<phubuh> ouch! :/
<Maddas> :-/
<mattam> :)
brwill_nearby is now known as brwill
TimFreeman has joined #ocaml
TimFreeman has left #ocaml []
foxster has joined #ocaml
brwill is now known as brwill_zzz
srv has joined #ocaml
bk_ has quit ["I'll be back"]
mattam has quit [zelazny.freenode.net irc.freenode.net]
teratorn has quit [zelazny.freenode.net irc.freenode.net]
mattam has joined #ocaml
teratorn has joined #ocaml
Xcalibor has joined #ocaml
<Xcalibor> hiyas
<phubuh> is there any way to create classes anonymously?
<Xcalibor> ?
<Xcalibor> what use would that have?
<phubuh> well, in java, a common sight is button.addMouseListener(new MouseAdapter () { void onButton (Event e) { ... } });
<phubuh> i should refine my question to "is there any way to create subclasses anonymously"? :)
<Xcalibor> a type class is a kind of interface class... you wouldn't be able to say newtype MyType = ... and then instance {} Myclass where ... ???
<Xcalibor> well... okay, that's in haskell, sorry
<Xcalibor> java uses anonymous subclasses because it doesn't have closures
<phubuh> yeah, most of the time
<Xcalibor> anonymous classes are a kludge to solve this problem
<phubuh> i think anonymous classes are elegant
<Riastradh> Xcalibor, but there are cases when it isn't a kludge to solve a stupid problem...
<Xcalibor> in OCaml you simply give a closure as a call back and that solves it
<phubuh> but anonymous classes can't only be used to implement callbacks
<Xcalibor> Riastradh: yes, agreed, there's a small subset of all problems that they can solve
<Smerdyakov> phubuh, so what's the particular situation where you want to use anonymous classes in OCaml?
<Xcalibor> phubuh: other examples of uses?
<phubuh> Smerdyakov, well, there is no particular situation :)
<phubuh> i was playing around with the repl, and discovered that the object keyword can't be used outside of a class declaration, which makes the "class foo = object ... end" syntax a little confusing
<Smerdyakov> phubuh, ah. So if you don't want to use such a feature, then you should be content to learn that it doesn't exist. :)
<phubuh> i am :)
<Xcalibor> phubuh: anonymous classes are a kludge for this reason: a class is a type and its associated actions (ie. data and an interface to talk to that data about its state)
<Xcalibor> while an action can be anonymous, because it happens once, an object has a unique identity of its own... an anoynous class only lets you create limited objects for limited things... and it tries to supply what an anonymous action (ie. a lambda) would elegantly provide...
<Xcalibor> that's why I say they are a kludge... they are bending the OO model to get a sort of functional benefit... mostly ugly, specially when you have to implement the Even interface methods and fill your anonymous class with "{}" empty methods
<phubuh> # let f = let i = ref 0 in fun () -> incr i; !i;;
<phubuh> val f : unit -> int = <fun>
<phubuh> # f();;
<phubuh> - : int = 1
<phubuh> # f();;
<phubuh> - : int = 2
<phubuh> functions have state too :)
<Xcalibor> phubuh: a closure is not a class (even when you can implement a OO system by using closures)
<Smerdyakov> This discussion is pointless, I think.
<Smerdyakov> The connection between closures and objects is very close.
<Xcalibor> besides, your f has side-effects
<Xcalibor> Smerdyakov: between closure and object, it is; between closure and class it is not
<Smerdyakov> I don't think that's a meaningful comparison in this context.
<Xcalibor> anyway, what you use the anonymous classes in Java you would use a lambda in OCaml (I cannot think of a situation where you wouldn't, I mean)
<Xcalibor> Smerdyakov: agreed, but classes are object factories, and only objects by themselves by using a meta-grammar...
<phubuh> when an object is used as a grouping of related closures with the same state, and i want to pass one such grouping to a function/method, but with modified behavior :)
<phubuh> draw_model (new (object extend drawer method draw x = print_string "null drawer attempted to draw")) m
<phubuh> (imagine that drawer has five other methods that i want to modify as well
<Xcalibor> mmm...
<Smerdyakov> How can I load a file into the OCaml interactive environment?
<Riastradh> Bytecode-compile blah.ml and then '#load "/path/to/blah.cmo"'
<Smerdyakov> Hm. OK!
<Smerdyakov> "Unbound value load"
<Riastradh> You didn't forget the octalthorpe, did you?
<Smerdyakov> Ah, I did "forget" it. I thought it indicated the prompt.
buggs|afk is now known as buggs
<Smerdyakov> Hm... I have a large, many-file OCaml project created by others, and I want to get all of its modules loaded in the repl so I can play with them. Is there any easy way to do this? :\
<Smerdyakov> (The project is usually just compiled for command-line use.)
<Xcalibor> Riastradh: octalthorpe?
<phubuh> Xcalibor, #
<Xcalibor> Smerdyakov: you should be able to create a repl which includes those modules by default the same way you can create one with the graphics module already loaded... it's somewhere in the docs
<phubuh> if Unix.select reports that a socket is readable, but Unix.recv returns 0, does that indicate EOF?
<Xcalibor> # is octalthorpe? curious alias, never heard it before... nice word :-)
<phubuh> (Unix.recv is amazingly poorly documented)
<Xcalibor> phubuh: some modules/functions are very poorly documented on-line... I guess the oreilly book makes a better work
<phubuh> Xcalibor, ah, i'll check!
* Maddas shrugs
<phubuh> is the preliminary web version ok?
<Xcalibor> phubuh: no idea, never checked sorry
<Maddas> I didn't found the O'Reilly book too helpful for modules
<Smerdyakov> Xcalibor, well, right now I'm performing the topological sort on the modules by dependencies manually.
<Riastradh> Yes, # is an octalthorpe, not a hash sign, not a sharp sign, and _definitely_not_ a pound sign.
<Xcalibor> Smerdyakov: whoa...
<Xcalibor> Riastradh: so that's the official name? cool... in spanish has a lot of silly names as well... nobody seems to know which one is the right one, not even the Language Academy lol
<Xcalibor> $ ascii '#'
<Xcalibor> ASCII 2/3 is decimal 035, hex 23, octal 043, bits 00100011: prints as `#'
<Xcalibor> Official name: Pound
<Xcalibor> Other names: Number, Sharp, Crunch, Mesh, Hex, Hash, Flash, Grid, Octothorpe
<Riastradh> That is wrong; it is _definitely_ not a pound.
<Xcalibor> some discrepancies... nevertheless it's a very cool name... it has 8 'pikes'
<Xcalibor> i guess octothorpe comes from that fact
<Riastradh> Yes, indeed.
<Smerdyakov> Why is it not a pound?
<Riastradh> The name 'pound' for it was invented by trucking companies or something and was only slang used by them, or something of that sort, if I remember correctly; there already _is_ a pound sign, anyways.
<Smerdyakov> Why is it wrong because it started as slang?
<Riastradh> See the last clause of my sentence.
<Xcalibor> shit, I've got 89 hits of the Swen email worm just today!
<Riastradh> Swen?
<Xcalibor> yeah.. the 104kb Microsoft Tech security patch one
<Xcalibor> it got called Swen...
<Riastradh> I got 150 of them today, and about 80 of them yesterday.
<Xcalibor> whoah...
<Riastradh> A random slang term -- that is _already_ used for a _different_ symbol --, for a symbol that already has a name, doesn't make sense.
<Smerdyakov> --, isn't even valid morse code.
<Riastradh> You astound me with your vast knowledge of Morse code, Smerdyakov.
<Xcalibor> lol
<Riastradh> And I just got ten more within the past twenty minutes.
<phubuh> if you guys took the turing test, i don't think you'd win
<Xcalibor> Smerdyakov: I think Riastradh used the '--' as an elipsis to his text (like using parentheses as I am doig right now)
<Xcalibor> not even 1 legitimate email in my inbox at the moment, ouch...
<Riastradh> Xcalibor, he's very aware of how I'm using emdashes, but he didn't agree that it was syntactically correct when he first saw my use of a punctuation mark after one, so he bugs me about it whenever I do it now.
<Xcalibor> Riastradh: ah... I see... :-)
<phubuh> I think the comma in the sentence we're talking about is redundant, but otherwise, I agree that punctuation clusters like --; and --, are acceptable
<Riastradh> phubuh, I was explicitly separating the 'for a symbol that already has a name'.
<Xcalibor> which comma? I think I missed that particular discussion...
<Xcalibor> ah, silly me, it is "--,"
<Xcalibor> I see :-)
<phubuh> Riastradh, ah, of course. The comma isn't redundant. :-)
<Smerdyakov> Ugh. ocaml is segfaulting #load'ing .cmo files. :(
<phubuh> let rec loop () = try
<phubuh> client#update ();
<phubuh> loop ()
<phubuh> with Closed -> ()
<phubuh> That function isn't as tail recursive as I thought. :(
<Smerdyakov> Can you move the exception handler to be outside the loop?
<phubuh> Yeah, I can.
<Xcalibor> the compiler isn't optimizing that loop?
<Smerdyakov> Argh... I am rebuilding a library over and over again, and every time I get "File util.cma is not up-to-date with respect to interface Set" when I try to #load it in the repl.
<Smerdyakov> Does anyone know why that would happen?
<Riastradh> Do you have a module Set in util.ml?
<Smerdyakov> Oh. I think I see the problem. This wacky library redefines a module from the standard library.
<Xcalibor> ugh, ugly thing to do...
buggs|afk has joined #ocaml
buggs has quit [Read error: 60 (Operation timed out)]
foxster has quit [Client Quit]
<phubuh> in a chain a (); b () gives a the type unit -> 'a; it can properly infer b's. how can i force that a returns unit?
<phubuh> (the problem is that a is in another module, and ocaml complains about them being incompatible since one has unit -> unit for a, and one has unit -> 'a)
<whee> phubuh: use the ignore function
<phubuh> do i have to write a .mli? :/
<phubuh> oh
<phubuh> it still doesn't know that a returns unit
<whee> er, heh
<whee> it should think a returns unit if you're using it like that
<phubuh> yeah, i thought so too
<phubuh> it even gives a warning if it doesn't
<phubuh> maybe i'm parsing the error wrong
<phubuh> mind if i paste a type error at about 15 lines? :/
<phubuh> oh, wait, i heard they invented this thing called the "World Wide Web" on which you can store information
<phubuh> any ideas? :/
<phubuh> ah, whee, i figured out a way to "cast" a value to unit:
<phubuh> let to_unit () = ()
<phubuh> to_unit value
<phubuh> :)
<phubuh> very ugly, but it'll do
<whee> I think you mean "let to_unit a = ()"
<phubuh> i don't
<whee> but then I think that's the definition of ignore
<whee> your to_unit is unit -> unit
<whee> heh
<phubuh> indeed
<phubuh> what?! the to_unit method works, but only for send_version
<phubuh> then i wrap update in it, it doesn't make any difference :(
<phubuh> this is so confusing
<phubuh> in this piece of code, isn't it REALLY obvious that client#update() is unit->unit?
<phubuh> let rec loop () = loop (client#update ())
<phubuh> in try loop ()
<phubuh> with Closed -> ()
<whee> err, heh
<phubuh> UH. now i've got it complaining This expression has type Module.class = < ... > but is here used with type < ... >, where the two ellipsises represent the exact same text
<phubuh> i feel like i don't grok ocaml's type system when it comes to objects.
<whee> heh
<Riastradh> I think OCaml's object system is quite sucky.
<whee> I think you've got a case of having the same type, but not having the same type :)
<phubuh> whee, that does sound spot on.
<mattam> Riastradh: something particularly annoy you ?
<Riastradh> No first-class classes!
<whee> ocaml's objects would be more fun with finalizers too
<mattam> Riastradh: no first class modules either :)
<whee> unless it has those and I missed it
<whee> mattam: functors work well enough for that, I guess
<phubuh> Riastradh, interesting -- that was the real issue behind by rantings about anonymous inner classes
<mattam> yes, but it's not that flexible
<phubuh> whee, you can set an initializer to set a Gc finalizer :/
srv has quit [Remote closed the connection]
<phubuh> here's my strange error, by the way: http://www.rafb.net/efnet_cpp/paste/results/j1570019.html
<mattam> error is probable before the call point
klamath has joined #ocaml
<phubuh> okay, uh, i just recalled the code from about an hour ago, redid what i was doing, and now it works