gl changed the topic of #ocaml to: OCaml 3.07 ! -- Archive of Caml Weekly News: http://pauillac.inria.fr/~aschmitt/cwn , A tutorial: http://merjis.com/richj/computers/ocaml/tutorial/ , A free book: http://cristal.inria.fr/~remy/cours/appsem, Mailing List (best ml ever for any computer language): http://caml.inria.fr/bin/wilma/caml-list | http://icfpcontest.org/ !!
monotonom has quit ["Don't talk to those who talk to themselves."]
kinners has joined #ocaml
cDlm has quit [Remote closed the connection]
cDlm has joined #ocaml
wolfman8k is now known as wolf|zZ
GreyLensman has joined #ocaml
sundeep has quit ["Client exiting"]
yauz has joined #ocaml
GreyLensman has quit ["Leaving"]
vezenchio has quit ["According to [a processor for game design], you statistically have a better chance of becoming a rock star than you do of suc]
gini has quit [Read error: 110 (Connection timed out)]
monotonom has joined #ocaml
cjohnson has quit [Read error: 54 (Connection reset by peer)]
Nutssh has joined #ocaml
Nutssh has quit [Client Quit]
Nutssh has joined #ocaml
slashvar1lri] has joined #ocaml
slashvar[lri] has quit [Read error: 104 (Connection reset by peer)]
kinners has quit [Read error: 60 (Operation timed out)]
monotonom has quit ["Don't talk to those who talk to themselves."]
kosmikus|away is now known as kosmikus
mrsolo has joined #ocaml
slashvar1lri] has quit [Read error: 104 (Connection reset by peer)]
Lemmih has quit [Read error: 60 (Operation timed out)]
Petruchio has quit ["Fare thee well."]
eigenspace has joined #ocaml
mrsolo_ has joined #ocaml
mrsolo has quit [Read error: 104 (Connection reset by peer)]
wmg has joined #ocaml
wmg has left #ocaml []
karryall has joined #ocaml
slashvar has joined #ocaml
<slashvar> Hi there !
<Nutssh> slashvar, hi.
<vincenz> Anyone know a good book on denotational semantics for defining proglanguages? (Or perhaps a pdf)
<slashvar> hum ... I think there's a book from Dave Smith (I think it's the rigth spelling) and it's available online
<slashvar> but I don't have the url at hand
<vincenz> Ah, yes I had heard of that name
<vincenz> Didn't know it was online though, thnx
<slashvar> I meet him 2 weeks ago (in a spring school for phd student) and he told us about it, but I forgot to write down the url
* vincenz nods
<vincenz> What are you doing your PhD on?
<mayhem> slashvar: are you s.peyronnet
<slashvar> non
<slashvar> But I know him
<mayhem> he was my algo teacher this year
<vincenz> Tu parles francais, j'assumes. J'ai vu que tu viens de .fr
<slashvar> oui
<slashvar> mais c'est un channel anglophone ;)
<vincenz> Yup
<vincenz> So what is your PhD on?
<slashvar> Secure Information flow analysis in the CDuce language
* vincenz nods
<vincenz> So I assume CDuce is used to model it? I have to admit I never heard of that language
<slashvar> no, CDuce is an XML-oriented language
<vincenz> So you're studying the security in CDuce? Or you're using CDuce (aka modelling in CDuce) the security analysis?
<slashvar> I working on static/dynamic analysis to infer information flow (mainly for security purpose)
* vincenz nods
<slashvar> so CDuce is my target language (and I'm using an extension of its type system, with semantic subtyping, to infer flows)
<vincenz> ah I see
<slashvar> (If you're interested in CDuce, just take a look at www.cduce.org ;)
<vincenz> Far off from my PhD domain :P
<slashvar> what is yours about ?
<vincenz> Well the topic isn't fixed yet as I started in april and I've been juggled around a bit
<vincenz> But generally memory management for multimedia applications on low power embedded systems
<slashvar> oki
<vincenz> BAsically how to use the memory-hierarchy as optimally as possible
<vincenz> And with the new very small technologies when to migrate when the chip starts to overheat
<karryall> vincenz: and are you using ocaml for this ?
slashvar has quit [Read error: 104 (Connection reset by peer)]
<vincenz> Nope
<vincenz> I used Ocaml for the ICFP
<vincenz> Most of the code I work on necessarily is C++
<vincenz> Seeing most multimedia apps are in c++
<vincenz> However I just started and maybe I can integrate Ocaml ;)
wolf|zZ is now known as wolfman8k
<vincenz> Anyone know how to do subtitution on filenames in bash?
<vincenz> for i in '*.ps'; do ps2pdf $i ($i - ps +pdf); done
<vincenz> got it
gim has joined #ocaml
slashvar[lri] has joined #ocaml
buggs^z has joined #ocaml
<Nutssh> I try to code in ocaml whenever I can get away with it.
<Nutssh> Oh, and thanks for switching back to english for the discussion above.
buggs has quit [Read error: 60 (Operation timed out)]
wolfman8k has quit ["Leaving"]
Herrchen has joined #ocaml
bk_ has joined #ocaml
<vincenz> Me too
<Nutssh> :)
buggs^z is now known as buggs
<vincenz> In fact our ICFP team was c++
<vincenz> But the simulator was being built so slowly I quickly hacked one together in ocaml
<vincenz> It's quite funny, most people claimed like 22mins in forth, or 5 minutes in haskell for runtime of their simulator
<vincenz> my ocaml one took 4 seconds
<vincenz> And after I moved one list ot an array
<vincenz> 2 seconds
* vincenz taps his head
<Nutssh> :)
<Nutssh> And how much faster was it to code?
<vincenz> Ooh....I don't know...hmm....MUCH!
<vincenz> Took me a while to get a gui coded
<Nutssh> :)
<vincenz> Seeing I had never used Graphics
<vincenz> And a bit of time for the parsing of the inputfiles
<vincenz> cause I did it manually
<vincenz> (not that comfortable with ocamllex and ocamlyacc yet)
<Nutssh> I was tempted to do it, but I want to do it with a group, and nobody here has any great love of such languages.
<vincenz> Next year you're on my team then :)
<vincenz> #abstractoasis is the channel
<Nutssh> We're a java place here. :(
<Nutssh> :)
<vincenz> I did it with only people from irc
<Nutssh> What is/was that? Who'd you do it with?
<Nutssh> Neat.
<vincenz> From freenode
<vincenz> My box is linux so I had a cvs installed
<Nutssh> I mentioned it then, someone here said that a team existed.
<vincenz> Everyone got an account
<vincenz> and communication through irc
<vincenz> Shouldn't it be Putty?
<Herrchen> moin
<vincenz> Moin?
<Herrchen> slang here in germany for hello - just a bad habit to use it on irc ...
<Nutssh> Cool.
<Nutssh> Ich spreche Deutsch nicht sehr gut.
<Herrchen> I compete with a friend using the same setup: talk over irc and cvs for code sharing
<Nutssh> Nice.
<vincenz> AH moin
<vincenz> from MoinMoin
<Herrchen> at least this sentence is correct :)
<vincenz> Ich sprece night Deutsch.
mellum has joined #ocaml
<mellum> hi
<vincenz> spreche even
<Nutssh> I sorta like telephone because its higher bandwidth, but CVS and IRC work OK.
<vincenz> Perhaps but that's not possible in group
<Herrchen> well in fact it is from nothern germany (Friesland) and sometimes moin moin is used.
<vincenz> And it doesn't give you an overview of what is being spoken
<Nutssh> Yeah.
<vincenz> Herrchen: lookup MoinMoin it's a python implementation of a wiki
<Herrchen> (and sometimes confused with good morging/guten morgen - because it sounds similiar)
<Herrchen> vincenz: ah - i didn't know
<vincenz> Maar ik spreek wel nederlands en dat trekt heel veel op duits
<Herrchen> hmm what is your feeling about your contest entry? I think ours sucks - after having to choose C because it was the only language we both knew I got really trouble with missing some features I am used to
<vincenz> That's why I participate with people off the net
<vincenz> I mean from irc
<Herrchen> vincenz: sorry I didn't understand your last sentence
<Nutssh> :)
<Nutssh> Ocaml is just too advanced.
<Herrchen> anyway, I had fun
<Herrchen> and thats what counts imho
<Nutssh> :)
<Nutssh> I would have been happy to have done it with others in lisp.
<vincenz> I did it last yaer in scheme
cjohnson has joined #ocaml
<Herrchen> we hoped to have something what we could do in prolog - and the one of this year would have been to slow :)
<vincenz> does prolog have good IO/Gui capabilities?
<Herrchen> vincenz: depends on the prolog system
<Herrchen> I thought it could be something which would be good solveable in prolog, but then it wasn't :)
<Herrchen> but in fact most prolog systems are slow
<Herrchen> the fastest I know is the ciao prolog system (GPLed) - which compiles to machine code, but don't know how good it handles dynamic predicates
<Nutssh> common lisp with compilation at runtime would be pretty sweet for this years ICFP, at least for the simulation bits.
<Herrchen> ah sigfood received - bbl
cjohnson has quit [Read error: 110 (Connection timed out)]
cjohnson has joined #ocaml
<buggs> how does one detect eof without raising an exception ?
<buggs> Herrchen, is ciao faster than yap ?
<Nutssh> Whats wrong with detecting the exception?
<vincenz> buggs: What's wrong with
<vincenz> exceptions?
<buggs> try let c = get_char in foobar c with Eof -> print last_c
<buggs> i want sth like that
<buggs> in case of eof i need the last char before the eof
<vincenz> let rec read_file() =
<vincenz> try
<vincenz> let data = Instruction.parse(input_line channel) in
<vincenz> data :: (read_file ())
<vincenz> with End_of_file -> close_in channel; []
<vincenz> buggs: easy
<vincenz> let last_c = ref ' ' in
<vincenz> try let c = get_char in last_c :=c; foobar c with Eof -> print !last_c
<buggs> ya but that sucks when the channel has 0 chars
<vincenz> Duh
<vincenz> Anything will suck if you have 0 chars
<vincenz> Cause conceptually speaking the notion of last char doesn't make sense in a channel of 0 chars
<vincenz> No matter what system you use...
<vincenz> or
<buggs> well if there is 0 chars i should print '' and not your ' '
<vincenz> let last_c = ref None in
<buggs> ya opetions ...
<Nutssh> There is no ''. There is the empty string "", but no empty char.
<buggs> this complicates stuff and i need performance
<vincenz> buggs: You HAVE to use one of those systems
<vincenz> Conceptually speaking
<vincenz> Yiu have no notion of a last_char
<vincenz> So either use an option
<vincenz> or use a default character
<buggs> there should be something to detect eof
<vincenz> There is no alternative
<vincenz> Even if the language provided it
<vincenz> If it's a file
<vincenz> val in_channel_length : in_channel -> int
<vincenz> and then use seek
<buggs> no it's stdin or a file
<vincenz> ..
<vincenz> Yet you need performance
<vincenz> I doubt the system I proposed is slow
<buggs> c := get_char
<buggs> maybe
<vincenz> Or any slower than the ideal system
<vincenz> A ref is not that slow it's just an if
<vincenz> And you only need to check it's value at the end
<vincenz> once
<vincenz> I mean an option
<buggs> isn't a match rather expensive ?
<buggs> i'll benchmark
<Nutssh> Don't worry, just do it.
<Herrchen> re
<Herrchen> buggs: yes
<Herrchen> buggs: yap just compiles to some sort of WAM
<vincenz> match is not expensive, it's just a switch
<Herrchen> buggs: but there should be some performance improvements in yap 4.5.x so I don't really know, I don't use development versions if I don't have to
<buggs> interesting never new about ciao
<buggs> *knew
bk_ has quit ["Leaving IRC - dircproxy 1.1.0"]
<Herrchen> anyway gotta go - bye
<Nutssh> buggs, don't bother micromanaging it. Implement first, then profile.
<Banana> ls
<Banana> sorry.
<Nutssh> :) Thats always been my rule and its incredibly well.
<buggs> ya, but i probably just fall to doing it in an impreative way
<Nutssh> For something like that, I'd do it imperatively.. I believe ocaml has a while construct?
<buggs> ya while true i used
<Nutssh> The last two programs I wrote were bottlenecked by Random.int and Array.sort. Each accounting for about 30% of the processing time.
<buggs> but the fallacy is to use input_char at all cause reading bigger chunks and coverting to a list is probably faster anyways
<Nutssh> Better question. What is it you really want to do?
<buggs> i'm doing an LZW compression programm
<buggs> using a Trie as data structure
<Nutssh> How about using Unix.read into a nice fat 16kb buffer?
<Banana> buggs: i think input_* and output_* are buffered anyway so you actually read (from disk) a chunk of data and not a single char.
<Nutssh> And, if you have to do a trie lookup on every character, the overhead of a function call to input_char is going to be lost in the noise.
<vincenz> Banana: I suggested that, the problem is that he doesn't know the size of the channel as it's stdin
<Banana> hum ?
<vincenz> I suggested he does a seek fr the end of file (he needed that for some reason)
<vincenz> But then he told me he's reading from stdin so channel_length is not an option
<vincenz> And hence reading by buffer is not an option either
<Banana> what i said is that the in_channel and out_channel data structures are already buffered (if i remember correctly) so he actually doesn't read on char at a time from disk.
<Banana> he does'nt have to implement buffer himself.
<vincenz> oh yes, that's truee
<buggs> the trie lookup is no so bad
<vincenz> but programmatically he still has to use input_char seeing he doesn't know the lenght of the channel
<vincenz> neither is input_char
<Banana> and i don't see the need for an Option type here...
<buggs> gprof shows alloc_shr costing a lot
<buggs> waht does it do ?
<vincenz> I assume that's the GC
<Nutssh> buggs, how much of it is done?
<buggs> compare_val and compare_resize_stack next and .mcount
<buggs> Nutssh, what do you mean ?
<Nutssh> How much of the program is done?
<Banana> buggs: these are 3 ocaml internals : alloc_shr is responsible for allocating bloc in the heap and regeistering them in the gc.
<Banana> compare_val is the polymorphic comparision function.
<Banana> it recursiveley traverse 2 ocaml value to test for equality.
<buggs> Nutssh, it works (beside that i loose some bytes at the end because of my eof problem)
<Nutssh> Ah.
<Banana> it uses a stack, hence compare_resize_stack is a auxiliary function.
<Nutssh> What are the major callers to alloc_shr at the end of the profile?
<vincenz> Banana: you said 3 but mentioned 2
<Banana> compare_val alloc_shr and compare_resize_stack ?
* Nutssh counted 3
<Nutssh> Suspicious.. Are you accidently using a generalized type \forall_A ... in your arrays instead of a specific type 'int array'. That hurt me a few times.
bk_ has joined #ocaml
<vincenz> ah ok
<buggs> i don't use arrays on encoding only when decoding
<buggs> currently i messure encoding
<Nutssh> ok.
<buggs> another problem i have is that i output_binary_int always uses 4 bytes
<buggs> Banana, so i guess the options aren't that cheap ?
<Nutssh> ouput_char (Char.chr x)
<karryall> output_byte
<buggs> x := x / 256 go to 10?
<Banana> buggs: i don't see why you need an options.
<Banana> why not just a char ref ?
<Nutssh> karryall, thanks.. Don't do much binary IO in ocaml.
<Banana> buggs: you are using a while or a recursive function ?
<buggs> Banana, if the channel is empty i should output nothing
<buggs> while
<Banana> why not just counting the number of byte read ?
<buggs> it could be stdin
<Banana> ?
<buggs> oh
<buggs> i c
<Banana> count = ref 0 ... try while blah do blah .... done with End_of_file -> if !count = 0 then ...
<buggs> the programm gets uglier and uglier that way :(
<buggs> don't you think if i read 1024 bytes explode them and recurse the list i can be as fast ?
<Banana> you will spend time allocating cells for the list...
<Nutssh> It shouldn't be as hard as you are making it out to be.
<buggs> Nutssh, hard is one thing beauty is another
cjohnson has quit [Connection timed out]
<buggs> look at my ruby version
<Banana> buggs: what is the algorithm ? read chars, put them in a data structure and when End_of_file then work on the data structure ?
cjohnson has joined #ocaml
<Nutssh> Do you have the code up someplace?
<Nutssh> The ocaml code?
<buggs> currently in a private repo
<Banana> can't you just test if your data structure is empty and then output nothing ?
<Nutssh> Can you post it into the same directory?
<buggs> let me remove the option then i'll check it in
<Banana> buggs: i'm not a ruby expert... what is the meaning of b = fh.getc ; c=b.cr when fh.eof is true ?
<Banana> nevermind i understand now.
vezenchio has joined #ocaml
<mayhem> hi guyz, I have a question about combinators theory, I have a question about B combinator
<mayhem> it is said : B =def S (K S) K
<mayhem> and B F G X := F (G X)
<mayhem> if I develop B F G X, that makes S (K S) K F G X := S S K F G X
<vincenz> what does def mean?
<mayhem> := S F (K F) G X := S F F G X := F G F G X
<Banana> (vincenz: by definition.)
<vincenz> ah
<vincenz> like macro substitution
<mayhem> is F G F G X := F (G X) ?
<Banana> mayhem: did that some month ago let me take a paper and write it down.
<vincenz> shouldn't that be
<vincenz> (S (K S) K) F G X
<vincenz> (S S K) F G X
<vincenz> (now if someone explained the ops of S and K...
<mayhem> K S =def S and S A B C =def A C (B C)
<mayhem> K X =def X, that is more clear I think.
<mayhem> I understand K as the projector on the first parameter
<vincenz> uhm
<vincenz> no
<vincenz> K S X = s
<vincenz> I just looked on a website
<vincenz> so (K S) waits for a second op
<vincenz> yes
<vincenz> but dropping the second
<vincenz> what do parentheses do?
<mayhem> syntaxic grouping, priority basicaly
<vincenz> S (K S) K F G X = S S F G X
<vincenz> is it left to right or right to left?
<vincenz> thnx
<mayhem> french speaking peoples only
<vincenz> nnot an issue
<mayhem> Banana: anything in your course that make believe that F G F G X := F (G X) ?
<vincenz> it doesn't explain the order of evaluation
<vincenz> like if I have something as
<vincenz> S K X K Y
<mayhem> if you try the exercise you will see that what I'm writing is good
<vincenz> do I have S X Y
<vincenz> or X K Y?
<mayhem> S A B C =def A C (B C) and B =def S (K S) K, thats all you need to know
<vincenz> I know
<vincenz> but the order of evaluation!
<vincenz> take S K X K Y
<mayhem> left to right
<vincenz> if I evaluate from right to left I get
<vincenz> ah ok
<mayhem> well, first (), then left to right
<vincenz> yup
<vincenz> then it's obvious
<vincenz> S (K S) K F G X
<Banana> mayhem: i find B F G X = F G X
<vincenz> me too
<vincenz> S (K S) K F G X
<vincenz> S A K F G X
<vincenz> (With A x = S)
<mayhem> A x =def S is different from A =def K S
<mayhem> (afaik)
<vincenz> K F G X
<vincenz> F G X
<vincenz> no
<vincenz> look at it from functional point of view
karryall has quit [Read error: 104 (Connection reset by peer)]
<vincenz> S x y = x
<vincenz> so S X = lambda y->x
<vincenz> so S X = lambda y->X
<vincenz> or another combinator/fun
<vincenz> which I labeled A
<vincenz> oops
<vincenz> I saw S K
<vincenz> sorry
<vincenz> either way
karryall has joined #ocaml
<vincenz> S (K S) K F G X
* vincenz mutters
<vincenz> Never mind me
<vincenz> I was confusing operators
<mayhem> k, so any hint why F G F G X would be =def F (G X) ?
<mayhem> (which is also =def B F G X)
<Banana> how does it look ?
<vincenz> good :)
<vincenz> I was going that way except for a small reasoning error
<vincenz> otherwise I would've ended there as well
<vincenz> But then again
<vincenz> I'm new to ski
<Banana> there is a missing parenthesis ....
<Banana> hold on.
<Banana> there.
<Banana> you can reload.
<vincenz> Woot I got W :)
<mayhem> Banana: hum ok, I didnt know S was prioritary than K even when K is in (), and I didnt know that K scope could be extended to multiple nested ()
<Banana> hum...
<Banana> there is non priority...
<mayhem> really strange cause when I do the exercise about combinator B, I found F G F G X, and the web interface says that it is a good result, can you try it ?
<mayhem> ahhh I know why
<mayhem> because the function there is FoG
<mayhem> so its indeed (FoG) o (Fo G) (X)
<mayhem> (F o G) (F o G) (X)
<mayhem> not sure if I'm clear
<mayhem> maybe it should be : (F o G) o (F o G) (X)
<mayhem> B F G X =def (F o G) o (F o G) (X) okkkkkkkkk
<mayhem> I think I got it ;)
<mayhem> so B G X =def G G X probably
<mayhem> what do you think ?
<vincenz> B takes three params, you can't just drop one
<vincenz> then you're left with a closure taking something
<Banana> vincenz: quite.
<Banana> you can still reduce (these are not function ;) but you get stuck at some point.
<Banana> for B G X you can't go further than S (K G) X
<mayhem> Banana: have you done the exercise ?
<Banana> what ?
<Banana> B G X ?
<Banana> either way, you have got the Church Rosser property for the combinators.
<mayhem> Banana: B F G X
<Banana> it's F G X.
<mayhem> Banana: see there is a form on the webpage for it
<Banana> which web page ?
<mayhem> yeah its F G X, but when you do the exercise on http://www.ifi.auf.org/combinateurs/Chapitre3.htm (middle of the page), you end up to the result F G F G X
<Banana> (the Church Rosser property insure that whatever reduction you make, you will find the same normal form if** there is one).
<mayhem> sure
<mayhem> which is definitely strange with what I'm saying
<mayhem> thats why I was askin
<mayhem> cause I think the exercise online has some problem, (or is it my brain which have problems ? ;)
eigenspace has quit [Read error: 110 (Connection timed out)]
<Banana> mayhem: the exercise called "Le combinateur B" ?
<Banana> where do you end up with F G F G X ?
<Banana> seems strange to me.
<vincenz> There's a bug in the evaluator
<vincenz> for instance it allows
<vincenz> K S -> S
<vincenz> this is wrong
<vincenz> K S -> lambda x -> S
<vincenz> it should pop another letter after it but it doesn't
<mayhem> Banana:
<mayhem> B F G X
<mayhem> = S ( K S ) K F G X
<mayhem> = S S K F G X
<mayhem> = S F ( K F ) G X
<mayhem> = S F F G X
<mayhem> = F G ( F G ) X
<mayhem> Bravo!Félicatation! Vous avez la bonne solution (e.g. congrats you found the solution)
<mayhem> isnt it strange ?
<Banana> yes,
<Banana> let me check.
<mayhem> its an online course from E.N.S.T.
<vincenz> it;s buggy!!!
<vincenz> (K S) != S
<mayhem> vincenz: doh, noone can be trusted nowadays
<mayhem> heh
<mayhem> I need to go, cya guyz this evening
<Banana> buggs: what do you think of this ? www.di.ens.fr/~kn/input2.ml ?
dsuch has joined #ocaml
slashvar[lri] has quit [Read error: 60 (Operation timed out)]
<Banana> this is a kind of 'one char' read ahead in_channel like the one you have in ruby.
<Banana> but input_char2 is ugly...
* vincenz drools
<Banana> it should throw an exception.
<vincenz> code in ocaml is so easy to write :P
<vincenz> Hey buggs
<Nutssh> buggs, where is the ruby and the ocaml trie?
<vincenz> you don't need ;; in ml files
<vincenz> And you don't put module LZW = struct...
<vincenz> you should only place what's actually inside the struct in the module file
<vincenz> Otherwise you have to LZW.Lzw.encode
<vincenz> And Nutssh where do you see ruby?
<buggs> that's an svn repo my topdir is https://cvs.cip.ifi.lmu.de/svn/stringalgorithmen04/hauser
<buggs> you need trie/ocaml to compile lzw.ml
<vincenz> why do you have triple code?
<buggs> vincenz, i find ;; improves readability
<buggs> triple ?
<Banana> buggs: or why not instead of having let c = ref ' ' do : let try let c = input_char ... in try while true do ... done with End_of_file -> output with End_of_file exit 0
<vincenz> quintiple I mean
<vincenz> quadruple
<vincenz> ruby/ocaml/java/c
<vincenz> it's curious the java version is smaller in code than the ruby and ocaml one, or on par
<vincenz> by the way your c-version is wrong
<vincenz> for multiple reasons
<buggs> they are not all up to date
<buggs> i'm a bit bored at uni sometimes
<buggs> we had to choose between c++ and SML
<vincenz> the c version, first of all you need to do #ifndef INCLUDE_TRIE_H
<vincenz> ...
<vincenz> secondly
<vincenz> you can't define functions inside a .h file
<vincenz> if you include it in multiple .c you'll have multiple definitions of that function
<buggs> vincenz, yes i can
<vincenz> the .h file should only declare the function
<vincenz> buggs try linking two .o files from two .c files each with that .h inclusion
<buggs> C is brocken in respective to how they encapsulate their modules
<Nutssh> Also, why are you using a class for the trie instead of a module?
<buggs> i wanted to test the OO features of ocaml
<Banana> buggs: the classic way here to avoid counting and Option is to try to read one char first, then only enter the while loop where you update c at the end instead of the begining.
<buggs> i find them less than great :(
<vincenz> what's wrong with the OO features of ocaml?
<Nutssh> Generally I reserve OO for times when I genuinely want subtyping and/or dynamic dispatch. So far, none of my ocaml code has actually needed that.
<vincenz> ME neither
<karryall> ugh objects :/
<vincenz> And if you consider I come from an OO background...(C++/Java...)
<vincenz> I program in an OO-style with modules
<buggs> vincenz, see the foldl method
<vincenz> (I even program in an OO way with c)
<Nutssh> vincenz, you use modules..
<vincenz> Nutssh: that doesn't stop me from using a clean oo paradigm
<Smerdyakov> vincenz, what is "an OO style with modules"?
<vincenz> a module defines one type t
<vincenz> and all funcs take as first param that type t
<buggs> c++ does not count as OO
<Smerdyakov> vincenz, if you don't use dynamic dispatch, it's not OO.
<vincenz> Smerdyakov: encapsulation...
<Smerdyakov> vincenz, so call it that.
<vincenz> Yes SyntaxPolice
<Smerdyakov> vincenz, this technique existed long before it was used in an "OO" context.
<Nutssh> C and java style 'objects' IMHO combine distinct concepts including subtyping, inheritence, modularity/namespace management and dynamic dispatch.
<vincenz> I tend to use terms loosely
<Smerdyakov> vincenz, don't use PL terms loosely in a channel with many PL researchers. :P
<vincenz> Alright
* vincenz is from an EE background...so doesn't even know half of the terminology
<vincenz> You're lucky I remembered the term 'encapsulation' from some webpage and used it in this context appropriately
<Nutssh> I do my code very heavily on the modules too, but I have yet to even be tempted, except once, to want to use the OO features. That was where I wanted buffer management with several backends.
<Smerdyakov> I would prefer the term "data abstraction," myself.
<vincenz> Meh
* vincenz returns to reading papers on memory hierarchies
<buggs> <vincenz> you should only place what's actually inside the struct in the module file
<buggs> what do you mean ?
* vincenz blinks
<Nutssh> vincenz, what papers are you reading?
<vincenz> When did I say that?
sanxiyn has joined #ocaml
<buggs> after the ;; comment
<vincenz> oh!
<vincenz> yes
<vincenz> module LZW struct xxxx end
<vincenz> only place Xxxx in file lzw.ml
<vincenz> and then you can refer to it as Lzw
<vincenz> as long as you make an mli file as well
<buggs> ah
<vincenz> They should really put that more obviously in the o'reilly book
<karryall> vincenz: no need for a .mli
<buggs> what module LZW then good for ?
<vincenz> karryall: not in this case no, but should he ever want to refer to module Lzw...
<Nutssh> buggs, its for whan you want to encapsulate modules in other modules.
<buggs> oh and it gets it implicitly uses the filename ?
<Nutssh> For instance, in module Unix in the standard library, they should define several modules instead of a flat namespace.
<Nutssh> Yes. module 'Foo' is implicitly defined in files 'foo.ml' 'foo.mli'
<Nutssh> IN effect, it does at the top level '' module Foo = (struct <contents of foo.ml> end) : (sig <contents of foo.mli> end) ''
<Smerdyakov> vincenz, you never need .mli files for anything but enforcing abstractions.
<buggs> Nutssh, but when i have LZW and LZ78 and both have decode and encode ?
Barrett has joined #ocaml
<karryall> buggs: you refer to them as LZW.encode and LZ78.encode
<buggs> without opening LZW then ?
<Nutssh> opening a module means that the namespace is exported. Like 'using namespace ...' in C++.
<karryall> right
<buggs> ah i got that very wrong indeed
Zaius has joined #ocaml
<Nutssh> For the trie, I'd probably define it as type 'a trie = Node of 'a trie array | Leaf of 'a instead of going into the OO.
<Banana> maybe if you need some inspiration you can have a look at : http://www.lri.fr/~filliatr/software.en.html
<vincenz> Smerdyakov: I thought that any func not
<vincenz> 'exported' by the mli was private to the module
<Nutssh> Nice.
<buggs> hmm so everyone is against OO in ocaml :)
<Banana> no.
<Smerdyakov> vincenz, if there is no mli file, everything is exported with its principal type.
<vincenz> ocamlweb looks pretty fly
<vincenz> Smerdyakov: I did not know that detail, thnx
Smerdyakov has quit ["Fly on plane!"]
<Nutssh> buggs, no. I've just not had something that needed it yet. When I want dynamic dispatch and subtyping and inheritance, I'll use it, or perhaps more accurately learn how to use it.
<buggs> i really would like someone comment on the foldl method of the trie
<buggs> not the function
<karryall> the method ? the problem is with #node I think
<Nutssh> Sorry, Can't help you there.
<buggs> karryall, "This method has type ('a -> node -> 'a) -> 'a -> 'a -> 'a
<buggs> which is less general than 'b. ('b -> node -> 'b) -> 'b -> 'b -> 'b"
<buggs> ???
<vincenz> buggs: link?
<karryall> the first one is not polymorphic
<Nutssh> Its alpha-renaming the 'a in your definition.
<vincenz> euhm
<vincenz> Why do you have the 'a. ?
<vincenz> method foldl : 'a. ('a -> #node -> 'a) -> 'a -> 'a -> 'a =
<vincenz> fun f accu n ->
<vincenz> List.fold_left
<vincenz> (fun a (s,n) -> n#foldl f (f a n) n)
<vincenz> accu self#transitions
<vincenz> *)
<vincenz> Why do you have the 'a . ?
<karryall> vincenz: look up polymorphic methods
<vincenz> k
<karryall> buggs: you need to define the class type beforehand
<vincenz> he did
<vincenz> as 'node
<karryall> no
<vincenz> object(self:'node)
<karryall> that's a binding for the type of self
<vincenz> oh
* vincenz shrugs
<vincenz> I'm lost
<buggs> karryall, i had an explicit class type that opened a can of worms
<Nutssh> And, try to compile it without the 'a and it also doesn't work.
<vincenz> but then agin I never looked at the oo stuf in ocaml
<karryall> I suspect the can of worm is the solution though
<buggs> i would rather suggest that being a problem of the compiler
<karryall> you would be wrong I think
<buggs> karryall, can you explain the problem to me ?
<Nutssh> Remember that the type system has to be robust even with subtyping and inheritance. That could be part of the problem.
<karryall> yes, that's the problem. Referring to #node inside the definition of node is a bit problematic
<Nutssh> In particular, the function 'f' that is an argument to foldl in a contravariant location.
Lemmih has joined #ocaml
<Nutssh> Err, the #node argument to the argument f is in a contravariant location.
<buggs> it works just fine for non recursive stuff
<buggs> and the error message is not really helpful imo
<karryall> the problem is the n#foldl in the body of the method
<karryall> I think it is inferred as a regular (non polymorphic) method
<karryall> that's why I think you should define a class type before
<karryall> with a foldl polymorphic method and constraint n to that type in the body of foldl
<Nutssh> Ah, Here's something interesting... If you make the type:
<Nutssh> method foldl : ('a -> node -> 'a) -> 'a -> 'a -> 'a =
<Nutssh> It compiles, and infers the type as:
<Nutssh> method foldl : (node -> node -> node) -> node -> node -> node
<karryall> yes, the definition of foldl is suspicious
<karryall> the third argument n is not used in the body
<buggs> oi :))
<buggs> thanks a lot Nutssh
<Nutssh> Hey, thats cute.
<Nutssh> Wish I'd seen that. Now, why was the origional definition wrong?
<Nutssh> Err, why was the origional definition not typechecking.
jao has joined #ocaml
Nutssh has quit ["Client exiting"]
dsuch has quit ["Lost terminal"]
<cDlm> how can I define a function map_elements which returns the list of values in a Map ?
<cDlm> without writing it for each kind of Map I have, that is...
kosmikus is now known as kosmikus|away
<mattam> module MElems(M : Map.S) = struct let map_elements m = M.fold (fun k v l -> v :: l) m [] end i suppose
<cDlm> module MyMapMake(Ord : Map.OrderedType) = struct
<cDlm> include Map.Make(Ord)
<cDlm> let elements m = fold (fun k v l -> v::l) m []
<cDlm> end
srv has quit [Read error: 104 (Connection reset by peer)]
<cDlm> seems to compile at least
smimou has joined #ocaml
srv has joined #ocaml
maihem has joined #ocaml
Zaius has quit [Read error: 104 (Connection reset by peer)]
<mayhem> Banana: back
monotonom has joined #ocaml
karryall has quit ["tcho"]
CosmicRay has joined #ocaml
bk_ has quit ["Leaving IRC - dircproxy 1.1.0"]
bk_ has joined #ocaml
<mattam> cDlm: yep, that's the other solution
_n0cte_ has joined #ocaml
_n0cte_ has quit []
scaudi has joined #ocaml
scaudi has left #ocaml []
mattam_ has joined #ocaml
<CosmicRay> uhoh.
* CosmicRay is startnig to like haskell :-)
<mattam_> you'll come back
<CosmicRay> I'm just reading over some haskell tutorials
<CosmicRay> the list comprehension stuff and type classes both look really nice
<CosmicRay> it seems that the typing systems in ocaml and haskell are very similar
<mattam_> haskell has type classes
<mattam_> but no modules and functors
<CosmicRay> haskell does have modules
<mattam_> yeah, but not module types
<mattam_> ie: not the same as ML
<CosmicRay> ah
<mattam_> CosmicRay: once you read and use monads for io, you'll like unpureness :)
<CosmicRay> actually one of my largest complaints about ocaml is I/O
<bk_> :-)
<CosmicRay> it's is nice that Haskell lists are essentially OCaml Lists and Streams all rolled into one
<mattam_> huh ?
<CosmicRay> or, put another way, more like Python
mattam has quit [Read error: 110 (Connection timed out)]
<mattam_> yeah, but it has it's drawbacks too (space leaks)
mattam_ is now known as mattam
cjohnson has quit [Read error: 60 (Operation timed out)]
mrsolo_ has quit [Read error: 110 (Connection timed out)]
cjohnson has joined #ocaml
cjohnson has quit [Read error: 60 (Operation timed out)]
cjohnson has joined #ocaml
karryall has joined #ocaml
Lemmih has quit [Read error: 60 (Operation timed out)]
magnus has joined #ocaml
Lemmih has joined #ocaml
<mayhem> hi, I'm reading web.yl.is.s.u-tokyo.ac.jp/~affeldt/study/abstract_machines.ps, can someone explain what @ means on page 5 ?
<Riastradh> (@) is OCaml's list appending operator.
<mayhem> I'm not sure that it means exactly this in thatp age
<buggs> mayhem, it says it's a control
<mayhem> buggs: what is it exactly ?
<mayhem> I'm not really familiar with that
<mayhem> the rest is the stuff is ok, but controls, I dont know
<mayhem> s/is/of/
rox has quit [Read error: 104 (Connection reset by peer)]
cjohnson has quit [Connection timed out]
cjohnson has joined #ocaml
cjohnson has quit [Read error: 60 (Operation timed out)]
cjohnson has joined #ocaml
<buggs> you could read the @ as call or apply
sundeep has joined #ocaml
rox has joined #ocaml
<buggs> i think it's more common to call C Code instead of Control like he does
<mayhem> <- too stupid, dont understand
Barrett has quit [Remote closed the connection]
<buggs> 1 2 @ +
<buggs> result 3
Lemmih has quit ["Leaving"]
<mayhem> doh, what is the interest of such an addition of @
<mayhem> 1 2 + isnt explicit enough ?
maihem has quit ["Read error: 54 (Connection reset by chocolate)"]
rox has quit [Remote closed the connection]
CosmicRay has quit ["Client exiting"]
rox has joined #ocaml
Lemmih has joined #ocaml
bk_ has quit ["Leaving IRC - dircproxy 1.1.0"]
<cDlm> paren-mode does not show matching () in tuareg here, is it a feature ?
monotonom has quit ["Don't talk to those who talk to themselves."]
rox has quit ["Client exiting"]
rox has joined #ocaml
smimou has quit ["?"]
cjohnson has quit [Connection timed out]
mattam_ has joined #ocaml
Lemmih has quit [calvino.freenode.net irc.freenode.net]
magnus has quit [calvino.freenode.net irc.freenode.net]
mattam has quit [calvino.freenode.net irc.freenode.net]
vezenchio has quit [calvino.freenode.net irc.freenode.net]
Herrchen has quit [calvino.freenode.net irc.freenode.net]
Demitar has quit [calvino.freenode.net irc.freenode.net]
cjohnson has joined #ocaml
Herrchen has joined #ocaml
Demitar has joined #ocaml
Lemmih has joined #ocaml
sanxiyn has quit ["Leaving"]