mbishop changed the topic of #ocaml to: Discussions about the OCaml programming language | http://caml.inria.fr/ | Grab Ocaml 3.10.0 from http://caml.inria.fr/ocaml/release.html (featuring new camlp4 and more!)
screwt8 has quit [Remote closed the connection]
screwt8 has joined #ocaml
love-pingoo has quit ["Connection reset by pear"]
buluca has quit [Read error: 113 (No route to host)]
ppsmimou has quit [anthony.freenode.net irc.freenode.net]
flux has quit [anthony.freenode.net irc.freenode.net]
ppsmimou has joined #ocaml
flux has joined #ocaml
buluca has joined #ocaml
qwwqe has joined #ocaml
pantsd has joined #ocaml
screwt8 has quit [Read error: 104 (Connection reset by peer)]
seafoodX has joined #ocaml
pantsd has quit ["Leaving."]
screwt8 has joined #ocaml
G has joined #ocaml
G_ has quit [Connection timed out]
seafoodX has quit []
seafoodX has joined #ocaml
G_ has joined #ocaml
visage has joined #ocaml
G has quit [Connection timed out]
visage has quit []
TFK has joined #ocaml
TFKv2 has quit [Read error: 110 (Connection timed out)]
qwwqe has quit [Remote closed the connection]
buluca has quit [Read error: 113 (No route to host)]
seafoodX has quit []
seafoodX has joined #ocaml
shawn has joined #ocaml
slipstream has joined #ocaml
slipstream-- has quit [Read error: 104 (Connection reset by peer)]
seafoodX has quit []
seafoodX has joined #ocaml
seafoodX has quit []
Smerdyakov has quit ["Leaving"]
Submarine has joined #ocaml
another has joined #ocaml
piggybox has quit [Nick collision from services.]
tomppa has joined #ocaml
seafoodX has joined #ocaml
G_ is now known as G
tomppa has quit [Read error: 110 (Connection timed out)]
ygrek_ has joined #ocaml
smimou has joined #ocaml
seafoodX has quit []
ygrek_ has quit [Remote closed the connection]
ygrek_ has joined #ocaml
xavierbot has joined #ocaml
smimou has quit [Remote closed the connection]
smimou has joined #ocaml
Sparkles has joined #ocaml
Sparkles has quit [Client Quit]
Sparkles has joined #ocaml
Sparkles has quit [Read error: 110 (Connection timed out)]
Mr_Awesome has quit ["time to impregnate a moth"]
smimou has quit ["bli"]
Mr_Awesome has joined #ocaml
bohanlon has quit [SendQ exceeded]
Mr_Awesome has quit ["time to impregnate a moth"]
screwt8 has quit [Remote closed the connection]
screwt8 has joined #ocaml
gour has joined #ocaml
gour has left #ocaml []
Sparkles has joined #ocaml
screwt8 has quit [Read error: 104 (Connection reset by peer)]
screwt8 has joined #ocaml
Cygal has joined #ocaml
visage has joined #ocaml
pango has quit [Remote closed the connection]
seafoodX has joined #ocaml
noteventime has joined #ocaml
visage has quit []
buluca has joined #ocaml
pango has joined #ocaml
seafoodX has quit []
screwt8 has quit [Remote closed the connection]
screwt8 has joined #ocaml
Cygal has quit ["ERC Version 5.1.4 (IRC client for Emacs)"]
Sparkles has quit []
another is now known as piggybox
ygrek_ has quit [Excess Flood]
loux has joined #ocaml
<loux> lol
loux has left #ocaml []
pango- has joined #ocaml
pango has quit [Remote closed the connection]
pango- is now known as pango
<rwmjones> the following is for cuervo, if he turns up (I've got to go now):
<rwmjones> if true then print_endline "hello";;
<xavierbot> hello
<xavierbot> - : unit = ()
<rwmjones> if false then print_endline "hello";;
<xavierbot> - : unit = ()
michel_ has quit [Read error: 113 (No route to host)]
michel_ has joined #ocaml
Smerdyakov has joined #ocaml
visage has joined #ocaml
smimou has joined #ocaml
Lena has joined #ocaml
psnively has joined #ocaml
smimram has joined #ocaml
smimou has quit [Read error: 110 (Connection timed out)]
<psnively> Hi folks! Has anyone here played with Oleg Kiselyov's delimited continuations?
ygrek_ has joined #ocaml
bytecoder has joined #ocaml
<bytecoder> Hello.
<bytecoder> Does OCaml have a 'reduce' function in its standard library anywhere?
<bytecoder> I feel dirty reimplementing it.
<bytecoder> foldr isn't what I want, btw.
<Smerdyakov> Can you give your definition of it here, so I can see what it is?
<bytecoder> It's the same as foldr without the base case.
<bytecoder> Instead of (f 1 (f 2 (f 3 0)))
<bytecoder> It's (f 1 (f 2 3))
<Smerdyakov> That seems like a bad function to use, as it goes wrong for empty lists.
<bytecoder> Because the operation doesn't make sense on empty lists.
<bytecoder> It comes in handy a lot.
<Lena> you don't have any neutral for the base case ?
<bytecoder> No.
<Smerdyakov> I don't think it's in the OCaml standard library.
<bytecoder> A good example would be finding the minimum value in a list.
<bytecoder> You could use some 'MAX' value for the base case.
<bytecoder> But that's fairly ugly.
<bytecoder> Finding the mimimum value in an empty list doesn't make sense, either.
<Lena> but the minimum of something empty is infinity
<bytecoder> Oh wait, in this case there is a base case.
<bytecoder> Lena, you can't find the mimimum element of a list if it has no elements.
<bytecoder> Lena, it's not "infinity."
<Lena> In maths
<bytecoder> This isn't math.
<psnively> Everything is math.
<psnively> Fnord.
<bytecoder> Anyway, I found a base case.
<bytecoder> Mostly I didn't want to have to include a serialization util file in the current module.
<bytecoder> Thanks :)
<psnively> Since folks are reading now :-) has anyone played with Oleg Kiselyov's delimited continuations? In particular, his incremental parser message to the mailing list?
<bytecoder> I'm still surprised that people don't notice how inelegant foldr is in a lot of cases.
<bytecoder> Even python has reduce ;)
<psnively> Not for long.
<psnively> (Well, depending upon when Python 3000 ships...)
<bytecoder> At least it had it to begin with :)
<bytecoder> I've grown away from python, anyway.
<bytecoder> Too verbose.
<psnively> Python's a tad weird for me too.
<bytecoder> I probably wouldn't mind it if python actually had a distinct 'function' construct.
<bytecoder> But it doesn't...
<bytecoder> Well, and pattern matching.
<bytecoder> But I digress...
<Lena> pattern matching rocks :D
<bytecoder> It's useful in some situations...
<bytecoder> By the way, psnively, are you the Paul Snively that frequents LtU?
<psnively> Yep.
* psnively ducks.
<bytecoder> Figured as much.
rwmjones_ has joined #ocaml
<psnively> I didn't do it. You can't prove a thing. ;-)
<bytecoder> I wonder if Jon Harrop ever goes in here...
<rwmjones_> bytecoder, I think you can write reduce easily enough
<bytecoder> I feel dirty even writing that name.
<bytecoder> rwmjones_, I did.
<rwmjones_> or else write it using List.fold_right in terms of Some/None (but very inefficient)
<bytecoder> That's an interesting solution, but I've already written it :)
rwmjones_ is now known as rwmjones_laptop
<bytecoder> I just didn't feel like factoring it out into its own file just so I can use it in another part of my project.
<bytecoder> Ooh, that's a nice descriptive error message...
<bytecoder> Oh great, now I'm trapped in IRC again.
<bytecoder> I knew I shouldn't have come in here.
<psnively> Anyone wanna try to tackle a continuation monad question?
<psnively> bytecoder: join the club. :-D
<rwmjones_laptop> go on ...
<Smerdyakov> I don't like functions that raise exceptions.
<psnively> Smerdyakov: Totally. ;-)
<Smerdyakov> Which is why I will tend to prefer folding to reducing.
<bytecoder> psnively, I only recently realized that continuations and monads were separate, so... no :)
<Smerdyakov> Natch, it's not a problem if you have a statically-enforced "non-empty list" type.
<bytecoder> Is it just me or does the relationship between continuations and monads seem...obvious?
<Smerdyakov> bytecoder, it's just you.
<rwmjones_laptop> it's just you
<psnively> bytecoder: You're a smarter man than I. I'm just trying to translate Oleg's incremental parser using his native delimited continuations to the monadic ones.
<psnively> And I'm getting the impression that, to do so, I'd need polymorphic recursion. Blech.
<bytecoder> Heh.
<bytecoder> I suppose that means I'm misunderstanding something.
<bytecoder> I can't stand reading academic papers or other technical documents, so I basically just "reinvent" things to understand how they work.
<psnively> It always scares me when Oleg says "in a straightforward way."
<bytecoder> Maybe I reinvented Monads the worng way...
<bytecoder> Heh, worng.
<psnively> bytecoder: With all due respect: probably. Category Theory doesn't tend to arise in most people via intuition. :-)
<bytecoder> Let's see, then.
<bytecoder> Isn't a monad just something that chains function calls with an extra 'world' argument?
<psnively> No.
<bytecoder> It appears I was right at being wrong.
<psnively> But don't feel bad; that's the intuition most people get from most naîve explanations of monads.
<bytecoder> Actually, that was secondary.
<psnively> OK.
<bytecoder> I initially figured monads were implemented as continuations...
<psnively> Sure, and if what you think monads are were all they were, that would be a reasonable implementation of them.
<bytecoder> Eh, I'll figure it out eventually.
<psnively> Fair enough... heaven knows I'm still working on int.
<psnively> It, even.
<bytecoder> I suppose I have to look deeper into monads than IO, though.
<bytecoder> ...I doubt I'll get around to doing it, though.
<bytecoder> I just noticed that I'm still in IRC.
<psnively> That's kind of where I am... trying to grok delimited continuations in terms of monads, since that's the only (relatively easy?) way to get them into native-code OCaml.
<bytecoder> What benefits to monads provide in OCaml?
<bytecoder> I suspect my misunderstanding is due to the limited samples that I've seen of them.
<bytecoder> *do
<Smerdyakov> Monads are an algebraic structure.
<Smerdyakov> They don't "provide" anything by themselves.
<bytecoder> So are my boxors.
<bytecoder> Or boxers.
<Smerdyakov> The value is in how many useful operations generalize over all monads.
<bytecoder> Damn lack-of-spellcheck.
<psnively> In this case, the benefit is to constrain the circumstances under which a ref is mutated, in the service of implementing delimited continuations via the mechanism described in "A Monadic Framework for Delimited Continuations."
<bytecoder> Oh, they're mainly for typechecking?
<Smerdyakov> A lot of folks, especially Haskell people, have an almost mystical regard for monads.
<bytecoder> I suppose I'll wind up reinventing them when I write my type checker, then...
<psnively> No; you can (and some folks do) use monads in Scheme.
<bytecoder> You've lost me.
<Smerdyakov> From my viewpoint, they're just an obvious-in-retrospect implementation of a blunt idea: when your programming language doesn't do what you want, embed another programming language inside it. (Certainly an oft-used idea in the Lisp world)
<psnively> A monad has a few basic operations. Those operations have a particular algebraic relationship to each other (the "monad laws").
<Smerdyakov> psnively, I don't think the monad laws are important, _especially_ for an initial understanding.
<psnively> Anything that fulfills those laws is, by definition, a monad.
<Smerdyakov> psnively, what matters is that you are embedding a language that does what you want inside a language that doesn't do what you want.
<psnively> Smerdyakov: Perhaps, but without them, intuition breaks down so rapidly as to be useless, at least in my experience so far.
<Smerdyakov> [This is most useful for thinking about the IO monad.]
<psnively> OK.
<Smerdyakov> The monad interface is just one possible constraint on the space of embedded languages.
<Smerdyakov> And I maintain that thinking about embedded languages first is key to understanding what this monad business is all about.
<Smerdyakov> It's not complicated at all. It's dead simple.
<Smerdyakov> No one will be confused about "what the IO monad is" if he starts from this point.
<psnively> For some values of "simple..." ;-)
<Smerdyakov> Anyone who doesn't think it's simple shouldn't be programming.
* rwmjones_laptop is a bit confused still as to why you would want or need monads in OCaml
<bytecoder> I wasn't under the assumption that they were "hard."
<Smerdyakov> rwmjones, you never need monads anywhere.
<bytecoder> The material on them is just poor.
<rwmjones_laptop> well, if I wanted to serialise IO in Haskell they seem to be useful
<rwmjones_laptop> but in OCaml ...?
<bytecoder> Heh, speaking of Haskell.
<psnively> rwmjones_laptop: I'm basically trying to noodle around with Oleg's generic zipper in OCaml. That implies having delimited continuations. That implies either sticking with his bytecode-only version, or using monads.
<Smerdyakov> rwmjones, no. What you find useful is embedding an imperative language in a functional language (Haskell). You can have embeddings that don't satisfy the monad ADT.
<bytecoder> Am I the only one that finds it ironic that Haskell has 'return' and OCaml doesn't?
<bytecoder> (Yes I realize that's related to monads.)
<bytecoder> its use of monads*
<psnively> rwmjones_laptop: Monads aren't just about I/O.
<Smerdyakov> rwmjones, and if what I'm saying goes over your head, then you should consider doing some reading before using "folk definitions" of these terms anymore. ;)
<psnively> Which, IMHO, is where most people get lost. They get using monads for I/O in a pure language like Hasell, and that's it.
<Smerdyakov> Right. We have two converging realizations.
<Smerdyakov> 1) You can embed an imperative language in a functional language.
<Smerdyakov> 2) You can generalize many embedded languages with an algebraic structure called a monad.
<Smerdyakov> 1+2) The embedded imperative language can be made to fit that structure.
<psnively> Right. My interest in monads arises from the realization that they can give me things I want, delimited continuations in this case, in a language that I want, OCaml.
<Smerdyakov> I would say that that is a bad and even misleading way to phrase it.
<Smerdyakov> Your interest arises from the realization that you can use an embedded language to add new language features.
<Smerdyakov> As a bonus, the embedding satisfies the monad ADT.
<rwmjones_laptop> hey hey, I'm just a practical programmer & mostly imperative thinker
<Smerdyakov> So you can use monad-generic code with it.
<rwmjones_laptop> does anyone have any examples of using monads for something other than I/O (esp ones in OCaml)
<rwmjones_laptop> ?
<bytecoder> Heh.
<bytecoder> Some None
<Smerdyakov> rwmjones, again, bad bad BAD way of phrasing that.
<psnively> Smerdyakov: Actually, the realization in this case really did proceed from the specific ("I want delimited continuations in native-code OCaml") to the specific ("Oleg has an implementation of delimited continuations in native-code OCaml, the price of which is writing code monadically.")
<Smerdyakov> rwmjones, ask instead: Does anyone have any examples of a useful structure in OCaml that turns out to be a monad?
<bytecoder> It's possible to nest variant types like that, correct?
<bytecoder> Some of Some of *blah* ?
<bytecoder> Err...
<bytecoder> lol
<rwmjones_laptop> you have to understand that I have only the basic understanding of monads, as used to resolve the problem that Haskell doesn't support I/O properly
<bytecoder> *blah* option option
<Smerdyakov> rwmjones, anything you find in the context of Haskell is likely to be relevant. The only popular monad implemented as an "abstract data type" in Haskell is IO.
<rwmjones_laptop> and in fact my understanding of monads is probably x 100,000 greater than other programmers
<Smerdyakov> rwmjones, so find a page about monads in Haskell and read the examples.
<bytecoder> Ok, have to go guys.
<bytecoder> Thanks.
bytecoder has quit ["Leaving"]
<rwmjones_laptop> yes, obviously I've done that, but I've never found anything compelling beyond implementing I/O .. so to me (and the vast majority of programmers) they'll see monads as a clumsy workaround for shortcomings in haskell
<psnively> rwmjones_laptop: You could just as easily argue that only Haskell and Clean support I/O properly.
<psnively> Oh, and DrScheme's REPL. :-)
<Smerdyakov> rwmjones, that depends on your point of view. Many people (including me) think it's best to keep your core programming language as simple as possible.
<Smerdyakov> rwmjones, embedded languages combining with compiler optimizer support provide a way to use other features "on demand" without penalizing the rest of the language.
<rwmjones_laptop> well possibly .. what I'm most interested in is writing software faster, safer and easier to maintain
<Smerdyakov> Yeah, then you want minimal languages, I claim.
<psnively> As, I think, are we all.
<rwmjones_laptop> (by "faster" I mean faster programming, not faster runtimes)
<psnively> Of course.
<rwmjones_laptop> so really I'd like to see a non I/O example ... can you point me to some webpages I can read?
<psnively> Which is why I encouraged Oleg to include his monadic delimited continuations in version 1.1 of his camlp4 extension that provides do-notation for OCaml. The whole point was to make the code more legible.
<Smerdyakov> Quick web search finds this: http://www.engr.mun.ca/~theo/Misc/haskell_and_monads.htm
<rwmjones_laptop> I think I may have read that one, but I'll certainly look at it again ... thanks
<psnively> rwmjones_laptop: My favorite example (and the one I'd like to ultimately rewrite in OCaml) is at http://okmij.org/ftp/Computation/Continuations.html#zipper-fs
<rwmjones_laptop> honestly though, I'm working "at the coalface" with unreformed C programmers
<rwmjones_laptop> they actually believe that C is the best language to do anything in
<Smerdyakov> What is "at the coalface"?
<psnively> rwmjones_laptop: Sorry to hear that.
* Smerdyakov roles his eyes.
<Smerdyakov> l
<Smerdyakov> I'm happy to inform you that there are plenty of companies who don't have that problem.
fmadero has joined #ocaml
<rwmjones_laptop> fmadero, welcome
<Smerdyakov> So suggesting that proposing solutions that don't assume that everyone needs to be convinced not to use C are "ivory tower" is unjustified.
<psnively> Yeah--the first thing that needs to happen is for people to recognize that theory and practice aren't actually distinct.
<Smerdyakov> In other words, you should probably find a better job.
<psnively> Every practice has a theory; theories evolve (at least in science) to explain and predict practice.
<rwmjones_laptop> well, that's a long battle. The easy wins are to start showing people that these languages are actually better than C, and a lot of that is that they do the practical stuff (like dynamic linking, etc)
<Smerdyakov> You are making the mistake of assuming that your local context summarizes the world.
<Smerdyakov> Almost everyone working professionally in programming laughs at the idea of using C today.
<psnively> rwmjones_laptop: Sure. So the work on Alice ML might be quite interesting to you.
<rwmjones_laptop> well, I hate to disagree, but a vast number of programmers write in C and the dynamic languages like Python which are hardly better
<Smerdyakov> Not so. Python is a huge step up.
<Smerdyakov> If you are to disagree, disagree with what I said, which is just about C.
<rwmjones_laptop> kind of, but actually the errors I've found in Python revolve around dynamic typing
<rwmjones_laptop> and wouldn't have happened in a language with static typin
<rwmjones_laptop> typing
<Smerdyakov> Not to mention that the most successful programmers mostly ignore C today.
<psnively> Unfortunately, most people I know who've graduated from C "graduated" to C++.
<Smerdyakov> So, if you're at a shop that uses C, you could probably improve your career by moving on.
<fmadero> C++ is a want to be OO language
<psnively> fmadero: On the contrary; C++ is a positively brilliant OO language.
<fmadero> claims to be OO but you still end up messing with the details of pointers.
<fmadero> no sir
* psnively believes that object-orientation belongs to the problem set, not the solution set.
<fmadero> OO is not about details
<rwmjones_laptop> I don't know if any of you use linux, but if you do then you're using a system written largely in C, and it's this that I'm trying to change for the better
<fmadero> if i want to do details i will do it assembly or c
<psnively> fmadero: On the contrary; OO is about virtually nothing else.
<Lena> I thought we were on a channel about a real language, not about C or C++
<Smerdyakov> There is no standard definition of "OO," so arguing about it is ridiculous.
<psnively> Lena: Heh.
<Lena> :)
<fmadero> indeed Smerdyakov i rest
<fmadero> sorry everyone
<psnively> Smerdyakov: Part of my point, actually.
<psnively> rwmjones_laptop: Quite. And what a tragedy that OS design is stuck firmly in the 1960s.
<Smerdyakov> rwmjones, most programming done today is at a high enough level that how your OS is implemented is hardly relevant.
<psnively> (For that matter, what a tragedy that we have something called an "OS.")
<rwmjones_laptop> you'd be surprised
<Smerdyakov> I write tons of "systems code" for UNIX, and I use almost entirely Standard ML.
<rwmjones_laptop> well that's good, but the people writing the actual code that goes into Linux distros are tending to write it in horrible languages like C, C++, Java, & python
<Smerdyakov> Those people make up a tiny portion of programming going on.
<rwmjones_laptop> that's what I'm trying to say, and the suggestions here aren't helpful
<Smerdyakov> And an astronomically tiny portion of programming-related economic activity.
<rwmjones_laptop> well if you want to look at the bigger picture, most programming is probably being done in basic or something
<Smerdyakov> Excel wins, no doubt.
<psnively> Sure, and Visual Basic is becoming one of the best languages in the world.
<rwmjones_laptop> probably .. anyway, none of this is helping getting functional languages mainstream
<rwmjones_laptop> it really is all about the stupid practical stuff
<Smerdyakov> Functional languages are already practical.
<Smerdyakov> You're living decades in the past if you don't think so.
<rwmjones_laptop> dynamic libs, wide array of libraries, integeration with existing languages, accessible tutorials
<psnively> On the contrary; my point was precisely that Visual Basic is rapidly becoming the most practical functional language in the world.
<Smerdyakov> We have "accessible tutorials."
<Smerdyakov> I don't care if people who aren't smart can't learn to use a language.
<rwmjones_laptop> well I do
<Smerdyakov> The smart people are an order of magnitude more productive and can replace the peons.
<Smerdyakov> Jane Street Capital is kicking ass using OCaml for 99% of new development.
<Smerdyakov> If they're somehow doing it when "OCaml is not practical," then that's really impressive.
<rwmjones_laptop> smart people have many problems, one of which is that they don't want to work on the boring grunt stuff
<psnively> Sometimes that's because the boring grunt stuff is a solved problem in other contexts. The biggest issue I see in software development in the literally incessant wheel-reinventing.
<Smerdyakov> rwmjones, you're speculating, while I've given a real-world example of a company thriving using OCaml as its development base.
<Smerdyakov> rwmjones, how do you mix "not practical" with "billions of dollars in revenue"?
<rwmjones_laptop> well Jane St may be an island of sanity in a sea of mediocrity (I know because IIRC we did some consultancy for JSC at my last job), but believe me it's extremely rare and most banks write crap in Excel or Java or whatever
<psnively> Sure. So what do you propose to do about it?
<rwmjones_laptop> the reason they do so is because functional languages aren't either known or practical for them
<rwmjones_laptop> it's a bit of both
<Smerdyakov> rwmjones, it's mostly the former.
<Smerdyakov> rwmjones, if you agree that Jane Street is using OCaml successfully, then how can you claim that the reasons stopping other companies aren't just social?
<Smerdyakov> I agree that most ventures have trouble attracting smart people.
<rwmjones_laptop> so to use them, they'd need to be able to either hire programmers in those languages, or send their programmers on training courses
<Smerdyakov> At the same time, I have no interest in those ventures.
<rwmjones_laptop> they can do neither
<Smerdyakov> I hope they all go bankrupt ASAP.
<rwmjones_laptop> they'd need to be able to buy RHEL with OCaml packages
<rwmjones_laptop> they can't do that (although I'm changing that)
<Smerdyakov> RedHat doesn't have OCaml packages?
<rwmjones_laptop> they'd need to know that they can reuse all the thousands of lines of code in other languages, and combine together
<rwmjones_laptop> (I'm working on that, again slowly)
<Smerdyakov> They should just use Debian!
<rwmjones_laptop> Red Hat will have quality OCaml packages in a few months
<rwmjones_laptop> what if they want to support their servers for 7 years .. good luck doing that with Debian
<psnively> You can't install OCaml on Red Hat?
<Smerdyakov> I can sympathize with companies with huge legacy code bases, to some extent.
<rwmjones_laptop> you can, but it's not supported, not part of the install, and you can't just pay someone to take the support effort on board
<Smerdyakov> But, moreso, I cackle with glee at the competitive advantage it provides to companies starting over, using rational development tools.
<rwmjones_laptop> all this should change over time
Rovlad has joined #ocaml
<Smerdyakov> I want to compete with the laggards, not help them adopt "my" tools so I can have a warm feeling inside. I'd rather have their market shares, thank you very much.
<psnively> rwmjones_laptop: I commend you for your patience, that's for sure.
<rwmjones_laptop> well not my patience - I'm trying to make it all happen
<rwmjones_laptop> just there is only one of me
<Smerdyakov> This is one of those situations where people have different fundamental goals and often don't realize it.
<Smerdyakov> WHY should I care what "most programmers" are using?
<Smerdyakov> WHY isn't it in my interests to support languages usable only by an elite, if they give that elite an obscene commercial advantage?
<rwmjones_laptop> because "most programmers" outnumber you 100,000,000 : 1
<rwmjones_laptop> so by making them productive, you are increasing the good for everyone
<rwmjones_laptop> by a massive leverage
<Smerdyakov> It's not a question of how much they outnumber _me_.
<Smerdyakov> It's a question of how much they outnumber the people able and eager to use superior tools.
<Smerdyakov> And of how much more productive that elite is than the rank-and-file.
<psnively> Making them productive sounds to me like pointing them to OCaml, the tutorials, the libraries, the FFI...
<psnively> It's far from obvious (to me) what, if anything, is missing.
<Smerdyakov> And, let's face it, most people have significant concerns about their personal success, not just overall society-scale productivity.
<rwmjones_laptop> and that's why I wrote the beginnings of ocaml-tutorial.org, at a time when there really were few good tutorials around
<rwmjones_laptop> also perl4caml so we could bring in all those excellent libs
<psnively> rwmjones_laptop: Let me assure you that it's greatly appreciated.
<rwmjones_laptop> Smerdykov you see, I'd like a iPhone [substitute techno wizardly thing], but I don't personally have time to invent one myself. We all benefit if the whole of society is more productive.
<psnively> So apart from not shipping with the Red Hat distro of Linux, what else needs doing?
<psnively> Sorry, needs resolving?
<rwmjones_laptop> oh, a million things. Personally I would like to be able to write dynamic libs (linkable from C programs) in OCaml.
Rovlad has quit []
<rwmjones_laptop> so I'm working on something called camlwrap
<rwmjones_laptop> which lets us do that
<rwmjones_laptop> (it's not released yet)
<rwmjones_laptop> it generates the .h files from the .mli files automagically
<rwmjones_laptop> in fact, it could generate bindings in lots of languages
fmadero has quit [Read error: 110 (Connection timed out)]
<rwmjones_laptop> if you want a laugh, download the source at libvirt.org and see how much better it would be if written in a proper language
<rwmjones_laptop> s/better/better, shorter and safer/
<psnively> Is it really worth trying to make OCaml callable from C? Or might we be better off calling an OCaml process from a C process, e.g. using XML-RPC, SOAP, REST...?
<rwmjones_laptop> this makes some sense, but C programmers would reject it as being "inefficient" .. and also because C makes it impossible to call XML-RPC programs like that
<rwmjones_laptop> s/impossible/intractable/
<rwmjones_laptop> the trick is to work from the inside to overthrow the system
<rwmjones_laptop> it worked for overthrowing communism ...
<rwmjones_laptop> :-)
buluca has quit [No route to host]
<psnively> See, this is where I can't sign up: I'm not willing to let the C world define the rules of the game.
<psnively> The insistence that everything work with the C runtime model, the C memory model, the C community's definition of "efficiency..." well... loses, and loses big.
<psnively> I mean, as if life weren't short enough as it is.
<rwmjones_laptop> sure, but I really don't think you can stop the world and ask them to get off. You can start with a library that they can call which (and here's the trick) they don't even know it's written in this wierd language. They think it's just an ordinary C lib.
<rwmjones_laptop> to them, it looks, smells, acts, even builds, like an ordinary C library
<rwmjones_laptop> but then you can say -- look, it's (literally) 10x shorter than the C equivalent
<mbishop> sounds like FFTW
<rwmjones_laptop> just for fun I recoded parts of libvirt in OCaml, and they were about 15% of the size
* rwmjones_laptop looks ...
<rwmjones_laptop> FFTW isn't actually an OCaml lib though, it is (AIUI) a C lib written by an OCaml prog
<psnively> Eh. Sounds like hiding the hair to me. Wait until they find out you foisted a garbage collector on them. ;-)
<rwmjones_laptop> right, but the good thing about the OCaml GC is it works using ordinary malloc blocks (a big advantage)
<psnively> And it'd be even shorter if written in APL. ;-)
<rwmjones_laptop> my keyboard doesn't support APL :-(
<psnively> Very much part of my point. ;-)
visage has quit []
<psnively> Hmmm. I wonder if the natdynlink branch will help you at all.
<rwmjones_laptop> I think fixing -fPIC will help me most ... the x86-64 version in ocamlopt is somewhat borked, but I've not tried it recently
<psnively> Ah.
fmadero has joined #ocaml
<rwmjones_laptop> fmadero, you had a question about 'if .. then .. else'?
<fmadero> rwmjones_laptop: correct
<rwmjones_laptop> if true then print_endline "hello, it works";;
<xavierbot> hello, it works
<xavierbot> - : unit = ()
<rwmjones_laptop> if false then print_endline "this shouldn't be printed";;
<xavierbot> - : unit = ()
<psnively> Nice work on xavierbot, BTW. :-D
<rwmjones_laptop> I think that you may have a problem with ; or in ...
<rwmjones_laptop> please look for exploits for me
<fmadero> rwmjones: what if i want to return an int?
<fmadero> if 1 > 0 then 0;;
<xavierbot> Characters 1-16:
<xavierbot> if 1 > 0 then 0;;
<xavierbot> ^^^^^^^^^^^^^^^
<xavierbot> This expression has type unit but is here used with type int
<rwmjones_laptop> fmadero, something like:
<rwmjones_laptop> let i = if true then 1 else 0 ;;
<xavierbot> val i : int = 1
<rwmjones_laptop> i ;;
<xavierbot> - : int = 1
<rwmjones_laptop> fmadero, oh I see
<rwmjones_laptop> the else clause, if missing, is assumed to return unit ()
<rwmjones_laptop> that is, () is "unit"
<fmadero> rwmjones_laptop: yes the else must be used.
<rwmjones_laptop> so if you want to return something other than unit, then you can't omit else
<rwmjones_laptop> did I miss that in your email?
<fmadero> i am not famaliar with the "
<fmadero> unit type
<rwmjones_laptop> () ;;
<xavierbot> - : unit = ()
<rwmjones_laptop> unit is a type
<rwmjones_laptop> it has exactly one value, which is written ()
<rwmjones_laptop> compare with int which is a type
<rwmjones_laptop> with values 0, 1, 2, -1, -2, etc.
<fmadero> hmm, the unit type is new to me.
<rwmjones_laptop> let f () = () ;;
<xavierbot> val f : unit -> unit = <fun>
<bluestorm> hm rm
<psnively> You can take "unit" to mean "no value," to a first approximation.
<bluestorm> rwmjones_laptop:
<bluestorm> (* Create an object, so we get the CamlinternalOO module. *)
<bluestorm> (* XXX Are any of the methods unsafe? *)
<bluestorm> let _ = object end
<fmadero> psnively: so like null?
<bluestorm> what is that piece of code doing ?
<psnively> Yes. Again, to a first approximation.
<bluestorm> (you are doing similar things with let _ = List.length and others)
<rwmjones_laptop> it just creates an object, the object isnt important, but it causes the CamlinternalOO module be read off disk and importedbefore we chroot
<bluestorm> hm
<rwmjones_laptop> specifically it needs to read camlinternalOO.cmi file off disk
<rwmjones_laptop> but bluestore I'm sure you're looking in the right place ...
* rwmjones_laptop might need to kill xavierbot before bed tonight ....
<bluestorm> i never noticed that the runtime imported standard libs on demand
<rwmjones_laptop> strace is your friend there
<bluestorm> (never looked for that actuallY)
<bluestorm> :p
ygrek__ has joined #ocaml
<rwmjones_laptop> it doesn't import them as they are already linked in, just the interface file needs to be loaded before they can be used
<rwmjones_laptop> for example, xavierbot contains all the code in Obj, but you can use Obj
<rwmjones_laptop> hopefully
<rwmjones_laptop> Obj.magic;;
<xavierbot> Characters 1-10:
<xavierbot> Obj.magic;;
<xavierbot> ^^^^^^^^^
<xavierbot> Unbound value Obj.magic
<rwmjones_laptop> s/can/can't/
<psnively> I gave up and posted my question to the list. We'll see if Oleg responds. :-)
<fmadero> rwmjones_laptop: so must an expression always return something?
<rwmjones_laptop> fmadero, yes
<psnively> Yes.
<rwmjones_laptop> but that "something" can be unit :-)
<rwmjones_laptop> and very often is :-) :-)
<fmadero> ok now i understand the message
<psnively> Same as "void," again to a first approximation.
<rwmjones_laptop> fmadero, what was the message again?
<fmadero> This expression has type int but is here used with type unit
<rwmjones_laptop> yup
<psnively> if 1 > 0 then 0 else 5;;
<xavierbot> - : int = 0
<psnively> if 1 > 0 then 0 else ();;
<xavierbot> Characters 22-24:
<xavierbot> if 1 > 0 then 0 else ();;
<xavierbot> ^^
<xavierbot> This expression has type unit but is here used with type int
<psnively> if 1 > 0 then 5 else 0;;
<xavierbot> - : int = 5
<psnively> if 0 > 1 then 5 else 0;;
<xavierbot> - : int = 0
<psnively> if 0 > 1 then 5 else failwith "You fool!";;
<xavierbot> Exception: Failure "You fool!".
<fmadero> so is print_endline "Hello Mom" is of type unit?
<bluestorm> yes
<psnively> print_endline;;
<xavierbot> - : string -> unit = <fun>
<bluestorm> print_endline;;
<xavierbot> - : string -> unit = <fun>
<bluestorm> :p
<rwmjones_laptop> print_endline "Hello Mom";;
<xavierbot> Hello Mom
<xavierbot> - : unit = ()
<rwmjones_laptop> seems so
<fmadero> ok i got it thanks everyone
<rwmjones_laptop> np
<psnively> int_of_string "Hello Mom";;
<xavierbot> Exception: Failure "int_of_string".
<psnively> int_of_string "12345";;
<xavierbot> - : int = 12345
qwwqe has joined #ocaml
ygrek_ has quit [Remote closed the connection]
rwmjones_laptop is now known as rwmjones_gone
rwmjones_gone has quit ["Leaving"]
ygrek__ has quit []
psnively has quit []
mbishop has quit [Remote closed the connection]
martin_ has joined #ocaml
martin_ is now known as mbishop
love-pingoo has joined #ocaml
Mr_Awesome has joined #ocaml
xavierbot has quit [Remote closed the connection]
Lena has left #ocaml []
<twobitsprite> Mr_Awesome: how would I do that?
<Mr_Awesome> good question
<twobitsprite> Mr_Awesome: (sorry, just now saw your response)
<twobitsprite> Mr_Awesome: ... concerning repetition in ocamlyacc...
<Mr_Awesome> yeah i remember now
<Mr_Awesome> hold on a second, ill get you a good resource
<twobitsprite> cool
michel_ is now known as marc
<Mr_Awesome> that shows you how to make a calculator using lex and yacc. shouldnt require too much translation to get it working with their ocaml counterparts
<Mr_Awesome> essentially, the answer to you question would be to do this - expr: ID | INTEGER | list | ...etc; list: expr | list expr;
<Mr_Awesome> the nonterminal list will give you one or more consecutive expr's, simulating the effect of + in regexps
<Mr_Awesome> of course, you may have other tokens delimiting your list
<twobitsprite> Mr_Awesome: cool, thanks... now, I was thinking I should do "expr list" instead of "list expr" because I'm building an actual list, so "expr :: list" would make more sense...
<twobitsprite> Mr_Awesome: or, am I thinking backwards?
* twobitsprite is coding stoned :P
<Mr_Awesome> it doesnt matter either way. using left recursion (ie list expr, it recurses on the left side) is more efficient
<Mr_Awesome> in my own parser, i built the list "backwards" like this and then just reversed the list when it was complete
<twobitsprite> Mr_Awesome: but, wouldn't that cons the 'list' onto the 'expr', thus be an improper list?"
<Mr_Awesome> the parser itself doesnt do any consing, youre merely telling it how to build large sequences from smaller ones
<Mr_Awesome> the end result of list expr and expr list wont be any different, its just that the one using left recursion is faster
<Mr_Awesome> the link i gave you may offer a better explanation
<Mr_Awesome> if expr list makes more sense to you, then by all means do it that way :)
<twobitsprite> Mr_Awesome: yeah, its not like the compiler itself is going to need to be blindingly fast
<Mr_Awesome> indeed
<twobitsprite> so "expr list { $1 :: $2 }" should be fine?
<Mr_Awesome> yep
<Mr_Awesome> (if you wanted to do it the other way, it would be "list expr { $2 :: $1 }" and then youd reverse the list when it was complete)
<twobitsprite> Mr_Awesome: cool, thanks for your help
<Mr_Awesome> np
buluca has joined #ocaml
love-pingoo has quit ["Connection reset by pear"]
scode has quit [Remote closed the connection]
scode has joined #ocaml
qwwqe has quit ["Leaving"]
noteventime has quit ["Leaving"]
smimram has quit ["bli"]