Banana changed the topic of #ocaml to: OCaml 3.08.1 available! | Archive of Caml Weekly News: http://sardes.inrialpes.fr/~aschmitt/cwn/ | A tutorial: http://merjis.com/richj/computers/ocaml/tutorial/ | A free book: http://cristal.inria.fr/~remy/cours/appsem/ | Mailing List: http://caml.inria.fr/bin/wilma/caml-list/ | Cookbook: http://pleac.sourceforge.net/
<vincenz> This is odd
<vincenz> I made a program and it won't even start the main
<vincenz> Doh
<vincenz> $< instead of $^ in my Makefiles
foolio has joined #ocaml
<Smerdyakov> creichen, I don't know about that one.
GreyLensman has joined #ocaml
<vincenz> easy
<vincenz> use an mli
<vincenz> define the type in the mli
<vincenz> (of the class)
* vincenz isn't sure tho
<vincenz> scratch that
<Smerdyakov> mli files don't introduce any bindings for their own corresponding ml files.
<vincenz> howabout
<vincenz> clas....
<vincenz> let f class _ = new class();;
<vincenz> actually
<vincenz> let f c _ = new c();;
<vincenz> class c= objectm ethod g = f c() end;;
<vincenz> never mind that doesn't work
<Smerdyakov> let f constructor _ = constructor ();;
<Smerdyakov> works fine.
<Smerdyakov> You can call it with 'f (new c)'.
<vincenz> ah yes
<vincenz> I fail to see the point tho
<Smerdyakov> Actually:
<vincenz> of the func f
<Smerdyakov> You can call it with 'f (fun () -> new c)'.
<vincenz> Smerdyakov: not really
<vincenz> new c is unit -> class
<Smerdyakov> You could use the point-free style if c had more interesting parameters. :)
<vincenz> ah ok :)
<Smerdyakov> vincenz, no, new c is c.
<vincenz> new c() is c
<Smerdyakov> Nope.
<vincenz> ah!
<vincenz> that's cause it should be
<vincenz> class c params =
<vincenz> empty constructors is just ugly
* vincenz is braindead at this moment, he's been refactoring and cleaning his ocaml code today to a painstaking spotlessness
fooli has quit [Read error: 110 (Connection timed out)]
foolio is now known as fooli
ez4 has joined #ocaml
<creichen> That idea worked perfectly (though I had to introduce another wrapper function, as "f" in my example was also intended to be used outside of class "c"). There's still some code duplication, but nowhere as bad as what I had feared I might have to resort to.
<creichen> Thanks, guys! :-)
cjohnson has joined #ocaml
<Smerdyakov> If you want a definitive answer about better ways, try one of the OCaml mailing lists.
<Smerdyakov> I never choose to use OCaml's OO features of my own free will, so it's always lucky when I know how to answer any question about them. :-)
<creichen> Interesting... so why/when do you pick O'Caml over SML, then?
<Smerdyakov> When joining projects that already use OCaml
<creichen> (Clarification: I don't have the slightest intention of starting a flame war or anything, I'm really just curious)
<Smerdyakov> Most OCaml experts avoid the OO stuff, though. It's not a sign of language mismatch.
<creichen> Ah, right... your advisor's projects seem to use O'Caml quite a bit.
<creichen> So far, I've used the OO stuff exclusively for data hiding purposes, and to save myself a little typing when specifying the functions I want to apply. Meaning that I'm not really doing anything I couldn't get done with modules, as far as I know.
<Smerdyakov> Yes, though, after as long using OCaml as he's had, he would probably keep using it even if he found SML slightly better for a project. :-)
<creichen> Makes sense, of course...
<Smerdyakov> creichen, OO is uniformly less runtime efficient than module-based alternatives in OCaml.
<creichen> Because of dynamic dispatch, I know.
<Smerdyakov> And modules let you express more complicated typing relationships.
<creichen> Such as?
<Smerdyakov> Have you ever seen examples of functors that take as arguments structures whose signatures must agree on the values of some abstract types?
<creichen> I believe I read about that when looking at SML (the "sharing type" construction, or something like that).
<Smerdyakov> Yup. You can't get anything like that with OO.
<vincenz> darn
<vincenz> type inference
<vincenz> ok..
<vincenz> I ahev a class with a method taking as input a virtual class
<vincenz> however when I pass it a class derived from this virtual class (Which then happens to haev a method more) it won't work
<creichen> vincenz: You have to explicitly cast it to that type, if I'm not mistaken.
<creichen> (Using the (:>) infix meta-operator (or whatever one should call it ;-)
<vincenz> thnx!
<vincenz> creichen: it will still use the derived-methods right?
<creichen> I believe so; (value :> type) only tells the type system that you want "value" to be considered to be of type "type", if that's a valid possibility according to the rules of structural subtyping.
<vincenz> alright :)
CosmicRay has joined #ocaml
CosmicRay has quit [Client Quit]
CosmicRay has joined #ocaml
shammah has joined #ocaml
malc_ has joined #ocaml
kinners has quit ["leaving"]
mrsolo__ has joined #ocaml
monochrom has quit ["Don't talk to those who talk to themselves."]
malc__ has joined #ocaml
monochrom has joined #ocaml
malc_ has quit [Read error: 60 (Operation timed out)]
cjohnson has quit ["The main attraction: distraction"]
CosmicRay has quit [Read error: 113 (No route to host)]
malc__ has quit ["leaving"]
GreyLensman has quit ["Leaving"]
Nutssh has left #ocaml []
monochrom has quit ["Don't talk to those who talk to themselves."]
mlh has quit [Client Quit]
srv_ has joined #ocaml
srv has quit [Read error: 232 (Connection reset by peer)]
vezenchio has joined #ocaml
ez4 has quit [Read error: 104 (Connection reset by peer)]
pango has quit ["Client exiting"]
Herrchen has joined #ocaml
Submarine has joined #ocaml
m3ga has joined #ocaml
Submarine has quit ["ChatZilla 0.8.31 [Mozilla rv:1.4.1/20031114]"]
m3ga has quit ["Client exiting"]
kinners has joined #ocaml
srv has joined #ocaml
srv_ has quit [Read error: 232 (Connection reset by peer)]
CosmicRay has joined #ocaml
haakonn has quit [Read error: 110 (Connection timed out)]
haakonn has joined #ocaml
CosmicRay has quit [Read error: 113 (No route to host)]
kinners has quit ["leaving"]
velco has joined #ocaml
cjohnson has joined #ocaml
CosmicRay has joined #ocaml
docelic has quit [Remote closed the connection]
<Demitar> How would I implement the processing of a recursive application? The following won't work but I'm currently out of ideas:
<Demitar> let rec eval_application ~env application =
<Demitar> match application with
<Demitar> IdAppl (id, expr) ->
<Demitar> (Hashtbl.find env id) expr
<Demitar> | ApplAppl (appl, expr) ->
<Demitar> (eval_application ~env appl) expr
<Demitar> in
<Demitar> I want to parse and interpret something like (((func arga) argb) argc). (Although I do it without the ().)
<Smerdyakov> How is that "recursive"?
<Demitar> Now is not the time to complain about my terrible wording. :)
<Smerdyakov> What is the type of eval_application?
<Smerdyakov> (the desired type)
<Demitar> (I'm busy wrapping my mind about ASTs and cannot be disturbed with other oddities. :))
<Demitar> Well...
<Demitar> I guess (ignoring ~env) I'd ideally want (application -> unit) (although I can ignore the output arg when calling).
<Smerdyakov> So every function in the language you are evaluating returns unit?
<Smerdyakov> I need to go now, but I encourage you to ponder why you have chosen to make multiple application constructors for your AST type.
<Smerdyakov> The canonical kind of AST only has one application node.
<Demitar> Ok, got a good reference?
<Smerdyakov> You could look at the OCaml source. I don't have a reference offhand.
<Demitar> Or rather, what type is the application node?
<Smerdyakov> exp * exp -> exp
* Smerdyakov is gone.
<Demitar> Ah, so it's deferred to the evaluation rather than the parsing.
<Demitar> Thanks.
<Demitar> It all makes so much more sense now!
<Demitar> (I see where typing becomes useful in the context.)
docelic has joined #ocaml
velco has quit ["Client exiting"]
cjohnson has quit [Read error: 104 (Connection reset by peer)]
cjohnson has joined #ocaml
mrsolo_ has joined #ocaml
mrsolo__ has quit [Read error: 242 (No route to host)]
vezenchio has quit ["None of you understand. I'm not locked up in here with you. YOU are locked up in here with ME!"]
vezenchio has joined #ocaml
vezenchio has quit [Remote closed the connection]
cjohnson has quit [Operation timed out]
vezenchio has joined #ocaml
mrsolo_ has quit [Read error: 60 (Operation timed out)]
nikkola has joined #ocaml
CosmicRay has quit ["Client exiting"]
mrsolo_ has joined #ocaml
Herrchen has quit ["bye"]
nikkola has quit [Read error: 104 (Connection reset by peer)]
pango has joined #ocaml
salo has joined #ocaml
eugos has joined #ocaml
<salo> can someone help me figure out my problem with:
<salo> List.sort (fun ((p1,_),(p2,_)) -> (compare p1 p2)) somelist
<avlondono> somelist contains those (p1, _) and (p2, _)?
<avlondono> probably what you want is fun (p1, _) (p2, _) -> ....
<TheDracle> Did you try let myFun = fun (p1, _) (p2,_) -> compare p1 p2 in List.sort myFun somelist;;
<salo> let somelist = [(.1,"something");(.3,"else")];;
<avlondono> yeah, so either TheDracle or mine should work, if you enclose them in a parenthesis, it becomes a tuple itself.
<salo> ahhh, i see. thanks!
<TheDracle> So you had a tuple of two tuples.
<TheDracle> Use let liberally, it really makes your syntax clearer.
velco has joined #ocaml
<TheDracle> I hate compaq....
<docelic> sure
<docelic> they're crap
<docelic> regardless of the financial structure ;)
<TheDracle> .. I got this 1945 ipaq.
<TheDracle> Screen cracked a week after I bought it.
<TheDracle> They said the warranty wouldn't cover it. I think it's faulty, I didn't even drop it.
<TheDracle> The screen is just incredibly fragile.
<TheDracle> Their customer service is outsourced to somewhere in India or something.
<TheDracle> I put like a 300 dollar investment into a paperweight basically.
<TheDracle> And, in order to repair it they want 200 bucks.
<TheDracle> So, basically a 600 dollar fault piece of shit that will break the week after getting it repaired.
<salo> if you paid by credit card you may have an option
<salo> i had my own sad ipaq story too
<TheDracle> Yeah, to just deny payment maybe.
<TheDracle> They're so expensive, you'd think they'd come with some kind of warranty.
<salo> also, some credit cards offer extended warranties, such as replacement due to breakage in first 60 days
<TheDracle> Yeah, I think Utah State law dictates they'd have to replace it in the first 6 months.
<TheDracle> But they've drawn this entire thing out for maybe 10 months.
<TheDracle> Lol.
<TheDracle> So, having shotty customers service has covered their asses in that regard.
CosmicRay has joined #ocaml
<dan2> CosmicRay: hey
velco has quit ["I'm outta here ..."]
<TheDracle> Hm, looks like I can get a brand new one on ebay for the same price they want for repairing it.
<salo> is there a built in function for taking the first n elements of a list?
mrsolo_ has quit [Read error: 104 (Connection reset by peer)]
velco has joined #ocaml
<salo> how about:
<salo> let sublist n l =
<salo> let rec builder n l out = match n, l with
<salo> 0, _ -> List.rev out
<salo> | n , [] -> invalid_arg "requested sublist longer than list"
<salo> | n , y::rest -> builder (n - 1) rest (y::out)
<salo> in builder n l [];;
<salo> perhaps there is a more efficient way
<avlondono> I doubt there is anything tail recursive. If you won't use the n in the middle match, I'd rather use _, but that's just style. And I would sort them the other way around, as hitting the second match is improbable, the first match only once and the third one n times.
<simon> why not (out::y::[])?
<avlondono> anyway I'd rather write let rec builder n l out = if (n <> 0) then begin match l with | h :: t -> builder (n - 1) t (h :: out) | [] -> raise blah end else List.rev out
* salo considers
<salo> simon: you suggest (out::y::[]) and then not reversing the final output?
<salo> and do you mean: out @ [y]
<simon> salo, I asked why not, but yeah.
<simon> salo, oh right.
velco is now known as Moriarti
Moriarti is now known as velco
<salo> out @ [y] takes length of out many steps, so i am pretty sure it is less efficient
<salo> also, it is not tail recursive
salo has quit []
vezenchio has quit ["None of you understand. I'm not locked up in here with you. YOU are locked up in here with ME!"]
lmbdwr has joined #ocaml
<lmbdwr> hi ppl
<lmbdwr> anyone ever heard of (deep) blue calculus ?
CosmicRay has quit [Remote closed the connection]
CosmicRay has joined #ocaml
docelic has quit [Read error: 110 (Connection timed out)]
eugos has quit ["Leaving"]
<Tristram> hello, I'm again having problems using a librairie
<Tristram> I launchd
<Tristram> I launched ocaml netclient.cma
<Tristram> and I get : Reference to undefined global `Str'
<haakonn> try ocaml -I str.cma
velco has quit ["I'm outta here ..."]
<Tristram> should I load str manualy?
<avlondono> ocaml str.cma netclient.cma should do it
<avlondono> I don't know what else is needed, but at least that will load str.cma
<Tristram> ho, all right, I thought Str was always loaded (like String)
<Tristram> thank you both
cjohnson has joined #ocaml
Hadaka has quit [Read error: 60 (Operation timed out)]
monochrom has joined #ocaml
CosmicRay has quit ["Client exiting"]
<dan2> is there anything i can use to get ocaml to read from mailspools
<Smerdyakov> open_in
<dan2> Smerdyakov: ?
<dan2> Smerdyakov: hmm, s/mailspools/maildirs/
<Smerdyakov> You can use most any C library that does that.
monochrom has quit ["Don't talk to those who talk to themselves."]
<dan2> Smerdyakov: but... that wouldn't exactly be easy
<Smerdyakov> It would, actually.
<dan2> Smerdyakov: oh?
<dan2> Smerdyakov: is it just declaring externals?
<dan2> Smerdyakov: how easy?
<Smerdyakov> Read the manual.
<dan2> Smerdyakov: hmm, I don't know if I feel like spending time creating stub code
<dan2> hmm camlidl
GreyLensman has joined #ocaml
ez4 has joined #ocaml
mattam has quit [Read error: 104 (Connection reset by peer)]
mlh has joined #ocaml