Banana changed the topic of #ocaml to: OCaml 3.08 "Bastille Day" Release available ! -- 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
monotonom has quit [Read error: 60 (Operation timed out)]
monotonom has joined #ocaml
debona|r has left #ocaml []
debona|r has joined #ocaml
skylan has quit [Remote closed the connection]
skylan has joined #ocaml
debona|r has left #ocaml []
paganini_ has joined #ocaml
paganini_ has left #ocaml []
rjudace has joined #ocaml
<rjudace> Hi all, how do I declare two types that use each other, e.g type a = int * b option ;; type b = a option ;;
<jdrake_> rjudace, you can use 'and' between types
<Smerdyakov> Use 'and' instead of 'type' after the first definition.
<Smerdyakov> You will need to get rid of those ;;. They are rarely needed in programs.
<rjudace> thanks, i was stumped on that one
pattern has quit [Read error: 60 (Operation timed out)]
pattern has joined #ocaml
<jdrake_> any idea why I would get a syntax error when compiling a curses binding on this line: type window
<jdrake_> first line in file
arke has joined #ocaml
<Smerdyakov> What filename extension?
<jdrake_> ml
<arke> Smerdyakov: great! perfect person to ask :)
<Smerdyakov> Is there a definition of window on the line following that?
<jdrake_> no
<arke> Smerdyakov: I need a good ML tutorial, preferably one that isnt Hello, World oriented, if you know what I mean.
<jdrake_> another type definition
<arke> Ocaml, not ML
<arke> :)
<Smerdyakov> You can't just say that a type exists without defining it.
<Smerdyakov> arke, look at the topic.
<arke> ok
<arke> yeah, i looked at that one ... is there a one-page version?
<jdrake_> smerdy, this is what the file looks like: http://rafb.net/paste/results/xOCbPx69.html
<jdrake_> arke, no, just read it
<jdrake_> it almost looks like this file needs to be preprocessed or something
<Smerdyakov> jdrake_, it does.
<arke> ok, thanks :)
arke has left #ocaml []
<Smerdyakov> I don't know why you want to define this 'window' type when you never use it, anyway.
<jdrake_> it is not my code
<jdrake_> it is just a curses binding I downloaded
<jdrake_> it tries to compile it with this: ocamlc.opt -pp cpp -c curses.ml
<Smerdyakov> I don't think I can help you.
<jdrake_> do you know of any curses bindings that I might not have found
<Smerdyakov> No, but calling the C functions directly is trivial, I think.
* Smerdyakov leaves
<jdrake_> thank you for looking
cjohnson has quit [Read error: 104 (Connection reset by peer)]
yauz_ has joined #ocaml
yauz has quit [Read error: 60 (Operation timed out)]
GreyLensman has joined #ocaml
debona|r has joined #ocaml
jdrake_ is now known as jdrake
GreyLensman has quit ["Leaving"]
bk_ has left #ocaml []
debona|r has left #ocaml []
pattern has quit [No route to host]
mrsolo_ has joined #ocaml
tautologico has quit ["Leaving"]
Herrchen_ has joined #ocaml
Herrchen has quit [Read error: 60 (Operation timed out)]
weitzman has quit [Read error: 60 (Operation timed out)]
pattern has joined #ocaml
pattern has quit [Remote closed the connection]
debona|r has joined #ocaml
pattern has joined #ocaml
debona|r has left #ocaml []
monotonom has quit ["Don't talk to those who talk to themselves."]
jdrake has quit [Read error: 110 (Connection timed out)]
<rjudace> join #galax
vezenchio has quit ["all that is necessary for evil to triumph is for good men to do nothing"]
debona|r has joined #ocaml
<debona|r> Can someone explain what this statement actually does?
<debona|r> let compose f g x = f(g x)
<Smerdyakov> We don't have statements in OCaml.
<Smerdyakov> That there is a definition.
<debona|r> nm, I just got it
<debona|r> ok, definition
<debona|r> what's the different between a statement and a definition then?
<Smerdyakov> There are no statements in OCaml. It's just not a meaningful term in this context.
<debona|r> well, what's the computer science difference between the two as far as meaning is concerned?
<Smerdyakov> Statements are something you have in C. They "do something."
<Smerdyakov> Definitions are something you have in C and OCaml. They "define something."
<debona|r> thank you
debona|r has left #ocaml []
maihem has joined #ocaml
maihem has quit [Read error: 54 (Connection reset by peer)]
_fab has joined #ocaml
ita has joined #ocaml
<ita> moin
<Herrchen_> hi
karryall has joined #ocaml
Herrchen_ is now known as Herrchen
<ita> is there a way to get the current time (in milliseconds?)
<ita> (in an ocaml program - not right now :)
<mflux> Unix.gettimeofday ();;
<ita> mflux: thanks
slashvar[ens] is now known as slashvar[lri]
<slashvar[lri]> Yop
cjohnson has joined #ocaml
bk_ has joined #ocaml
<mflux> I wrote a simple 'yield'-implementation (discussed yesterday evening) for ocaml.. it's 140% slower compared to the version that does things more directly
<mflux> it uses threads. and that number is with -vmthreads, with -threads it's slower
<mflux> and as a bonus, if you don't finish the enumeration, it's likely to leave a stray thread behind ;)
cjohnson has quit [Read error: 110 (Connection timed out)]
cjohnson has joined #ocaml
<det> can't you just return a value/closure pair?
<det> I mean, to enumerate
<mflux> the point was to provide an interface you could use like let e = enumerate ( fun i -> for c = 0 to 10 do yield i c done ) in while true do Printf.printf "%d" (next_value e) done
<mflux> as you can see the given function never leaves the loop to return an answer
<det> mainly to mix with Ocaml's imperiate loop stuff?
<mflux> it doesn't need to be an imperative loop of course
<det> but, it seems easy if you are using recursion instead
* Demitar wonders what mflux is trying to archieve.
<mflux> let's say you have a routine to iterate a binary tree without parent-pointer
<mflux> hmh, well I wonder if that was a good example anyway
<mflux> read the urls from <24 hours ago ;)
<det> at some point you will find the next element and recurse
<det> why not return the element + a thunk instead
<det> is what I mean
<mflux> the most simple implementation of the algorithm would be let rec iterate node = iterate node.left; handle_node_itself node; iterate node.right;, right?
<mflux> how about if you would have to write that without recursion?
<mflux> the point would be to isolate the actual matter of doing stuff from the algorithm of traveling the tree
<det> that's what I am saying
<det> ehh
<det> how would you write that without recursion?
* Demitar wonders what he is missing. Sounds like an "let interate_tree tree func =" or?
cjohnson has quit [Connection timed out]
cjohnson has joined #ocaml
<det> mrsolo_: you are saying that instead of handle_node_itself node, you would yeild node?
<mflux> yes
<mflux> for instance if you had two recursive functions
arnolt_ has quit [Remote closed the connection]
<mflux> for which the first reads the data in a recursive manner and the second writes it in a recursive manner
<mflux> not very simple to formulate that without using a temporary storage (ie. list)
weitzman has joined #ocaml
weitzman has quit [Read error: 60 (Operation timed out)]
jcristau has quit [Nick collision from services.]
weitzman has joined #ocaml
cjohnson has quit [Connection timed out]
cjohnson has joined #ocaml
pac_away has joined #ocaml
CosmicRay has joined #ocaml
jcristau has joined #ocaml
cjohnson has quit [Connection timed out]
cjohnson has joined #ocaml
ita has quit ["leaving"]
jdrake has joined #ocaml
cjohnson has quit [Connection timed out]
cjohnson has joined #ocaml
brian_m has joined #ocaml
maihem has joined #ocaml
weitzman has quit [Read error: 54 (Connection reset by peer)]
weitzman has joined #ocaml
cjohnson has quit [Read error: 110 (Connection timed out)]
cjohnson has joined #ocaml
maihem has quit [Read error: 104 (Connection reset by peer)]
maihem has joined #ocaml
weitzman has quit [Read error: 60 (Operation timed out)]
<jdrake> is there a function that is functionally equivalent to 'getchar' in C?
<Riastradh> input_char
<jcristau> input_char
<jdrake> is there one that doesn't require enter to be pressed?
<Riastradh> You have to tweak the buffering.
<mflux> I suppose Unix-module has the required functions
<mflux> hm, tcsetattr might be sufficient
<mflux> anyway, curses-module for ocaml exists too, albeit the interface library built on top of it is unfinished
<mflux> sourceforge.net has it
<jdrake> i already downloaded that I think, couldn't compile it
<mflux> why not?
<jdrake> one sec
<jdrake> can't find my extraction of it
<mflux> it appears I didn't make any modifications to mine to compile it
<jdrake> is ocaml-tmk the one?
<mflux> yes
<mflux> do you have ocamlc.opt and ocamlopt.opt around?
<jdrake> yes
<jdrake> File "curses.ml", line 1, characters 0-1:
<jdrake> Syntax error
<jdrake> first two lines: type window
<jdrake> type screen
<mflux> uh
<mflux> ocaml version?
<jdrake> 3.08
<mflux> perhaps that's it, as I still have 3.07
<Smerdyakov> mflux, that code shouldn't work in any OCaml version that I know of.
<Smerdyakov> mflux, it begins a .ml file with 'type window,' without giving a definition for that type.
brian_m has quit [Client Quit]
<mflux> smerdyakov, are you familiar with how to link ocaml programs with c-libraries?
<mflux> as I think it is a trick like that used to have a type you cannot construct
<mflux> that is, an opaque type you receive from c-library functions and you may pass back
brian_m has joined #ocaml
<mflux> and it does work with 3.07
<Smerdyakov> mflux, how odd. It does work in 3.07.
<mflux> maybe they've changed the definition to something else
<mflux> removing the feature alltogether doesn't seem like a smart move
<jdrake> i might as well just making a binding to the function I want, if I can figure it out
<mflux> release notes doesn't seem to mention it
weitzman has joined #ocaml
<jdrake> do you guys know of an example that is extremely simple on dynamically linking a C library for ocaml?
<mflux> well, curses isn't complex ;)
<mflux> but apparently the example doesn't quite cut it for you ;)
<jdrake> that curses thing doesn't even compile
<jdrake> i am not about to use it
<karryall> jdrake: there are tons of them in the hump
<jdrake> i will look there then
vezenchio has joined #ocaml
<mflux> atleast ocaml-sdl uses the same syntax
cjohnson has quit [Read error: 110 (Connection timed out)]
cjohnson has joined #ocaml
brian_m has quit [Client Quit]
<mflux> ..and atleast debian doesn't have a version for 3.08 yet..
<karryall> mflux: hum ? what syntax ?
<mflux> 'type foo'
<karryall> yeah ?
<mflux> doesn't compile with 3.08
<karryall> it's an abstract type
<karryall> arf
<karryall> of course it does
<mflux> it does?
<karryall> yes
<mflux> jdrake had some trouble with it
<mflux> I don't have 3.08 myself though
<jdrake> heh, i upgraded as soon as I found out about it
<mflux> where is that documented anyway? the BNF does display that that form is possible of course
<mflux> oh, it's right next to the bnf ;)
<mflux> I wonder what's jdrake's problem in that case anyway
<mflux> so did the definition fail to work with smerdyakov or not?-o
<karryall> "Abstract type: no equation, no representation." ...
<mflux> smerdyakov didn't actually say so but implied it
pac_away has left #ocaml []
brian_m has joined #ocaml
brian_m has quit [Client Quit]
mrsolo_ has quit [Read error: 60 (Operation timed out)]
Imbroglio has joined #ocaml
shawn has quit [Read error: 54 (Connection reset by peer)]
shawn has joined #ocaml
monotonom has joined #ocaml
mattam_ has joined #ocaml
<jdrake> what exactly does CAMLparam1 (unit); do exactly?
mattam has quit [Read error: 60 (Operation timed out)]
<karryall> it registers the value unit as a local root for the GC
<karryall> but if it's really unit ie (), that's not really necessary
<jdrake> i am sort of copying what is in the manual for ncurses, and it does that
<karryall> there's no harm in doing it
<jdrake> what happens when I allocate a structure with malloc, which is returned, then in a later function (reset) it becomes useless then. Do I free it there, or does the garbage collector deal with it?
<karryall> you have to call free() youself, yes. The GC won't do it for you.
<jdrake> well the C api doesn't seem to bad so far at least for simple things
<karryall> it's quite usable yes
mattam_ is now known as mattam
<jdrake> how would I raise an End_of_file exception in C
<jdrake> i see the function to actually raise it, but not exactly how that fits together with the other
<jdrake> Callback.register_exception
<karryall> raise_end_of_file()
<jdrake> oh nice, http://caml.inria.fr/ocaml/htmlman/manual032.html didn't mention that one
<karryall> all those builtin exceptions are a bit special, there are not implemented the same way in bytecode and native
<mellum> Doing stuff in C is evil. It can introduce extremely weird bugs. Avoid it at all costs.
<jdrake> mellum, the world is written in C
<jdrake> special interfacing with it is required sometimes
<mellum> jdrake: I meant C as an extension to Ocaml.
<mellum> Though in fact the statement doesn't seem far of otherwise, either.
<jdrake> mellum, i would if you could tell me how to do this in ocaml: http://rafb.net/paste/results/sLGvur51.html
<mellum> jdrake: I don't know.
<mellum> It's buggy as you wrote it, though, which kinda proves my point.
<jdrake> what is buggy about it
<jdrake> because that is just ripping code off of somebody else who did it in C
<mellum> You return a malloced pointer to caml. It might survive there even after the free() call.
<jdrake> mellum, sure it will, but nobody told me any better way to do that when I asked above
<mellum> then the heap border might change, and it will suddenly point into Caml's heap, terminally confusing GC.
<mellum> jdrake: You can allocate an abstract object and put the pointer inside
<mellum> Is there really no API in the Unix module for this stuff?
<jdrake> i didn't see any ioctl stuff
<jdrake> there is termios but I don't exactly know how to do it with that
<karryall> yeah jdrake, read about this in the manual chapter 18.2.3
<jdrake> funny, that is exactly where my browser is
<karryall> it's safer not to use malloc'ed pointers directly
<jdrake> how do I use an Abstract_tag
<karryall> you allocate a block with tag Abstract_tag
<karryall> and then you store stuff in it
<karryall> value b;
<karryall> b = alloc_small (size, Abstract_tag);
<karryall> size is the size of you block in _words_
<mellum> so in this case, 1
<jdrake> ok
<karryall> yes
<karryall> and then
<karryall> Field (b, 0) = (value) your_pointer;
<karryall> to store your pointer in the first (and only) slot of the block
<jdrake> does Field work both ways to retrieve the point
<jdrake> er
<karryall> yes
<jdrake> where is this field macro documented
<karryall> (struct foo*) Field (b, 0)
<jdrake> found it
<jdrake> i am not sure how that assignment you made works then
<karryall> b is a small value array
<karryall> Field (b, 0) is like b[0]
<jdrake> terminal.c:20: warning: implicit declaration of function `caml_alloc_small'
<mellum> #include <caml/alloc.h>
<jdrake> hmm,i wouldhave figured memory
<jdrake> well my thing seems to work
<jdrake> just might be a pain in the ass for if some keys are pressed like f1, which is three characters for some reason
<mellum> jdrake: in this context, that means absolutely nothing.
<mellum> jdrake: I had an application once that would crash after 5 hours of run time because of a bug in the C code.
<jdrake> what was the bug
<Riastradh> C is evil. Minimize the amount of C code you have to deal with.
<jdrake> C is evil yes, witness the code I just wrote, fiddling with ioctl
<mellum> The GC of caml is moving. I had a C pointer to a caml object, and allocated something. If the GC moved the caml object around, it would crash when I dereferenced the pointer.
<mellum> But this only happens extremely rarely, if a major GC is triggered at that very allocation.
<mellum> And even then a reading access might not notice.
<Riastradh> Even ignoring POSIX hideousy, C is evil.
<jdrake> better to use B?
<jdrake> no, APL
<mellum> jdrake: better to use basically anything, IMHO.
<jdrake> hmm
<jdrake> brainf*ck
<jdrake> or pascal, don't know which is worst
<mellum> But one shouldn't underestimate the social factor. Very often, you don't have a choice simply for social reasons
<jdrake> oh yesterday a friend said that sml looks nicer than ocaml, smerdy said something like "that is the general consensus". What do you guys think :-)
<Riastradh> They're both ugly.
<jdrake> that doesn't sound very positive encouragement to actually use them
<Riastradh> Maybe that's why I don't use them.
<jdrake> heh
<jdrake> scheme?
<mellum> Riastradh: then what are you doing on this channel? :)
<Riastradh> Yes.
<Riastradh> mellum, trolling, of course, and raking in potential Schemers!
* Riastradh ducks.
<mellum> Riastradh: Oh. Of course.
<Riastradh> Naturally.
<mellum> Well, I don't like dynamic typing, so Scheme is not for me
<jdrake> Riastradh, one day scheme will be calling me, but I want to make sure I can actually program in ocaml first :p
<monotonom> society be damned. I am anti-social.
<Riastradh> mellum, did you know that there are some Scheme implementations that perform static type analysis?
<mellum> Riastradh: But certainly not comparable to ML's type system with tagged unions and pairs and stuff, right?
<mellum> If they do, then they're not Scheme.
<Riastradh> '...and pairs and stuff?'
<monotonom> Let's say pairs first.
<mellum> Riastradh: you know the ML type system, I suppose, so you probably know what I mean
<Riastradh> What would make Scheme equivalents of ML's variant types, or whatever you want to call them, not Scheme?
<Riastradh> No, I don't know what you mean by the pairs part.
<jdrake> what is a pair
<monotonom> int*string in ocaml
<mellum> Riastradh: the fact that you usually cannot derive these types
<jdrake> that is a tuple
<monotonom> fine, a tuple. how do you express it in scheme?
<Riastradh> You could use vectors or lists or records, monotonom.
kosmikus|away is now known as kosmikus
<Riastradh> mellum, what prevents variant types/tagged unions/whatever from being implemented in Scheme?
<mellum> Riastradh: nothing. But their presence doesn't imply a static type system.
<Riastradh> mellum, when did I say that it did?
<mellum> whatever. I don't believe a scheme with a static type system put on top of it would be useable, even if it is possible.
<monotonom> With the following promises? length (must be 2) is checked statically. type of first component (int) checked statically. type of second component (string) checked statically. anonymous record (if you want to call it a record), i.e., I just write fst x and snd x for the two respective components.
<mellum> But really, I don't think it is. What would the type of "eval" be?
<jdrake> please stop the scheme vs. *ml
<Riastradh> Note that I never stated that there exist Scheme implementations that modify Scheme to have such a fascistly strict static type system as ML; I carefully used the phrase 'perform static type analysis.'
<mellum> Riastradh: Okay, but that's not what I want. I want a fascist strict static type system, and so Scheme is not for me.
<karryall> well being strict about static typing _is_ the point
<karryall> it proves your program is type safe
<monotonom> And I was just curious as to to what extent the static type analysis of those scheme implementations do.
<Riastradh> karryall, static type analysis doesn't _just_ prove type safety of programs.
<monotonom> Sigh I find Riastradh to be overly defensive in tone.
<Riastradh> I started out mostly in jest, monotonom. I must say that if I'm being considered defensive the rest of you seemed to be on the offensive.
<monotonom> I think we have seen so many flame wars on comp.lang.* that we suspect we have similar wars here.
<jdrake> you guys should stop the arguments before they get to this point
<monotonom> I think all of us here actually know better, and whenever a question "can L do X?" is raised, the intention is not to snide L, but to seriously find out, for honestly practical and intellectual purposes, just what is asked: can L do X?
<monotonom> I think we need a charter. 0. Don't start a war. 1. Don't assume other people are starting a war.
<jdrake> any news on what is happening with 'ocaml.org', i saw the post before about the domain transfer and wait a few months
<Riastradh> ocaml.org is sitting dormant.
<Riastradh> That's what's happening with it.
<monotonom> I never noticed a difference.
<jdrake> no mention on 3.08 if you look
<Riastradh> That tends to happen when the object is dormant, monotonom.
<jdrake> i will probably scrap the info it has and make a personal reference page on my own site
<monotonom> Ah, now I understand.
<jdrake> monotonom, and many people would take that site for the ocaml main page, and look - its dead, oops - ocaml must have died, lets move on
<monotonom> Anyway it is recommended that ocaml.org is just a fan site, and the real home page is at http://caml.inria.fr/ocaml/
<jdrake> most of it is just links I use, so i will probably set something later that just has those links
<monotonom> Yes of course the people outside won't know.
<jdrake> which is probably a good reason to have it fixed :-)
<jdrake> they are working on it though
<monotonom> Someone should give ocaml.org back to the Inria people.
<Riastradh> Did INRIA ever own it?
<monotonom> Probably not.
<jdrake> no, but there was a message someone pointed out on the mailing list that there is talk of it being transferred or having been traferred over
CosmicRay has quit ["Client exiting"]
theweitzman has joined #ocaml
weitzman has quit [Nick collision from services.]
theweitzman is now known as weitzman
kosmikus is now known as kosmikus|away
Imbroglio has quit []
mrsolo_ has joined #ocaml
mrsolo_ has quit [Read error: 110 (Connection timed out)]