mfurr changed the topic of #ocaml to: OCaml 3.08.2 available! | Archive of Caml Weekly News: http://sardes.inrialpes.fr/~aschmitt/cwn/ | A tutorial: http://merjis.com/richj/computers/ocaml/tutorial/ | A free book: http://cristal.inria.fr/~remy/cours/appsem/ | Mailing List: http://caml.inria.fr/bin/wilma/caml-list/ | Cookbook: http://pleac.sourceforge.net/
pflanze has quit ["[x]chat"]
kinners has joined #ocaml
gim has quit ["zzzz"]
m3ga has joined #ocaml
mattam has quit [Read error: 110 (Connection timed out)]
oberke has joined #ocaml
<oberke> hello all
<oberke> anyone cares to test my http server for ara (for searching debian packages) at http://congruence.net1.nerim.net/search ?
<m3ga> seems to work for me
<vincenz> yip
<oberke> well thanks ;)
<oberke> (you can do boolean etc. queries)
<oberke> m3ga: what's wrong with the url ?
<vincenz> oberke: what's it written in?
<oberke> oh ocaml of course
<vincenz> the entire webserver?
<oberke> yep
<m3ga> sorry, thought you were *asking* if it can do boolean, then realised that you posted it :-)
<oberke> well it's a pretty simple http server
<oberke> m3ga: hehe ;)
<vincenz> oberke: you reuse the http server code from the humps
<vincenz> ?
<oberke> nope
<oberke> i had some leftover http code
<vincenz> you use fork?
<oberke> threads
* vincenz nods
<oberke> str is not reentrant and i use it for searching
<oberke> so unless i recode most of the stuff...
<vincenz> but don't threads need reentrant codetoo?
<vincenz> s/codetoo/code too
<oberke> well yes :)
<vincenz> so..?!?
<oberke> so it's buggy !!!
<oberke> actually i was thinking of mutexing calls to str
<oberke> but i'm gonna replace it with pcre anyway
* vincenz shivers
<oberke> meanwhile, while the load is low... it should work ;)
<vincenz> hehe
<vincenz> that's VERY iffy
<vincenz> why not use string?
<oberke> well well
<vincenz> or do you need complexm atches?
<oberke> seems to work...
<oberke> in fact no
<vincenz> oberke: until two people make two calls at the as me time
<oberke> i don't know where exactly it isn't reentrant
<vincenz> oberke: str stores it's last match somewhere
<oberke> vincenz: yes but i don't care, i just want to know if it matches
<oberke> vincenz: string ? i'm looking for regexes
<vincenz> ah
<oberke> well the user does
<vincenz> I fali to see why they didn't make the str return all the needed info
<vincenz> o.O
<vincenz> as a type t
<Excedrin> is it "bad" to do it single threaded and use select?
<vincenz> would've solved the reentrancy proble
<oberke> well i complained about that a long time ago and xavier said that it was "a thorn in his feet" or somesucj
<vincenz> Excedrin: no
<vincenz> Excedrin: in fact for many things it's quite good, solves you thread-headaches
<oberke> exedrin: no but it's a pain in the ass
<vincenz> oberke: not really
<vincenz> I made a framework for that, quite cute
<oberke> vincenz: well i need to be multithreaded any way
<oberke> i wouldn't want one long search to stall other searches
<vincenz> oberke: right
<vincenz> but for muds, select is better
<vincenz> cause otherwise you need to mutex no the world
<vincenz> s/no/on
<oberke> you do muds in caml ? :)
<vincenz> not yet
<vincenz> I was halfthinking it
<vincenz> but I thinking making a system from scratch
<oberke> hehe...
<vincenz> (especially a balanced system)
<oberke> well why don't you do a decent mailclient ? mutt sucks imho
<vincenz> it's not appealing
<Excedrin> there's some sml code to build threads and a scheduler using continuations, seems like that would solve the long running search problem
<vincenz> or simply make str reentrant :P
<oberke> excedrin: well we don't have continuations yet do we ?
<Excedrin> that too
<vincenz> don't continuations mess up the typing system?
<oberke> vincenz: yes but that would break the api
<Excedrin> wait, I thought ocaml did have continuations?
<Riastradh> Nope.
<vincenz> oberke: well...sometimes you gotta break eggs
<vincenz> call it something new and make str deprec
kinners has quit [Read error: 110 (Connection timed out)]
<oberke> vincenz: hmm well regex sound fine to me
<oberke> they could also put a tree representation for regexes, so we don't have to use dirty strings for program-generated regexes
<vincenz> ?
<oberke> Concat(Star(String "shit"),Or(String "toto",String "bar")) etc.
<vincenz> why don't they add the ocaml-lib (extlib) to the std distro?
<vincenz> oberke: sounds like more of a hassle than anything
<oberke> vincenz: could be useful
<vincenz> oberke: for what?
<vincenz> (just curious)
<oberke> vincenz: of course we keep parsing from strings, it's just that you can get the syntax tree of a regex
mfurr has joined #ocaml
<vincenz> and do what with it?
<oberke> or a regex from the syntax tree. i don't know, if you have to build a regex, you won't have to quote lots of stuff
* vincenz thinks that
<vincenz> type a' option_special = None | One of a' | Some of a' list is useful
<oberke> if you build a regex without quoting user-supplied strings, you'll run into trouble if there are special chars in the string
<vincenz> oh right
<oberke> vincenz : well yep but make it [`None|`One of 'a|`Some of 'a list] coz' we still need 'a option :)
<vincenz> yah
<Nutssh> vincenz, they answered it somewhere.. They want the standard library to be just whats needed for the compiler. They also want to reserve the right to relicense the compiler as closed source.
<vincenz> Nutssh: ah I see
<vincenz> oberke: Yeah, though...I never got that ` thingy
<oberke> nutssh: what ? closed source ??
<vincenz> it's something about an opentype
<oberke> vincenz: well you can use the same ` contsructor more than once
<oberke> type fruit = [`Apple|`Banana] and stuff = [`Apple|`Mouse];;
<vincenz> how does it know which to match?
<vincenz> nm
<oberke> well it doesn't, you get types like [> `Apple ] which means any type which contains `Apple
<vincenz> hmm hmm
<vincenz> basically you can expand
<oberke> plus, you don't have to fully qualify these open types if they are defined in a module
<oberke> ie instead of GMisc.Stuff.Tags.Bold you just type `Bold
<vincenz> what happens if you call a func with `Orange?
<oberke> they are like symbols in scheme
<vincenz> exception?
<oberke> vincenz : you can't ;)
<vincenz> o.O
<vincenz> sure you can
<oberke> won't compile
<oberke> or you get a match failure
<vincenz> type somethingelse = [`Apple | `Orange];
<oberke> wait..
<vincenz> so basically, the plus side, open types, the down side some of it is moved to runtime
<oberke> # let f = function `Orange -> true;;
<oberke> val f : [ `Orange ] -> bool = <fun>
<oberke> # f `Apple;;
<oberke> This expression has type [> `Apple ] but is here used with type [ `Orange ]
<vincenz> with a possible exception
<mfurr> vincenz: no, its still completely statically typed
<oberke> well no you don't get a match failure, it detects it
<Nutssh> oberke, the copyright holder can release with any license they want, even more than one at a time. (For instance, mysql.)
<vincenz> mfurr: euhm
<vincenz> module 1: type applespears, functionapplepears
<mfurr> consder let f = function | `A -> true | `B -> false
<vincenz> module 2: type appleoranges
<mfurr> f `C is a type error
<vincenz> module3:callfunctionmodule1 with module2
m3ga has left #ocaml []
<Nutssh> oberke: Try let f = function `Orange -> true | _ -> false;;
<Nutssh> Then f will accept an open type.. Eg, f `Apple
<vincenz> mfurr: are you sure it's a solveable prob?
<vincenz> I mean, can what happens at runtime be completely analyzed at compiletime?
<vincenz> seems like a strong claim
<oberke> vincenz: it's not what happens, it's just a finite representation thereof
<oberke> the real downside is that if you have complicated open types, the type errors the compiler prints can be several pages long and quite incomprehensible
<vincenz> so what's the limitation?
<mfurr> if you have "let f = `Orange -> true | _ -> false"
<mfurr> and then type
<mfurr> f `Oragne, it won't pick up that its an error
<vincenz> I mean why not use these by default?
<Nutssh> vincenz, with variant types [`A `B], it can identify if a match failure can happen by tracking which constructors a function can legitimately accept without a match failure (which, with 'match x with _ -> ...') could be all of them. And a conservative approximation of which constructors it may return. All statically at compile time.
<mfurr> to quote the manual: "After seeing the power of polymorphic variants, one may wonder why they were added to core language variants, rather than replacing them.
<mfurr> The answer is two fold. One first aspect is that while being pretty efficient, the lack of static type information allows for less optimizations, and makes polymorphic variants slightly heavier than core language ones. However noticeable differences would only appear on huge data structures."
<vincenz> thnx :)
* Nutssh bows to mfurr.
<oberke> classes + polymorphic recursive variant types give absolutely awful type errors !
<oberke> i mean, it's totally insane and undebuggable.
<vincenz> o.O
* vincenz learns a new sytnax
<vincenz> #
<mfurr> oberke: In those situations, I find manually adding the type declarations /very/ helpful
<oberke> mfurr: well except that they tend to be quite big !!!
<mfurr> cut & paste :)
<oberke> < method1: [> `Stuff of 'a | `Foo | `Bar of 'a ] as 'a > -> etc...
<Nutssh> I've never used variant types in a program I've written.
<mfurr> The toplevel is useful in that respect
<Riastradh> Nutssh, never used variant types? I believe you mean _polymorphic_ variant types.
<oberke> mfurr: what good is the toplevel when you can't even load your code due to such a type error ?
<mfurr> load a part at a time?
<oberke> mfurr: yep with lots of modules, you have to extract code by hand
<Nutssh> I think we use different nomenclature. I distinguish between 'sum types' and 'variant types'.. Ocaml uses 'variant types' and 'polymorphic variant types'?
<vincenz> are polymorphic variant types oftne used?
<oberke> vincenz: gtk/gtk2 relies heavily on them
<mfurr> Nutssh: yes. Sums are often called "variants"
<oberke> (i mean lablgtk)
<mfurr> they are really useful when you need to build up data structures across modules
<mfurr> or any place you need subtyping on sums
<vincenz> hmm
<vincenz> can methods return polymorphic variant types?
<vincenz> (or get them as params?)
<Nutssh> They're also something that is really easy to overuse and blow up in your face. :(
<mfurr> yes, they are just like any other type
<vincenz> mfurr: not sure, methods have more restrictions
<vincenz> method x = x
<vincenz> is not allowed unless you define the type of x
<vincenz> (constrain)
<mfurr> let o = object method get = `A end;;
<mfurr> val o : < get : [> `A ] > = <obj>
<vincenz> aha
<vincenz> oki
<Nutssh> It is allowed. 'object method get x = x end'
<vincenz> odd
<Nutssh> It doesn't do what you think... See the oo section of the ocaml manual.
<vincenz> but euhm
<vincenz> for classes...
<vincenz> right
<vincenz> as long as it's nameless it's fine
<Nutssh> You probably meant 'object method get : ('a. 'a -> 'a) = fun x -> x '
<Nutssh> Section 3.11
<oberke> ok here's a challenge : does anyone know of a way to get the pagesize of the system in ocaml ?
<oberke> even a standard system command would do...
<oberke> or digging in /proc for that matter
<Nutssh> In classes, if you want universally quantified types for classes or methods, aka "FORALL_'a 'a -> 'a" which is what "'a -> 'a" expands to, you have to state the quantifications explicitly with either ['a] in the class, or ('a. ...) in the method.
* vincenz can't find the section that exlpains why nameless classes can be polymorphic
<mfurr> oberke: write an C wrapper for getpagesize(2) ?
<oberke> mfurr: well that's what i was trying to avoid precisely
<Nutssh> ['a] in the class creates a class thats universally quantified in a type 'a, ('b. ...) for a method that should be universally quantified on the types of one of its arguments.
<Nutssh> oberke, what do you need it for?
<mfurr> oberke: then you probably won't be able to in a cross platform manner
<oberke> nutssh: telling the rsz/vsz of the process
<oberke> no it will run under debian linux
<oberke> it's for ara to tell how much memory it uses (Gc.stats doesn't work under native) #memory
<vincenz> Nutssh: with that syntax .a...
<Nutssh> I thought those weremeasured in kilobytes?
<vincenz> Nutssh: does it generate a new method for each type?
<vincenz> (kinda like templates in c++)
<oberke> nutssh: no pages
<Nutssh> Doh. :(
<oberke> nutssh: 4k on i386, 8 or 16k on arm, etc...
<Nutssh> vincenz: 'Creating a new method for each type' is an implementation issue in the compiler.
* vincenz nods
<vincenz> just curious
<vincenz> Nutssh: why do nameless objects not have that problem?
<Nutssh> Read section 3 very closely. Its tricky.
<vincenz> I mean objects not inside a class
* vincenz can't find the section :/
<Nutssh> Ocaml reference manual.
<mfurr> vincenz: its because the universal quantifier is hoisted to the class level, so any unification will constrain any future usage
<Nutssh> My guess is that type inference can handle unconstrained types in normal non-oo code by universally quantifying over them.. But in the more complicated OO tyep system, it can't reason that automatically.
<mfurr> thus, in the anonymous case, the quantifier is already at the outermost level
<Nutssh> mfurr, good idea, but it doesn't work either. You have to explicitly tell it that a class is universally quantified over some type variable.
* vincenz needs to read his new pierce books on types
<vincenz> is it possible to constrain modules not to use system-functions?
<vincenz> the problem is that even pervasives contains stuff to access files
<vincenz> (if one wanted to make a framework with drop-in dynlinkable modules)
<vincenz> I guess one could make a subset of Pervasives call Pervasives, but leave out io
<vincenz> and then limit access to only that module
<Nutssh> mfurr: could you elaborate on that explanation?
* vincenz goes to bed
<vincenz> feel free to answer post-sleep
<vincenz> my irc remains open
* vincenz waves
<mfurr> so Ocaml only allows (inferred) universal quantifiers at the outer most level...
<mfurr> so, as you point out: class foo = object method get x = x end;;
<mfurr> vies
<mfurr> gives
<mfurr> Some type variables are unbound in this type:
<mfurr> class foo : object method get : 'a -> 'a end
<mfurr> The method get has type 'a -> 'a where 'a is unbound
<Nutssh> Ok, But why do named objects require it exlicitly but anonymous ones don't?
<Nutssh> And in that the 'a is bound at the class level.
<mfurr> (I think) because the quantifiers are hoisted to the 'object' level in the anonymous case
<mfurr> thus when you try to bind an object to class, you need to specify the quantifier explicitly
<mfurr> Its the same reasoning as to why you must list the quantifiers in a record type as well
<Nutssh> Oh, I see it.. Yes... class foo = object .... end The ''object .... end'' creates is of a paramaterized type, paramatarized by any open type variables in the definition. If you want to bind it to a name, that name must also be paramaterized. Like " type 'a option = None | Some of 'a "
<mfurr> right
<Nutssh> Gotit.
<oberke> i know there's a camlp4 module for it, but I miss local opens for modules a lot
<oberke> what do you think ?
<mfurr> you can use local module binding to make things easier... let module M = LongerModulename in M.foo
<oberke> yes i do that
<oberke> but why can't we have that syntactic sugar ?
<oberke> a trick would be open module X in stuff -> let module T = struct open X let z = stuff end in T.z ...
* mfurr shrugs
* oberke hesitates between going to bed and getting up at 7 or not going to bed and getting up at 7
Messenjah has quit ["damn the man"]
oberke has quit ["bed wins"]
mfurr has quit ["Client exiting"]
srv has quit [Read error: 104 (Connection reset by peer)]
srv has joined #ocaml
Hanji has quit [Remote closed the connection]
crazyDude has joined #ocaml
monochrom has quit ["hello"]
<crazyDude> hello folks, is this the ML forum?
Hanji has joined #ocaml
<crazyDude> hm, where is everyone?
<avlondono> yep, there is people. there are some guys here that seem to know ml quite well.
monochrom has joined #ocaml
* avlondono isn't active in this channel though
<avlondono> so I really don't know why am I answering ;-)
<crazyDude> i need to write an function called alternating sum that takes a list of integer and find the sum
<crazyDude> for example [a1,a2,a3,a4], the alternating sum is a1-a2+a3-a4
<crazyDude> I would like to figure the answer on my own. can anyone give me some tips?
jason_ has joined #ocaml
jason_ has quit [Client Quit]
CosmicRay has joined #ocaml
zzorn_away has quit ["........"]
monochrom has quit ["hello"]
CosmicRay has quit ["Client exiting"]
vezenchio has quit ["\o/ python _o--|_"]
budjet has joined #ocaml
budjet has quit [Remote closed the connection]
crazyDude has quit ["Leaving"]
<mrsolo_> crazy: mathmatical induction and reduce
monochrom has joined #ocaml
budjet has joined #ocaml
judge has joined #ocaml
budjet has quit [Remote closed the connection]
<judge> what's the proper way to turn a string into a list of chars
<judge> sml has an explode function
<judge> so far i found a way to do it using Stream
<judge> but is there a more direct way?
<ayrnieu> ask google about 'ocaml explode'
<mrsolo_> you are everywhere!
<ayrnieu> mrsolo - well, /whois suggests that you attend a couple of channels I don't plan on joining =)
<mrsolo_> i suspect as much, emacs users carry pitchfolks
monochrom has quit ["hello"]
mlh has joined #ocaml
jason_ has joined #ocaml
<jason_> Hm.. Does anybody here know a bit about lablgtk?
<jason_> Like.. The main loop takes over my entire program's execution.
<jason_> I have another set of code that's supposed to be running in another thread.
<jason_> But, for some reason the main loop even though it's in another thread locks up the entire program.
<jason_> Do I have to specifically compile for pthreads or something?
<Nutssh> jason_, ocaml doesn't use pthreads, but you do have to compile with threads.
pango has quit ["Client exiting"]
_fab has quit [Remote closed the connection]
pango has joined #ocaml
srv_ has joined #ocaml
hangman4 has quit [Connection timed out]
hangman4 has joined #ocaml
Hadaka has quit [Read error: 60 (Operation timed out)]
mrsolo_ has quit [Read error: 104 (Connection reset by peer)]
mrsolo_ has joined #ocaml
srv has quit [Read error: 110 (Connection timed out)]
<jason_> Nutssh: What if I want to use system threads though
<jason_> ?
<jason_> The problem, I think, is the main gtk thread is a system thread.
<Nutssh> There may be system threads, but they all block on a single lock around the heap. Multiple threads can't run ocaml code at the same time.
<Nutssh> See -thread and the thread-related information in the manual.
<jason_> Hm.
<jason_> So, I can't run any blocking code?
<jason_> Or what?
<jason_> In a thread I mean?
<jason_> What I'm trying to do is make a GTK visual interface to an underlying socket-based program.
<jason_> And, the program blocks on read and writes etc..
<jason_> So, I want it to display text as it reads it into the GTK window.
<Nutssh> You need to do -thread in the compile, and pay attention to locking issues. GTK calls can only be made from one thread.
<jason_> Hm.
<jason_> Yeah, I'm doing the -thread thing.
<jason_> I'm actually just running the two independantly at the moment.
<jason_> So, they're both in the same .ml file, but two separate expressions, one being run in a Thread.
<jason_> And, the GTK process just blocks off my socket reading process erradicly.
<jason_> Like, some input will get through.
<jason_> Mostly if I generate GTK events for some reason.
<jason_> Like, if i push the button over and over again, I get thread time in the other thread.
<jason_> I've gotta sleep though, I'll play with this more tommorow.
<jason_> Thanks for your help :)
jason_ has quit [Remote closed the connection]
<Nutssh> Night.
Submarine has joined #ocaml
rossberg__ has quit ["Leaving"]
rossberg__ has joined #ocaml
rossberg__ has quit [Client Quit]
zzorn has joined #ocaml
Hanji has quit [tolkien.freenode.net irc.freenode.net]
smimou has joined #ocaml
Hanji has joined #ocaml
gim has joined #ocaml
Bottomlesspit has joined #ocaml
Lemmih has joined #ocaml
mlh has quit [Client Quit]
mattam has joined #ocaml
Demitar has quit [Remote closed the connection]
vezenchio has joined #ocaml
dobrek has joined #ocaml
rossberg has joined #ocaml
avlondono has quit [Read error: 110 (Connection timed out)]
mrvn_ is now known as mrvn
Bottomlesspit has quit ["damn the man"]
CosmicRay has joined #ocaml
avlondono has joined #ocaml
lmbdwar has joined #ocaml
<lmbdwar> lo
lmbdwar has left #ocaml []
Demitar has joined #ocaml
Naked has joined #ocaml
Naked has quit [Client Quit]
Naked has joined #ocaml
Naked is now known as Hadaka
Lemmih has quit ["Haskell - www.haskell.org"]
det has quit [Read error: 60 (Operation timed out)]
Submarine has quit ["Leaving"]
det has joined #ocaml
dr|3 has joined #ocaml
<dr|3> lolo..some tongue in cheek amusement for y'all. http://xplite.r0gue.net and http://bms.r0gue.net
<mrvn> dr|3: consider taking an english class
<dr|3> ok
<dr|3> considered it. and found it a superfluous option.
<mrvn> dr|3: you go cave back
<mrvn> (for thos that haven't looked at the urls that was about the same language skill level)
<dr|3> ok
<dr|3> haha. fuck you. haha.
_fab has joined #ocaml
<mellum> lololol!!1!eleven!
Submarine has joined #ocaml
<dr|3> :P
CosmicRay has quit [Remote closed the connection]
CosmicRay has joined #ocaml
tautologico has joined #ocaml
Submarine has quit [Remote closed the connection]
Submarine has joined #ocaml
<oracle1> I added a new variable to the CIL type varinfo
<oracle1> now If i set this variable to true in one function and give this variable as argument to another function N
<oracle1> then it's not set to true anymore when examining the formals of N
<oracle1> how can this happen? a varinfo of an expression stays the same varinfo, also for function calls..
<Submarine> this is funny
<Submarine> #ocaml is now a CIL help channel :-)
<oracle1> i know i know
<oracle1> :)
<oracle1> should I have asked if i can ask a question about CIL? heh
<oracle1> i know that here are people working with/on cil. and it's written in ocaml. you can't say anything :>
<Submarine> I know too.
<Submarine> it just feels funny
<oracle1> why? is it not only me asking for help for cil?
<Submarine> I think so.
<Submarine> I see often discussions about CIL here.
<oracle1> ok
<oracle1> I mean this is strange. If i give a global variable to a function as argument. then its in that function still a global variable
<oracle1> so it keeps its varinfo
mrvn_ has joined #ocaml
mrvn has quit [Read error: 60 (Operation timed out)]
dobrek has quit ["leaving"]
<oracle1> is it due to setFormals?
<oracle1> does setFormals copy some 'attributes' of a varinfo for function calls?
<tautologico> good ocaml lib for xml ?
tautologico has quit []
Niels|Parents has joined #ocaml
pango has quit ["brb"]
Nutssh has left #ocaml []
smimou has quit ["?"]
pango has joined #ocaml
Hanji has quit [Read error: 104 (Connection reset by peer)]
dr|3 has quit [No route to host]
CosmicRay has quit ["Client exiting"]
Niels|Parents has quit [Read error: 54 (Connection reset by peer)]
Submarine has quit ["Leaving"]
Niels|Parents has joined #ocaml