Yurik changed the topic of #ocaml to: http://icfpcontest.cse.ogi.edu/ -- OCaml wins | http://www.ocaml.org/ | http://caml.inria.fr/oreilly-book/ | http://icfp2002.cs.brown.edu/ | SWIG now supports OCaml| Early releases of OCamlBDB and OCamlGettext are available
thedark-dcc has quit [Read error: 60 (Operation timed out)]
systems has joined #ocaml
mattam has quit ["zZz"]
systems has quit ["Client Exiting"]
travisAWAY is now known as travisbemann
travisbemann is now known as travisAWAY
Smerdyakov has joined #ocaml
_BT has joined #ocaml
travisAWAY is now known as travisbemann
<travisbemann> does anyone know about any bugs in the implementation of Unix.readline which would make it return empty strings in the place of file names?
<travisbemann> whoops
<travisbemann> i meant Unix.readdir
mrvn has joined #ocaml
_BT has quit ["Client Exiting"]
mrvn_ has quit [Read error: 110 (Connection timed out)]
rox has quit [Remote closed the connection]
palomer has quit [Remote closed the connection]
polin8 has quit [Read error: 104 (Connection reset by peer)]
<travisbemann> does anyone know of any residual incompatibilities between the Unix module and multithreading under OCaml code running natively?
palomer has joined #ocaml
polin8 has joined #ocaml
palomer has quit [Remote closed the connection]
Smerdyakov has quit [brunner.freenode.net irc.freenode.net]
mellum has quit [brunner.freenode.net irc.freenode.net]
pattern_ has quit [brunner.freenode.net irc.freenode.net]
Smerdyakov has joined #ocaml
mellum has joined #ocaml
pattern_ has joined #ocaml
jqhjrag has joined #ocaml
jqhjrag has left #ocaml []
<travisbemann> does anyone have any idea why under OCaml 3.06 a unix system call would work in multithreaded bytecode-compiled code but not multithreaded native-compiled code?
foxster has quit [Read error: 104 (Connection reset by peer)]
foxster has joined #ocaml
mattam has joined #ocaml
palomer has joined #ocaml
travisbemann is now known as travisAWAY
Yurik__ is now known as Yurik
foxster has quit []
mattam_ has joined #ocaml
mattam has quit [Read error: 60 (Operation timed out)]
gene9 has joined #ocaml
pattern_ has quit [brunner.freenode.net irc.freenode.net]
mellum has quit [brunner.freenode.net irc.freenode.net]
Smerdyakov has quit [brunner.freenode.net irc.freenode.net]
Smerdyakov has joined #ocaml
mellum has joined #ocaml
pattern_ has joined #ocaml
gene9 has quit []
rox has joined #ocaml
systems has joined #ocaml
<systems> hello
mattam_ is now known as mattam
systems has quit ["Client Exiting"]
polin8 has quit ["Lost terminal"]
Yurik has quit [Read error: 104 (Connection reset by peer)]
polin8 has joined #ocaml
systems has joined #ocaml
<systems> hey, is the ocaml compiler/interpreter etc... written in ocaml or part of it is written in c?
<systems> I remember I read something about it, but I can't find it anymore, I thought it was in the faqs but it isn't!
<mellum> systems: the compiler is written in ocaml. The bytecode interpreter is written in C.
mellum has quit ["ircII EPIC4-1.1.7 -- Are we there yet?"]
karryall has joined #ocaml
systems has quit [Read error: 110 (Connection timed out)]
<pattern_> i am trying to understand the y combinator:
<pattern_> # let rec y f x = f ( y f ) x ;;
<pattern_> val y : (('a -> 'b) -> 'a -> 'b) -> 'a -> 'b = <fun>
<pattern_> what i'm having problems with at the moment is the part of that definition that reads: "( y f )"
<pattern_> doesn't that form an infinate loop?
<pattern_> i mean, i'm used to seeing a terminating case in a recursive function definition
<pattern_> this is so confusing!
mattam has quit [Read error: 110 (Connection timed out)]
<pattern_> ok, now i think i understand...
<pattern_> the terminating case is in f
taw has joined #ocaml
* taw is having troubles with ocaml now
<taw> i had program in single file
<taw> i divided it into a few .ml and .mli files
<taw> and i can't link it now
<taw> Error while linking en.cmo: Reference to undefined global `Unilang'
<taw> unilang.cmi and unilang.mli both exist
<taw> what does that thing mean ?
<taw> (these files contain lot of "open Foo" clauses)
<karryall> taw: is it the compilation or the linking that is failing ?
<taw> hello
<taw> mmm
<taw> linking
<taw> $ make u2
<taw> ocamlc -o u2 de.cmo en.cmo eo.cmo pl.cmo jp.cmo main.cmo
<taw> Error while linking en.cmo: Reference to undefined global `Unilang'
<taw> make: *** [u2] Error 2
<mrvn> Is there something apart from String that I can use to read/write from unix filedescriptors efficiently? Strings are too small for my liking.
<taw> too small ?
<mrvn> A string must be <16 MB.
<taw> hmm
<karryall> taw: where is Unilang defined ?
* taw didn't know that
<taw> karryall: unilang.mli
<taw> that's a module
<taw> not any global
<taw> en.ml:
<taw> open Unilang
<taw> etc.
<karryall> is there a unilang.cmo ?
<taw> of course not
<taw> it's just an interface
<taw> a few typedefs
<taw> only .mli and .cmi
<karryall> hum
<taw> that's ".h file" in terminology of other popular language ;)
<karryall> urk :)
<taw> "urk" ?
<mrvn> If theres an mli there must be a ml file to go along with it.
<taw> whaaaat ?
<karryall> mrvn: no that's not always needed
<taw> using .mli alone worked perfectly in my last ocaml project
<taw> (it was texvc)
<taw> ;)
<karryall> is it in the same directory ?
<mrvn> karryall: here it is cause he gets a linker error
<taw> i don't know why dosn't it work now
<taw> karryall: it's all single directory
<mrvn> taw: some value is declared but not defined in the mli
<taw> project layout is very similar to one of texvc (which worked perfectly), so i don't understand why it doesn't work
<taw> $ cat unilang.mli
<taw> type food_t = Apple | Hamburger | Pizza | Breakfast | Orange
<taw> type drink_t = Beer | Cola | Tea | Coffee | Vodka
<taw> type time_t = Weekday of int | Month of int | NextYear | NextMonth | NextWeek | NextDay | Yesterday | Today
<taw> type place_t = Poland | Germany | Japan | University | Shop
<taw> type color_t = Blue | Yellow | Green | Red | Black | White
<taw> type gizmo_adj_t = New | Old | Big | Small | Color of color_t
<taw> type gizmo_basic_t = Book | Computer | Car | Bicycle | Flower
<taw> type gizmo_t = GizmoBasic of gizmo_basic_t | GizmoComplex of (gizmo_adj_t * gizmo_basic_t)
<taw> type person_adj_t = Young | Happy | Sad
<taw> type person_t = Man | Woman | Kid | Girl | Boy
<taw> type gizmo_relation_t = Have | See | Need | Want
<taw> type mode = POSITIVE | NEGATIVE | PAST_POSITIVE | PAST_NEGATIVE
<taw> type sentence_t =
<taw> PERSON_IS of person_t * mode * person_adj_t
<taw> | PERSON_EATS of person_t * mode * food_t
<taw> | PERSON_DRINKS of person_t * mode * drink_t
<taw> | PERSON_TO_BE of person_t * mode * time_t * place_t
<taw> | GIZMO_IS of gizmo_t * mode * gizmo_adj_t
<taw> $
<taw> types only
<karryall> yes
<taw> so, any ideas ?
<karryall> maybe adding a -I . switch could help
gene9 has joined #ocaml
<karryall> mrvn: for your string problem ...
<karryall> mrvn: get a 64 bits computer !
<taw> hehe
mellum has joined #ocaml
<mellum> hi
<taw> hmm
<taw> can i define exceptions in .mli files ?
<mellum> I would think so
<taw> it seems that it causes theproblem
<karryall> taw: could be, yes since exceptions are some kind of values
<taw> ok, seem to work now
<karryall> so, what was the problem ?
<taw> exception defined in .mli file
<taw> ocaml didn't like it
<taw> it wasned .ml for it too
<taw> it wanted .ml for it too
<taw> pretty obscure stuff
<mrvn> karryall: I have, uni doesn't (allways)
<mrvn> exceptions have a Constructor. That code is probably in the *.ml file.
<mrvn> Is there something like __FILE__ and __LINE__ in ocaml?
<mrvn> Using "let position = try match ['a'] with [] -> 0 with Match_failure(_, x, _) -> x-19;;" is a bit akwad.
<taw> that exception was just Foo
<taw> typedef
<taw> nothing magcal
<taw> exception SomeName
<mrvn> exceptions are a bit more complex than type foo = Foo
TimFreeman has joined #ocaml
<karryall> mrvn: about big strings you can use Bigarrays
<karryall> type t = (char, int8_unsigned_elt, c_layout) Array1.t
<TimFreeman> Any idea how to get the following to compile? It does if I change the 17+3 to a 20:
<TimFreeman> let unc (_, x) = x;;
<TimFreeman> let rec f = (fun x -> x);;
<TimFreeman> let f = (17 + 3, f);;
<TimFreeman> let x1 = (unc f) "a";;
<TimFreeman> let x2 = (unc f) 3;;
<TimFreeman> The problem is that the value f isn't polymorphic enough.
<TimFreeman> The 17+3 is a stand-in for a more complex computation that can't be a compile-time constant.
<taw> why do you do such evil things ?
<TimFreeman> I want to carry some data around with my polymorphic function.
<taw> why let rec ?
<taw> instead of simply let ?
<Smerdyakov> Pairs can't be polymorphic, as far as I know....
<taw> ocaml sometimes does too strict typing with redundand rec
<TimFreeman> Oh. The "rec" is inessential. If I get rid of it, the problem is unchanged.
<Smerdyakov> Or maybe I'm wrong :D
<Smerdyakov> But I think it's dodgy in general.
<TimFreeman> (3, fun x -> x) is polymorphic, but (3+1, fun x -> x) isn't.
<Smerdyakov> Oh, I know why, at least in SML.
<Smerdyakov> The value restriction says that only values may be polymorphic.
<Smerdyakov> Your first example is a value, but not the second.
<TimFreeman> Hmm. Here's something that works in the top level but not the compiler:
<TimFreeman> let unc (_, x) = x;;
<TimFreeman> let f = (fun x -> x);;
<TimFreeman> let q = 17+3;;
<TimFreeman> let f = (q, f);;
<TimFreeman> let x1 = (unc f) "a";;
<TimFreeman> let x2 = (unc f) 3;;
<Smerdyakov> Yes, then your 2nd f binding is a value.
<Smerdyakov> No nontrivial computations are performed
<TimFreeman> Smerdyakov: The compiler doesn't think so, apparently. Could that be a compiler bug?
<Smerdyakov> More likely I was wrong about having variables in values.
<Smerdyakov> SML/NJ works the same way..
<taw> ml type inference system in sml and ocaml is the same
<taw> module modules and objects
<taw> modulo modules and objects ;)
<taw> so kind of typing that's disallowed in one is also disallowed in the other, usually
TachYon26 has joined #ocaml
<taw> i have written short article about that, but that's in polish
<taw> hehe
<TimFreeman> SML/NJ got rid of the weak type variables, I suppose? It's been a long time since I've used it.
<taw> and not very deep
<Smerdyakov> I think you should just find another way of doing this, TimFreeman.
<TimFreeman> Not that weak type variables would help.
sk8` has joined #ocaml
sk8` has left #ocaml []
<TimFreeman> Oops, I forgot to save my file. The code that I said works in the top level but not the compiler actually does work in the compiler.
<TimFreeman> So I suspect I have a workable solution.
<karryall> TimFreeman: how about this :
<karryall> type 'a v = { data : 'a ; func : 'a. 'a -> 'a } ;;
<karryall> let unc r = r.func ;;
taw has left #ocaml []
<karryall> let x = { data = 17; func = fun x -> x } ;;
<karryall> etc
<TimFreeman> Well, this is automatically generated code and I don't want to reimplement type inference to generate the code. The solution with "q" above seems workable and doesn't require me to put any new types in the generated code.
TimFreeman has left #ocaml []
gene9 has quit []
systems has joined #ocaml
systems has quit [Read error: 110 (Connection timed out)]
<palomer> does ocaml have some kind of hook systom like lisp?
<palomer> I mean built in of course
<mrvn> that would do what?
<palomer> it would fit in the imperative style
<palomer> it would combine all the side affects of the hooks
<mrvn> no, what would a hook do?
<palomer> like let a = [ b ; c ; d ];;
<palomer> where b c d are functions
<palomer> well run-hook a ;; would run all three functions
<mrvn> List.iter
<mrvn> List.iter (fun x -> x ()) a
<palomer> ahh, nice
<mrvn> and b, c, d would be fun () -> whatever
<mrvn> whatever having type unit
<mrvn> Thats just plain higher level functions
<mrvn> ocaml has a hook meachanism for when the GC drestroys a value
palomer has quit [Remote closed the connection]
liyang has quit ["leaving"]
liyang has joined #ocaml
TachYon26 has quit ["bez ki³y nie ma zaliczenia (z prawd studentek AM)"]
systems has joined #ocaml
<systems> is there any ocaml web forum , webboard etc...
<mellum> I don't think so. What's wrong with the mailing list or this channel?
<systems> i don't really have questions, but i want to read about other ppls problems with ocaml
<systems> kinda help when you get bored from reading a book or something
<systems> i think mist mailin lists have online archives
<systems> which should i read?
systems has left #ocaml []
mattam has joined #ocaml
Krystof is now known as K_singing
karryall has quit [Ping timeout: 14400 seconds]
taw has joined #ocaml
taw has left #ocaml []
travisAWAY is now known as travisbemann
travisbemann has left #ocaml []
mattam has quit [Read error: 54 (Connection reset by peer)]
taw has joined #ocaml
<taw> i want to read file line by line
<taw> and do something depending on which regular expression matches each line
<taw> like perl -p
<taw> how can i do that ?
<mrvn> use the Regexp module
<taw> and how to iterate line by line ?
<mrvn> read_line
UVJEMRI has joined #ocaml
UVJEMRI has left #ocaml []
taw has left #ocaml []
<mrvn> Anyone know of a datatype that like string and queue in one? I need to cut of chars/strings at the start and add chars/strings at the end.
<mrvn> I don't want to copy the string all the time though.
systems has joined #ocaml
<mrvn> systems: awake?
<systems> yup ?
<mrvn> Anyone know of a datatype that like string and queue in one? I need to cut of chars/strings at the start and add chars/strings at the end.
<mrvn> I don't want to copy the string all the time though.
<mrvn> Why do you have to join right after I ask a question?
<systems> i would still disappoint you, i just started on ocaml 2 or 3 days ago
<systems> :(
<mrvn> too bad.
<systems> what's wrong with regular strings?
<systems> i think they are mutable
<systems> str.[3] <- 'a' ;; but i am not sure
<mrvn> First they are limited to <16M on 32 Bit archs and I don't want to copy 10MB around just to cut off a few chars at the start.
baader has joined #ocaml
<systems> a single string 16 mb ?
<mrvn> Also I have to delete stuff at the start, so I can't use one big string and just remember start and length of a valid substring.
<mrvn> I'm writing an ftp proxy. Its getting data in on one socket and outputs them on another socket. But both are different speeds so I have to buffer the data inbetween.
<systems> i dont know, the only thing i can think of , but don't trust me i am newbie to programming, write the string to a file , and read it piece by piece, then write it again when you are done
<mrvn> Nah, don't wanna do that.
<mrvn> I can use a queue of strings and keep each string reasonable sized.
<mrvn> But that needs some extra work to have the right interface.
systems has quit [Killed (NickServ (Nickname Enforcement))]
systems has joined #ocaml
<systems> got disconnected sorry
<systems> what was did i last say
<mrvn> 00:31 < systems> i dont know, the only thing i can think of , but don't trust
<systems> so was it a stupid idea
<mrvn> I don't want to use files. I might only need to buffer a few K at any time for a GB big file. With a file I would need 1 GB space.
<mrvn> I can use something like a queue of strings.
<systems> they a module called Buffer by the way
<mrvn> Thats only for adding at the end.
<mrvn> It does it by using one string and remembering how much of it is already used.
<systems> so you want to create a program, that reads a string...change few things , write it back
<mrvn> No, reads a string and writes the string at the same time.
<mrvn> The string is realy long and reading/writing takes time.
<mrvn> read a bit, write a bit, read a bit, write a bit
<systems> i scrolled back, and read the socket thing
<mrvn> I have the sockets all set up. They call functions when they have data to be read or space to write data.
<mrvn> I just need to make the read function put the data into some buffer and the write function take some data from the buffer
<systems> okay, did you check the Buffer module ?
<mrvn> that can't cop of chars at the start.
<mrvn> and its limited to 16M
<mrvn> s/cop/chop/
<mrvn> I'm writing my own buffer module now.
<systems> why don't you just , yes , use a list or an array of buffers
<mrvn> I'm mixxing the queue and buffer module.
<systems> hehehe, i was really helpful wasnt i :Pp
<mrvn> not realy but I just asked to make sure there wasn't anything already doing what I need.
<systems> i would totally be the wrong person
<systems> ask rox, rox is usually online and active
<systems> scream rox
<mrvn> if he where he probably would have answered.
<systems> i was jokin about the being helpful thing, i think you didnt get it :(
<mrvn> got it :)
<systems> you didnt laugh >:/
<systems> so most object in ocaml are immutable, you create functions that take paramaters, and return a new object for you, even once of the same type
<systems> that should be the mind set ?
<mellum> systems: yes