<emu>
are there any docs on environments and working habits of ocaml programmers?
<Riastradh>
Eugh. On that page about numerics in OCaml, they suggest using for and while loops, because they're compiled to be faster.
<Smerdyakov>
Haha. You sure won't ever see anyone saying that about MLton.
<emu>
no loop-invariant motion?
<Riastradh>
emu, nope; nor lambda-lifting; all closures are heap-allocated...
* Riastradh
yucks.
<emu>
why...!
<Riastradh>
It's horrible! Is MLton ported to PPC?
<emu>
there must be some way to work with large programs in ocaml interactively
<emu>
how is it done?
<Nutssh>
I'm a bit surprised about the claims that ocamlopt doesn't do any invariant code motion.
mimosa has quit ["J'ai fini"]
blueshoe has joined #ocaml
mattam_ is now known as mattam
cjohnson has quit ["Drawn beyond the lines of reason"]
housetier has quit ["#breaks @ irc.highteq.de"]
Nutssh has quit [Read error: 110 (Connection timed out)]
rox has joined #ocaml
Kinners has joined #ocaml
pattern has joined #ocaml
Kinners has left #ocaml []
Nutssh has joined #ocaml
Nutssh has quit [Client Quit]
cleverdra has joined #ocaml
pattern has quit ["Terminated with extreme prejudice - dircproxy 1.0.5"]
wazze has quit ["Learning about how the end letters on French words are just becoming more and more silent, I conclude that one day the French]
pattern has joined #ocaml
blueshoe has quit [Read error: 104 (Connection reset by peer)]
pattern has left #ocaml []
pattern has joined #ocaml
housetier has joined #ocaml
whiskas has joined #ocaml
<whiskas>
Morning.
pattern has quit []
pattern has joined #ocaml
<Maddas>
What is lamba-lifting?
whiskas has quit [Remote closed the connection]
pattern has quit [Client Quit]
<cleverdra>
citeseer makes a paper available for download at citeseer.nj.nec.com/johnsson85lambda.html -- and one ML-related at citeseer.nj.nec.com/thiemann99mlstyle.html
<cleverdra>
and you have foldoc, too: wombat.doc.ic.ac.uk/foldoc/foldoc.cgi?lambda+lifting
<Maddas>
ok, thanks :)
<Maddas>
hm, I should usue foldoc more often, seems useful.
<Nutssh>
Oh wait. Just read that more closely.. Year&half old. *AARRGGGHH* That sucks.
<Maddas>
oh, yes
<Nutssh>
I always write code assuming the compiler is at least smart enough to do loop-invariant code motion!
<mellum>
well, that's not a completely trivial task
<Maddas>
Try it!
<Maddas>
Try taking it out in a place where it should be significant and benchmark :)
<Nutssh>
I did, and that explains why one particulalr program had 1/10 the performance I expected. (Not a big deal. premature optimization is the root of all evil and I'll get back to it later)
<Maddas>
I see. :-(
<Nutssh>
Oh well. At least I have confirmation, now. Oh well. (And its not much of a loss. The code I wrote is clear, if sluggish. Rewriting it would make less clear what is going on, if much faster.)
housetier has quit ["#breaks @ irc.highteq.de"]
<Nutssh>
(At a cost of eliminating 3 levels of abstraction, but probably worth it, eventually)
<Maddas>
heh
<Nutssh>
Thats actually a benefit. I found a *much* better incremental hash function at that lowest level. With the abstraction, shoehorning it in is much easier. :)
<Nutssh>
What kind of ocaml code have you written?
<mellum>
Nutssh: what are you working on?
<Nutssh>
That program was a datamining program. It can search two corpuses for substrings that occur frequently in one, but infrequently in the other. One of the core functions in it is an incremental hash function with some nice properties:
whiskas has joined #ocaml
<Nutssh>
hash(substring(s,i,j)) = f( hash(substring(s,i-1,j-1)) , s.(i-1), s.(j), j-i) with f easy to compute.
blueshoe has joined #ocaml
Tachyon76 has quit ["Leaving"]
<blueshoe>
anyone know when the next icfp contest is going to be?
<whiskas>
Hehe, you want to go?
<blueshoe>
you don't have to physically present, do you?
<whiskas>
I really don't know.
<blueshoe>
i'm pretty sure you can submit your entry online
<Maddas>
yeah, I think so
<Nutssh>
Yeah, AFAIK, its all electronic.
<blueshoe>
irght
<blueshoe>
ocaml had better win this time! :)
<Maddas>
:-)
<blueshoe>
gotta protect the family name
<Maddas>
heh
<Nutssh>
Its sorta surprising you don't see ocaml crop up more elsewhere, than you do.
<Nutssh>
BRB.
Nutssh has quit ["Client exiting"]
<blueshoe>
not enough marketing force behind it, maybe
Nutssh has joined #ocaml
<blueshoe>
functional programming may yet have its day, though
<blueshoe>
i've been hearing more and more dissatisfaction with java
<blueshoe>
from people who were singing praises to it during the dotcom era
<Nutssh>
I think so. Hell, garbage collection was the 'next big thing' only 10 years ago!, and it was 20 years old even then.
<Nutssh>
Err, 'the big thing', not 'the next big thing'.
<mellum>
More like 30 years old...
<whiskas>
mellum: Hey :-)
<blueshoe>
and i've also heard grumbling about OO not living up to its hype
<blueshoe>
so some people are starting to look for alternatives
<Nutssh>
OO is good, but its not everything.
tomasso has quit [Read error: 54 (Connection reset by peer)]
<blueshoe>
one of those alternatives is c#, but i really haven't heard that many people get particularly excited about it, since it's so similar to java
<Nutssh>
(and nothing lives up to the hype :)
<Maddas>
Nutssh: that's the good part of not being hyped.
<blueshoe>
other relatively popular alternatives are python and ruby.. but those are not an option for many projects due to their horrible performance, as performance still matters (and will probably start to matter more and more as moore's law starts to wind down in the next decade)
<blueshoe>
most everybody now hates perl
<blueshoe>
i don't see people using c any more than it is already
<Nutssh>
I've been meaning to learn python, but perl is too convenient, if horribly grotty. (Or, Ruby)
_JusSx_ has joined #ocaml
<Nutssh>
I think C's usage will continue to stay the same or even increase, even as its share of programming declines.
<blueshoe>
haskell's monads scare a lot of people away
<Maddas>
Nutssh: Same here, except that I'd go for Ruby
<Maddas>
blueshoe: I'm learning it now :-()
<Maddas>
s/(//
<whiskas>
Maddas: Agreed.
<blueshoe>
i actually like perl (at least most of perl 4)
<Maddas>
Perl 4? Eek!
<Nutssh>
Also, if people liked 'nice programming languages', can SOMEONE explain visual basic?
<blueshoe>
and perl has a lot of libraries, so it'll continue to be used... but most people use it grudgingly, i think
<Maddas>
I'm really waiting for Perl 6, that sounds like it'll get rid of quite a bit of cruft and bring cool things
<mellum>
Nutssh: Microsoft promotes it, so it must be good :)
<Nutssh>
LOL.
<Maddas>
mellum: Exactly :)
<blueshoe>
yeah, perl 4, before it had OO features
<Nutssh>
Yeah, but how many implementations of 'X' does a langauge need?
<Maddas>
blueshoe: Yeah, most people just use it to get simple things done quickly, I think.
<Nutssh>
perl oo frightens me.
<Maddas>
Nutssh: What do you mean?
<Nutssh>
To which?
<Maddas>
implementations of 'X'
<blueshoe>
although i hear perl's OO features were kind of slapped on the language rather unthoughtfully, though that may be just more rhetoric
<Maddas>
blueshoe: Some people like it a lot, some don't. It's really made up of very primitive parts and quite effective
<Maddas>
it always reminds me of the ak-47 =)
<Nutssh>
They have a lot of incomplete implementations of things. I don't care if a language has 20 half-implemented MIME parsers. I want one completed one.
<Maddas>
Nutssh: What, VB?
<Nutssh>
Perl.
<Maddas>
Ok
<Maddas>
Tell the people who write the modules :-)
<blueshoe>
the last icfp contest had as many people using ocaml as c++, iirc
<Nutssh>
Then there's languages where you have to implement everything. Ocaml seems to be beyond that hump a bit.
<Maddas>
Nutssh: I really miss a centralized place for O'Caml libraries
<blueshoe>
the humps are still pretty thin, i think
<Maddas>
I feel a bit like hunting when looking for modules
<Maddas>
I am eager to learn enough to write a parser using monadic parser combinations in Haskell, sounds very interesting :)
<Nutssh>
This is the icfp crowd, you *expect* functional languages doing that.
<Maddas>
What do you mean with 'ocaml as c++'?
<Nutssh>
Yeah. and I want functionality. I want ocaml to come with 100mb of 'bloated libraries' with unnecessary functionality.
<blueshoe>
the icfp contest attract a lot of attention outside of the functional crowd, though
<blueshoe>
maddas, i mean there were as many teams using ocaml as there were teams using c++
<Maddas>
Oh
<Maddas>
Yes, but C++ seemed to be the winner of last time :)
<Nutssh>
I've wanted to have the existing ocaml libraries, but with one or two extra functions a million times.
<blueshoe>
not ocaml "like" c++ ;)
<Maddas>
Nutssh: Are you being sarcastic?
<blueshoe>
yeah, c++ was the winner, but i don't think it was fair
<Maddas>
blueshoe: how was it 'not fair'?
<Nutssh>
No. If I have String.iter and String.map and String.map2 implemented, then I don't have to reimplement them.
<blueshoe>
it was an optimization problem, and they allowed contestants to use their own machine... and the winner had 16 dual athlon 1800 machines
<Maddas>
Nutssh: I don't understand what you're trying to mock
<Maddas>
oh, you are not being sarcastic :)
<blueshoe>
if they wanted to make the contest fair they would have ran each of the entries on the same machine
<Nutssh>
I'm upset that ocaml doesn't come with much more featureful standard libraries.
<Maddas>
Nutssh: String.iter exists
<Maddas>
Nutssh: String.map exists, you just need to declare it external yourself
<Maddas>
er, no, you need to export it in the mli
<Nutssh>
Whoops, I needed String.iteri. :)
<Maddas>
I wonder why they didn't. I just added the line to my string.mli yesterday, although that surely isn't a good way to do it
<Maddas>
Nutssh: I understand.
<Maddas>
Although that should be quite trivial to implement, I have had similar problems already
<Maddas>
more like annoyances than problems :)
<Nutssh>
I mentioned this somewhere else and they protested against 'bloated libraries'.
<Maddas>
Does having 'bloated libraries' actually do anything other than using disk space?
<Nutssh>
Yeah, death of a hundred papercuts. :( String should export every function that Array exports, and both should export every function that List exports that is reasonably defined on arrays.
<Maddas>
Does run-time execution take any impact at all?
<Maddas>
Nutssh: Yeah, strings not being an array is a pity.
<Maddas>
Or a list, whichever
<Maddas>
On the other hand, it's trivial to write an explode function :)
housetier has joined #ocaml
<Nutssh>
Yes. And even if it doesn't, people who care about space can enhance the compiler to garbage collect out unused functions.
<Maddas>
Nutssh: that sounds like a rather hard thing to do though
<Nutssh>
Yeah. So? What about points, vectors, and a geometry library? Trivial too, but it adds up.
<Maddas>
But I would think that the compiler can determine which functions are certainly not used, since you don't have eval
<Maddas>
Nutssh: Yeah, I'm not arguing against you.
<Nutssh>
Maddas: ?? Why would it be hard?
<Maddas>
I don't know, anything involving writing a garbage collector sounds hard to me =)
<Maddas>
(or modifying one)
<Nutssh>
Exactly. I think half of the reason java is used is because it has so many libraries.
<blueshoe>
that definitely helps
<blueshoe>
same with perl
<Maddas>
Perl without libraries would be nowhere as useful for the quick things you need done either
<Maddas>
Yeah
<blueshoe>
and c
<blueshoe>
that is, all the libs in c help its popularity
* Maddas
is happy that he was never forced to write anything with a GUI yet
<Maddas>
blueshoe: Yes
<blueshoe>
people would obviously still use c even if it didn't have all those libs
<Nutssh>
Oh, I seldom use perl libaries, but use it a fair amount.
<Maddas>
Even though I still see C as a system programming language
<Maddas>
The O'Caml FFI is very easy, isn't it?
<blueshoe>
i plan to use ocaml at least as much as i do perl, for small scripts
<Maddas>
At least for doing simple things.
ita|zzz is now known as ita
<whiskas>
FFI?
<Maddas>
Foreign-Function Interface
<blueshoe>
since ocaml has a regex library i really don't see what advantage perl would provide for small scripts
<Nutssh>
OCaml too has a reasonable set of libraries, but you have to hunt&peck them. It'd be nice if they were in some nice overarching package/naming system.
<Maddas>
To use C from O'Caml and the other way round
<ita>
the right tool for the right job, guys :)
<Maddas>
blueshoe: A lot of convenience
<whiskas>
Aha.
<Maddas>
Nutssh: Exactly, that's what I meant with hunting too
<Nutssh>
Actually, I'm implementing a regexp library in ocaml, my main side project.
<blueshoe>
that foreign function interface for ocaml -> c looks really scary
<blueshoe>
at least to my beginner eye
<Maddas>
blueshoe: Mapping one C function to one O'Caml function was trivial, even though I don't know C well at all
<blueshoe>
nutssh, have you read cosineau and mauny's functional approach to programming?
<Nutssh>
From what I've read, (not used it), ocaml's FFI looks pretty nice, especially the callout ability from c back into ocaml.
<Nutssh>
blueshoe: No.
<blueshoe>
maddas, well, it looked scary to me.. i might feel differently once i know ocaml better
<Maddas>
oh, the o'caml part was even more trivial ;)
<Maddas>
blueshoe: Perl one-liners are the typical example for the shortcuts being handy
<blueshoe>
nutssh, in that book one of their major projects is to implement a regex library in caml light
<Maddas>
(and making things unreadable)
<blueshoe>
maddas, i guess i don't write that many perl one liners
<blueshoe>
a typical perl script for me is about a page or two long
<blueshoe>
sometimes more
<Maddas>
Oh, then O'Caml certainly catches up, I'd say
<blueshoe>
yeah
<blueshoe>
especially if there's any chance it'll grow
<Nutssh>
Oh, I know I could do a backtracking one with continuations and combinators (I came from the CMU bastion of functional programming). But I'm doing an automata implementation.
<Maddas>
I just find Perl the most convenient glue I have around, and I use O'Caml for more isolated things
<Nutssh>
Perl has some nice uses, no questions asked.
* Maddas
goes on reading about Haskell in the background
<blueshoe>
well, i need to learn ocaml better before i can really weigh in on this issue with anything to back up my oppinions
<Maddas>
blueshoe: Especially for large things, the static typing starts to pay out, I find
<Maddas>
although I never wrote anything really large, of course :)
<blueshoe>
back in the early 90's i wrote a 30k line perl app
<Maddas>
heh
<blueshoe>
it was an early search engine
<Nutssh>
Static typing can be a godsend. :) I was taking some trie code that used arrays. Swapping it for hashtables was changing the type, then fixing all of the type errors.
<Nutssh>
blueshoe: Uummm. Ouch?
A has joined #ocaml
<Maddas>
Actually, there is a guy I know who implemented some typesafety for perl
<blueshoe>
used to search through restaurant menus... a dotcom idea three or four years ahead of its time
<Maddas>
Although I must say that it does not really fit in :)
<blueshoe>
nutssh, well, perl was actually fine for the task... it didn't need to be high performance
<Maddas>
Yeah, things like retreiving information from webpages is one example where it shines
<Maddas>
(thanks to the modules)
<Nutssh>
I'm not disputing that.. Its the 30kline perl that frightens me. Heh. :)
<blueshoe>
i'm not sure if it was the best choice for maintainability, though... but i didn't know about ocaml then ;)
<Maddas>
Nutssh: Especially since that was probably an older, even messier perl :)
<Nutssh>
I've had good luck with using flex for some of that stuff, replacing a fair amount of perl with it.
<Maddas>
flex?
<Nutssh>
flex is a lexer-generator.
<Maddas>
Oh
<blueshoe>
maddas, yes, i've seen a static typing module for perl... it's kind of cool, though only basic types are supported
<Maddas>
blueshoe: yeah
<Maddas>
Nutssh: The part that I find that the module shines is in retrieving the webpages
<Nutssh>
If you want to grok stuff out of messages, it can be extroadinarily convenient. I'm working on bringing that technology to some radical new uses.
<blueshoe>
maddas, have you used curl?
<Maddas>
blueshoe: A little, yes
<Maddas>
(the program, not the library)
<Nutssh>
Ah. Yeah. Especially with semi-meaningful parsing of the html. it would.
<blueshoe>
how do you think curl compares to perl for web page munging?
<Maddas>
Nutssh: sounds cool!
<Maddas>
blueshoe: I never used it much, and I only used it as a replacement for wget when I did
<Maddas>
I doubt it would have filled my needs
<Maddas>
at least not easily :-)
<blueshoe>
i only looked at it briefly.. never used it
<blueshoe>
but it's popular
<Maddas>
Yup
<Maddas>
I was always happy with LWP, so far
<blueshoe>
lwp?
<Maddas>
A collection of Perl modules for www stuff
<blueshoe>
ahh
<Maddas>
Perl 6 junctions look cool
<Maddas>
(among a lot of other things)
<blueshoe>
what are those?
<Maddas>
hm, let me see if I can find the document
<Maddas>
I wonder if are similar things in other languages
<Nutssh>
Set doesn't have any of these functions already written like this. but at least the first-half of that webpage is syntatic sugar on sets.
<Maddas>
Nutssh: Yes
<blueshoe>
the bastard wouldn't accept an ocaml solution, however
<Maddas>
blueshoe: haha
<Maddas>
Nutssh: I just find it very convenient and think that it allows for some cool things
<Nutssh>
Sure, its neat syntatic sugar on Sets.
<Maddas>
Hm
<A>
blueshoe: why wouldn't he?
<mattam>
because the example requires a polymorphic += operator
<Maddas>
yeah
<mattam>
(i guess)
<Maddas>
A: how would you write it? :)
<Maddas>
(this is why we need typeclasses!)
<mattam>
i can write it with a module though
<Nutssh>
I have *got* to learn haskell's type system.
<A>
Maddas: sorry, i'm new here... so you claim it can't be done in ocaml?
<Maddas>
A: No, I'm just wondering
<Maddas>
mattam: How would you do it?
<A>
It's just that I read the page blueshoe mentioned, and saw it didn't have an ocaml solution
<blueshoe>
i've written graham's accumulator
<blueshoe>
with help from this channel
<A>
and you sent it to Graham?
<blueshoe>
but it used a constructor float_ing = Float of float | Int of int
<blueshoe>
yeah
<blueshoe>
he never replied
<blueshoe>
/ing/int
<Maddas>
blueshoe: That's not generic enough, I guess
<blueshoe>
i guess not
<blueshoe>
but it's a pretty nitpicky distinction, imo
<Maddas>
blueshoe: And you need to convert your number to that type
<blueshoe>
since the functionality is identical
<Maddas>
How do convert the number to the type without knowing it already?
<blueshoe>
it will take either a float or an int, they just have to be specified in the right format
<Maddas>
blueshoe: Which violates the specification of the question
<blueshoe>
yes, it does
<Maddas>
That's why it wouldn't get listed
<blueshoe>
but if you know what values you're dealing with (which you have to to successfully perform operations on them, usually) then i don't see the distinction as being very meaningful
tomasso has joined #ocaml
<mattam>
module type PlusEq = sig
<mattam>
type t
<mattam>
val (+=) : t -> t -> t
<mattam>
end
<mattam>
module Operators(Peq : PlusEq) = struct
<Maddas>
blueshoe: That doesn't matter, it doesn't answer the question :)
<mattam>
open Peq
<mattam>
let acc n = fun i -> n += i
<Nutssh>
Shouldn't it be a functor over an underlying type supporting increment?
<mattam>
end
<Maddas>
I should read up on functors
<Maddas>
blueshoe: yes, you always know what you're dealing with in O'Caml
<Maddas>
blueshoe: Which is because of O'Caml's type system
<blueshoe>
right
<Maddas>
One could also say that you could just cast the type in C++, making the thing much easier
<mattam>
perhaps i could send him this one.
<Maddas>
the point is exactly handling an unknown type :)
<blueshoe>
without the typesafeness you might wind up adding 1 to "shoe"
<mattam>
how do you like my solution ?
<Maddas>
blueshoe: Yes
<Maddas>
blueshoe: Actually, no
<Maddas>
Type classes, for example.
<blueshoe>
i've heard of type classes, but i don't know what they are
<Maddas>
and if mattam's thing works, then also that way in O'Caml :)
<Maddas>
(I have no idea what it does, TBH)
<Maddas>
blueshoe: it's a bit like operator overloading, I guess
<Maddas>
I'm still learning, so I don't want to give you false information
A has left #ocaml []
<mattam>
TBH ?
<Maddas>
to be honest
<blueshoe>
mattam, i don't understand your solution, but i don't know ocaml very well... you might want to look at paul grahm's notes page, though, before sending it in... he qualifies his problem in there and goes in to more detail about solutions he won't accept
<mattam>
the problem in my solution is that you can't add floats to int.
<blueshoe>
ah, you can in mine
<Maddas>
mattam: you just have to increment it by one, that's all :)
<blueshoe>
it does a conversion
<blueshoe>
in fact, iirc, one of graham's sample inputs was adding a float to an int
<Maddas>
oh,y es
<Maddas>
it has to.
<Maddas>
Works for any numeric type-- i.e. can take both ints and floats and returns functions that can take both ints and floats.
<Maddas>
"I currently believe that you can't write this program in ML and Ocaml (no polymorphism),"
* Demitar
looks in.
<Maddas>
blueshoe: basically, you define functions/operators in a type class, then make types member of the type class
<Maddas>
blueshoe: So, anything using + doesn't need to be a concrete type, just a member of the typeclass in which + is defined.
<Maddas>
Something like that. :-)
<Demitar>
Maddas, sounds to me like someone is expecting a language to do something a way it's not supposed to be done in that language.
<Nutssh>
Ok. Got it implemented with functors.
<Demitar>
Do you have a reference.
<Demitar>
s/./?.
<Maddas>
Demitar: Yup
<Maddas>
Demitar: That's inherent in the question
<Maddas>
I'm not trying to say o'caml is bad because it can't be done, I don't think he is trying to say that
<Nutssh>
Define a new module Float that matches the signature, and then apply the functor.
<Maddas>
Ok, sounds like some practice
<blueshoe>
nutssh, and to add floats to ints?
<Nutssh>
Actually, on reflection, I didn't need to have Int.create or Int.print. Int.t is a transparent type.
whiskas has quit ["Leaving"]
<mattam>
problem is, i don't think he accepts boxed floats and ints, so there's no way to do that. Actually it is a good thing, as such a permissive accumulator is not of much use.
<blueshoe>
the problems seems tailor made for languages which are sloppy with their types
<mellum>
blueshoe: of course. It was invented to promote Lisp./
<Maddas>
blueshoe: I don't like the negative tone in that, though
<blueshoe>
how about "loose"?
<Nutssh>
blueshoe: He said nothing about that. Also, note that my floats and its are NOT boxed.
<Maddas>
blueshoe: Better
<Maddas>
blueshoe: aka more flexible :-)
<blueshoe>
i think he did, nutssh
<Demitar>
"when $is_sheep { push @sheep, $_ }" Is equivalent to: "if $_ ~~ $is_sheep { push @sheep, $_; next }"
<Demitar>
Makes a lot of sense, right? :)
<mattam>
Nutssh: you cannot add a float to your int incrementor
<Maddas>
Demitar: sure, why?
<Nutssh>
Yes you can. Define Float.t and Float.(++), pass to functor, and it works.
<blueshoe>
nutssh, click on graham's "send it along" link, near the bottom of his page, and you'll see him explain himself further, and give this example:
<blueshoe>
x = foo(1);
<blueshoe>
x(5);
<blueshoe>
foo(3);
<blueshoe>
print x(2.3)
<Maddas>
err
<Maddas>
accgensub.html
<Demitar>
Maddas, merely making fun my inability to parse perl. :)
<Maddas>
Demitar: It's hard to parse a language you don't know
<blueshoe>
"It should print 8.3"
<Nutssh>
But I'll agree with blueshoe that the problem is tailored to languages that allow type violations.
<Maddas>
Nutssh: Not violations
<mattam>
Maddas: especially perl
<Maddas>
mattam: certainly
<Maddas>
hm, tailored maybe, ok.
<Maddas>
Although it isn't a violation if it allows to do it, is it? :)
<mattam>
it's not violations just ad-hoc polymorphism that caml lacks
<Nutssh>
Maddas: *hmms* Ok, that was a bit strong, not what you point it out.
<Maddas>
yeah, mattam
<Nutssh>
mattam: No guarentee that the object being 'added' is a numerical-like object at all.
<Maddas>
Nutssh: I don't disagree by principle, it's just that I don't like calling other type systems bad because they are different.
<Maddas>
Nutssh: Yes, there is
<Maddas>
Nutssh: See type classes
<mattam>
Nutssh: that can be enforced, using type classes or like in the C++ example
<Nutssh>
It could be that INCRTYPE.t is an iostream. Maddas, yeah, I was just remembering that its not inherently ill-typed, but does require more than hindley-milner to represent it.
<mattam>
and it lacks it for the specific reason that inference is not guarenteed to terminate with it, IIRC
<Maddas>
I see
<Nutssh>
Eh, its a toy problem, so I'm not sure what it says. (and I have real problems to solve. :)
<Maddas>
O'Caml is turing-complete, isn't it?
<Nutssh>
On a computer with an infinite hard drive, it is.
<blueshoe>
you could implement c in ocaml, right? :)
<Maddas>
never mind, it is
<blueshoe>
and a machine to run it :)
<Nutssh>
Forget C. Can you implement a simple lambda calculus in ocaml? Any takers :)
<blueshoe>
isn't that what ocaml is?
<mellum>
blueshoe: no, it's typed
<Nutssh>
Well, ocaml is a typed lambda calculus.
<blueshoe>
i see
<blueshoe>
well, i'm sure you could implement your own type that takes binary data and then implement functions that introspect that data to get a typless language
<blueshoe>
whee!
<Maddas>
I thought there were some problems with unpacking binary things
<Maddas>
(without using C)
<Nutssh>
Just implement an interpreter directly type lamterm = I | Y | K | Apply of lamterm * lamterm
<blueshoe>
i don't know... i was just making it up as i went along
<blueshoe>
anyway, if you have problems unpacking binary then just use a list of integers, 0's and 1's and simulate binary
<blueshoe>
and introspect that :)
<Maddas>
:-)
<Maddas>
use boolean instead then!
<blueshoe>
oh yeah
<blueshoe>
much better
<blueshoe>
or one of the values could be a string containing the entire source to ocaml, and the other the source to camlp4
<Maddas>
haha
<Nutssh>
Toy problem. :) How about a real problem?
<blueshoe>
and that's your binary
<Maddas>
Nutssh: unpacking binary data got over the network
<blueshoe>
i guess i need sleep.. i'm getting giddy
<Maddas>
Nutssh: of course the "don't use C" is a toy restriction too :)
<blueshoe>
heh
<Nutssh>
*hmms* That seems nicely doable.
<Maddas>
Nutssh: Possible, I only recall somebody asking here.
<Maddas>
The problem involved marshalling data to O'Caml types
<Nutssh>
Ok.
<Nutssh>
I did something similar. Data wasn't binary, but that isn't relevant.
<blueshoe>
the second rover's going to land at noon EST
blueshoe has quit ["well, time to sleep... night all"]
_JusSx_ has quit ["BitchX: Little. Yellow. Better."]
cjohnson has joined #ocaml
ita has quit [Remote closed the connection]
ita has joined #ocaml
d2004xx has joined #ocaml
_JusSx_ has joined #ocaml
_JusSx_ has quit ["BitchX Lite I said!"]
whiskas has joined #ocaml
<whiskas>
Hello. Remember me? ;-)
<Riastradh>
Boo.
<Riastradh>
Did you figure out how to use unfold a few days ago?
<whiskas>
Hmm, don't know, I've come into another approach.
<whiskas>
Which in the end, came to something like unfold, as you told me ;-)
<whiskas>
So I'm grateful for your guidance.
ita has quit [Remote closed the connection]
The-Fixer has joined #ocaml
<Riastradh>
You might also like a map_fold function: it combines the functionality of map and fold in one. Since you're destructuring and constructing lists at the same time -- i.e. map --, and keeping state throughout the iteration -- i.e. fold --, map_fold is pretty suitable here.
<whiskas>
Ooh?
<Riastradh>
I don't think OCaml's List module provides it -- it's a pretty barren module --, but it's pretty easy to define in terms of fold.
<whiskas>
Fold?
<Riastradh>
map_fold : ('a -> 's -> 'b * 's) -> 's -> 'a list -> 'b list * 's
<whiskas>
Hmm, I was thinking of fold as 'a list -> ('a -> 'a) -> 'a
<whiskas>
Dunno what gave me that idea.
<Riastradh>
Fold is the fundamental list iterator.
<Riastradh>
There are actually two fold operations -- and two unfold operations --, the left and right variants.
<Riastradh>
fold_left : ('a -> 'b -> 'a) -> 'a -> 'b list -> 'a
<whiskas>
Wow, lemme crunch that...
Nutssh has quit ["Client exiting"]
<whiskas>
I don't get it. First of all, what's it supposed to do?
<Riastradh>
[[fold_left kons knil list]] iterates across the elements of list with a state value, initialized by knil; kons is applied to each state and each element of the list, and returns the next state.
<whiskas>
Aah, think I get it now.
<whiskas>
That's why the fuction applied to fold takes 2 arguments.
<Riastradh>
Yes.
<Smerdyakov>
whiskas, I think reading the manual would explain these things more efficiently than asking questions.
ita has joined #ocaml
wazze has joined #ocaml
<Riastradh>
[[fold_left kons knil [e1;e2;...;eN]]] is like [[kons (... (kons (kons e2 knil) e1) ...) eN]].
<whiskas>
Smerdyakov: I'm not asking questions, we're just having a conversation.
<whiskas>
Riastradh: I recall implementing that 2 days ago, lemme think...
<Smerdyakov>
whiskas, OK, then:
<Smerdyakov>
whiskas, I think reading the manual would explain these things more efficiently than having conversations.
Demitar has quit [Remote closed the connection]
<whiskas>
Smerdyakov: :-))
<Smerdyakov>
(Not to mention <whiskas> I don't get it. First of all, what's it supposed to do?)
<whiskas>
Ok, ok, I'll shut up.
<Riastradh>
fold_right goes the other way around: [[fold_right kons knil [e1;e2;...;eN]]] is equivalent to [[kons e1 (kons e2 (... (kons eN knil) ...))]].
<whiskas>
So back to the manual it is. Though there's too much silence here.
whiskas has quit ["Leaving"]
Demitar has joined #ocaml
Nutssh has joined #ocaml
Nutssh has quit ["Client exiting"]
Nutssh has joined #ocaml
emu has quit [Read error: 60 (Operation timed out)]
rox has joined #ocaml
Hipo has joined #ocaml
rox has left #ocaml []
Demitar has quit ["Bubbles..."]
_JusSx_ has joined #ocaml
Nutssh has quit ["Client exiting"]
Swynndla has quit ["Leaving"]
The-Fixer has quit ["Goodbye"]
_JusSx_ has quit ["BitchX: often imitated, never duplicated!"]
ita has quit [Remote closed the connection]
_JusSx_ has joined #ocaml
mattam_ has joined #ocaml
mattam has quit [Connection timed out]
_JusSx_ has quit ["BitchX: try our Windows 95/98 and Windows NT 4 flavors too!"]
Swynndla_wk has joined #ocaml
<reltuk>
anyone know the bounds behavior of sqrt(lg(n)) as it compares to lg(sqrt(n))?
<Smerdyakov>
Are you asking about the asymptotic relationship of those two functions?
<Smerdyakov>
If you remember rules of logarithms, the second function simplifies even further.
<Smerdyakov>
(If we only care about asymptotic behavior)
<reltuk>
yeah, asymptotic behavior...
<Smerdyakov>
Do you see how to simplify lg(sqrt(n)), then?
<reltuk>
1/2*lg n
<reltuk>
I'm dumb
<Smerdyakov>
Which is the same as lg n, for these purposes.
<reltuk>
yep
<Smerdyakov>
So I think the relationship is clear now, though I haven't thought of a proof yet.
<reltuk>
so that's higher than sqrt(lg (n))
<Smerdyakov>
That's my intuition.
<Smerdyakov>
lg n/sqrt(lg n) = sqrt(lg n)
<Smerdyakov>
So we have a multiplicative difference proportional to n.
<reltuk>
I've got a crapload of these to put in order :-p
<reltuk>
but that property lg (sqrt (n)) = o(sqrt(lg(n))) helps a lot
The-Fixer has joined #ocaml
Maddas has quit ["Terminated with extreme prejudice - dircproxy 1.1.0"]
Maddas has joined #ocaml
themus has joined #ocaml
* Smerdyakov
wonders about how to do forward reasoning in Coq: deduce things from hypotheses without having to relate that directly to goals.
async_ has joined #ocaml
<async_>
if you have a function 'let double f = fun x -> f (f x)', so that '(double succ) 0 ==> 0', and '((double double) succ) 0 ==> 4', why does '(((double double) double) succ)' return 16, not 8?
<async_>
er, (double succ) 0 ==> 2
<Smerdyakov>
Well, evaluate (double double) double applied to an arbitrary value and find out. :)
<Smerdyakov>
As in, work it out by hand.
shrimpx has joined #ocaml
<async_>
Smerdyakov: are you in soda right now
<shrimpx>
is there an emacs mode for caml that does syntax hiliting and such in the terminal? tuareg-mode only does it in X
<Smerdyakov>
No
<mellum>
xemacs does this for me with tuareg-mode
<shrimpx>
i hacked it to turn on highlighting regardless, and it seems to work fine... it looks for XEmacs or emacs running in X specifically, for some reason