cjeris changed the topic of #ocaml to: Discussions about the OCaml programming language | http://caml.inria.fr/
postalchris has quit [Read error: 110 (Connection timed out)]
Smerdyakov has joined #ocaml
mikeX has joined #ocaml
pantsd has quit ["Leaving."]
<twobitsprite> is there any way to implement something like co-routines in ocaml? i.e. continuations, etc?
pantsd has joined #ocaml
<pango_> twobitsprite: continuations
_blackdog has quit [Remote closed the connection]
pantsd has quit ["Leaving."]
benny has joined #ocaml
<twobitsprite> pango_: I don't see anything about continuations in either the docs or the ocaml-tutorial
<pango_> well, rather closures
* twobitsprite scratches head an ponders
<twobitsprite> hmm... maybe a function that returns a result and it's self in a tuple?
<twobitsprite> let count n = let rec counter k () = (k + 1, counter (k + 1))
<twobitsprite> something like that, I guess would work, but is it the best way?
<pango_> it won't work as-is, because counter (k + 1) will be evaluated immediately
<pango_> you need fun () -> counter (k + 1), or similar
<twobitsprite> pango_: well... my definition of counter requires 2 arguments, the latter being ()
<twobitsprite> i.e., it returns a partial application
<pango_> ah, yes
benny_ has quit [Read error: 110 (Connection timed out)]
<twobitsprite> so... is that a good way to go about it, or is there a better way?
<malc_> you are a big optimist if you expect meaningful answer to this question
<twobitsprite> malc_: how so? I'm mostly just asking how this problem is typically solved...
<malc_> what problem? you started with co-routines, which can not be implemented in vanilla ocaml
<twobitsprite> hmm... it seems to me like my solution above should provide some rudimentary support for co-routines...
<twobitsprite> am I missing something?
<malc_> probably
<twobitsprite> malc_: ...
<twobitsprite> malc_: yes, that seems to fit my understanding of the term... what prevents me from having that functionality in ocaml with the approach I outlined above?
<malc_> carrying context around manually which defeats the purpose
romanoffi has joined #ocaml
<twobitsprite> hmm
<malc_> anyhow.. nearly 7am, time to sleep
<twobitsprite> I think I see what you're saying, but I think some functions could be defined which would make that easier...
<twobitsprite> malc_: k, night
<malc_> bye
malc_ has quit ["leaving"]
mikeX has quit ["leaving"]
<mrvn> twobitsprite: You can use CPS to implement this nicely but writing code in CPS form can be tiresome sometimes.
<twobitsprite> mrvn: hmm... I though CPS was very much like what I was doing above...
pantsd has joined #ocaml
<twobitsprite> although, I guess CPS is usually when you pass a continuation _into_ a function, which then calls it to jump back out, right?
<mrvn> similar. You wouldn't use tuples. Instead every cps function would get a continuation (closure) as first argument.
<twobitsprite> right...
<twobitsprite> however, I'm currently stuck on a type error in my current experiment... care to look a couple of lines of code for me?
<mrvn> sure
<twobitsprite> doesn't like line 4
<twobitsprite> says "This expression has type (int * (unit -> 'a)) option but is here used with type 'a"
<mrvn> ocaml -rectypes
<mrvn> If you want to do this without allowing rectypes then you have to define a type for it.
<twobitsprite> I see
<twobitsprite> hmm... but I did that
<mrvn> type 'a cont = 'a * (unit -> 'a cont) option;;
<mrvn> That but somewho so it works without rectype.
<twobitsprite> yeah... I was just about to paste something like that...
<twobitsprite> that's what I have
<twobitsprite> doesn't like that either
_blackdog has joined #ocaml
<pango_> personally I'd use a stream for that: http://nopaste.tshw.de/11789412493829a/
<mrvn> type 'a cont = { data : 'a; fn : unit -> 'a cont; };;
<mrvn> You have to trick ocaml somewhat.
<twobitsprite> pango_: hmm.... doesn't look much different...
<twobitsprite> this works: http://nopaste.tshw.de/1178941451cf3b7/
<pango_> twobitsprite: of course it doesn't look much different, you're reimplementing streams ;)
<twobitsprite> pango_: hmm... I see it the other way arround :P looks to me like streams (in this case) is a reimplementation of a Maybe
postalchris has joined #ocaml
<twobitsprite> mrvn: are those parens around the record necessary?
<mrvn> twobitsprite: probably not
<mrvn> pango_: What do you need for streams to work?
<pango_> camlp4o
<mrvn> how do you start a toplevel?
<pango_> ocaml camlp4o.cma
<mrvn> Thx.
<mrvn> too early in the morning.
<twobitsprite> mrvn: where you at?
<mrvn> germany
<twobitsprite> ahh
<twobitsprite> must be around 5:00 there, eh?
<mrvn> 6
* twobitsprite was close :P
_blackdog has quit [Remote closed the connection]
<pango_> I don't understand what you mean by "reimplementation of Maybe"... Streams are lazy datastructures, like your type 'a cont = { data : 'a; fn : unit -> 'a cont } type
Demitar has joined #ocaml
<twobitsprite> pango_: hmm... I'll have to look more into streams
_blackdog has joined #ocaml
_blackdog has quit [Remote closed the connection]
cmeme has quit ["Client terminated by server"]
cmeme has joined #ocaml
pantsd has quit ["Leaving."]
Smerdyakov has quit ["Leaving"]
<flux> if only streams didn't get destructed while they're being matched, and they'd be the perfect drop-in-replacement for lists in vertain occasions
<pango_> they're functional streams, but they're barely supported in camlp4 3.09... (Hopefully situation will improve with 3.10 ?)
<pango_> s/they're/there are/
<flux> I thought they were bound to get dropped?
<pango_> dunno
pantsd has joined #ocaml
<pango_> mmh yes, what I read in the mailing list was about functional objects, not functional streams...
skal has joined #ocaml
moglum has joined #ocaml
LeCamarade has joined #ocaml
G_ has joined #ocaml
sourcerror has quit [Connection timed out]
G has quit [Connection timed out]
moglum_ has joined #ocaml
<flux> has anyone had experience on generating sql queries the smart way?
<flux> something that would allow composing subqueries etc
<flux> I wrote something (incomplete, clunky syntax) some time ago, and I think it's actually not a trivial problem..
<flux> perhaps I should get some formal specification of the syntax to get a better idea what I'm supposed to be doing :)
<flux> the camlp4-module for statically checking sql queries seemed interesting, but unfortunately it didn't allow composing queries
<flux> I'm thinking some camlp4-module for doing that might still be the way..
<flux> my current version has a syntax like: let client = "client", ["client"; "name"] let site = "site", ["site"; "name"] let host = "host", ["host"; "ip"; "site"; "client"] let info = "info", ["info"; "host"; "message"] (table declarations)
<flux> let g_client = Q.get client let g_host = Q.get host let g_site = Q.get site let g_info = Q.get info (views)
<flux> and finally a query: let client_hosts = Q.select (Q.join g_client g_host) (g_client-|>"client" =| g_host-|>"host")
smimou has joined #ocaml
<flux> the final construction of the sql query isn't quite as elegant as I'd like..
moglum has quit [Read error: 60 (Operation timed out)]
kelaouch1 has quit ["leaving"]
kelaouchi has joined #ocaml
mnemonic has joined #ocaml
<mnemonic> hi
<flux> hello
* pango_ is waiting for a sql database module that would support placeholders
<flux> hmm.. I've used, for quite some time, something like this: query "INSERT INTO foo VALUES (?0, ?1)" [0, Int 32; 1, String "aiee"]
<pango_> other than that, a string is a convenient way to encode a sql query ;)
<flux> and while you can embed other sql queries with Quote (query "..."), it doesn't really given composability yet
<flux> or what kind of placeholders do you mean?
<pango_> composability ? good lock :)
<pango_> s/lock/luck/
<flux> yeah..
<flux> I'll need it
<flux> it's just that I've got tons of things I want to query, and sometimes I'd like to create new queries based on old queries
<pango_> flux: yes, that kind of placeholder... what module supports that ?
<flux> my sql module for postgresql :)
<pango_> nice
<mrvn> Wouldn't it make more sense to have some AST for queries?
<flux> yes
jlouis has quit [Remote closed the connection]
<flux> actually if you look a bit above, there's something I've used, it generates ASTs which are in the final step converted into a query
<mrvn> And you could have references in the AST for placeholders. You change the refrence and then query the AST (convert to string, send)
<flux> but it isn't quite as easy as I'd like
<pango_> btw I prefer INSERT syntax with explicit fields naming: INSERT INTO foo (field1, field2) VALUES (...
<flux> yeah, obviously. dropper for brevity :)
<flux> if not for other reasons, for the one that the primary key is probably a generated default value
<pango_> and then, for readability/maintenability, keeping field names and associated values together is better, imho
<pango_> (I miss some syntax for litteral hash tables at times...)
<flux> there's a camlp4-module that gives that, I think
<flux> the database.ml of one project has 1500 lines in it, mostly queries and wrapping values in/out to/from them
<flux> and it's bound to get larger..
<flux> pango_, you could also create a function that converts list of pairs into a hash table..
<flux> pango_, are you thinking the labels in the query would be hash table indices?
<pango_> that's just one example... maybe I've been using Perl too much recently ;)
<pango_> thanks
<flux> I suppose that's a good example on using camlp4 also
jlouis has joined #ocaml
vital303 has quit ["Leaving."]
ygrek has joined #ocaml
<pango_> (on the other hand in Perl I find myself explicitly building closures to get lexical scoping... I guess I've used OCaml too much ;) )
the_dormant has joined #ocaml
<pango_> (no need to mention, missing the static safety of OCaml, too...)
<flux> last time I did perl I noticed it doesn't do tail-call optimization..
<kelaouchi> any idea about a nice bookmarks manager for Unix ?
the_dormant has quit ["Au revoir"]
m3ga has joined #ocaml
bluestorm_ has joined #ocaml
love-pingoo has joined #ocaml
pstickne_ has joined #ocaml
Submarine has joined #ocaml
steele_ has joined #ocaml
pstickne_ has quit ["Leaving"]
beschmi has quit [Read error: 110 (Connection timed out)]
<ita|zzz> kelaouchi: konqueror has one
ita|zzz is now known as ita
<ita> bluestorm_: boing
<bluestorm_> ?
<kelaouchi> konqueror does ?
<bluestorm_> (does what ?)
G_ is now known as G
<ita> kelaouchi: the bookmarks
<kelaouchi> i had understood ita :P
<kelaouchi> wich way can i get bmktrans (http://www2.lifl.fr/~boulet/softs.html) work on a set of bookmarks file and not on an only one as default does ?
<ita> bluestorm_: where is lasts ?
<bluestorm_> hm
<bluestorm_> dunno
<bluestorm_> he's a night guy usually
<bluestorm_> (hm, generally)
<ita> i have an exxcellent hungrian-enlglish dictionary for you
<bluestorm_> :p
<bluestorm_> so some variable names really were hungrian ?
<ita> bluestorm_: they are all
<bluestorm_> what about "estrangulada" ?
<bluestorm_> (ok, it isn't a variable name actually)
<ita> bluestorm_: where ?
<bluestorm_> con.h
<ita> bluestorm_: semantik 0.2.8 ?
<bluestorm_> 0.2.7
<bluestorm_> aha
<ita> it was a zoo until the refactoring you know
<bluestorm_> :D
<bluestorm_> is see, hungrian refactoring is cool
<bluestorm_> -s
<ita> shame on you for not knowing hungarian notation
<bluestorm_> hm
LeCamarade has quit ["ExitFailure 27"]
slipstream has joined #ocaml
m3ga has quit ["disappearing into the sunset"]
steele_ has quit [Read error: 104 (Connection reset by peer)]
<flux> this might help me in my sql generation quest: http://savage.net.au/SQL/sql-99.bnf.html#query%20specification
mattam has quit [Read error: 145 (Connection timed out)]
mikeX has joined #ocaml
_blackdog has joined #ocaml
bluestorm_ has quit [Read error: 110 (Connection timed out)]
zmdkrbou has quit [Read error: 110 (Connection timed out)]
Submarine has quit [Connection timed out]
Sysop_fb[BOFH] has joined #ocaml
Submarine has joined #ocaml
mattam has joined #ocaml
mattam has quit [Remote closed the connection]
zmdkrbou has joined #ocaml
zmdkrbou has quit [Read error: 104 (Connection reset by peer)]
zmdkrbou has joined #ocaml
zmdkrbou has quit [Read error: 104 (Connection reset by peer)]
mattam has joined #ocaml
zmdkrbou has joined #ocaml
ed-t8 has joined #ocaml
the_dormant has joined #ocaml
pantsd has quit ["Leaving."]
Sysop_fb[BOFH] is now known as Sysop_fb
screwt8 has quit [Remote closed the connection]
screwt8 has joined #ocaml
zmdkrbou has quit [Remote closed the connection]
zmdkrbou has joined #ocaml
noteventime has joined #ocaml
the_dormant has quit []
malune_ has joined #ocaml
the_dormant has joined #ocaml
pango_ has quit [Remote closed the connection]
pango_ has joined #ocaml
malune__ has joined #ocaml
zmdkrbou has quit [Read error: 113 (No route to host)]
ed-t8 has quit [Read error: 110 (Connection timed out)]
malune_ has quit [Read error: 110 (Connection timed out)]
JeffSmac has joined #ocaml
zmdkrbou has joined #ocaml
Smerdyakov has joined #ocaml
<JeffSmac> oooo I just found a bug in labltk
<JeffSmac> I've been wondering why Clipboard.get didn't give a string...
_blackdog has quit ["Ex-Chat"]
_blackdog has joined #ocaml
<JeffSmac> fixed*
JeffSmac has quit []
noteventime has quit [Remote closed the connection]
ita is now known as ita|afk
moglum_ is now known as moglum
ygrek has quit [Remote closed the connection]
Sysop_fb has quit []
pango_ has quit ["I shouldn't really be here - dircproxy 1.0.5"]
the_dormant has quit []
pango has joined #ocaml
descender has quit ["Elegance has the disadvantage that hard work is needed to achieve it and a good education to appreciate it. - E. W. Dijkstra"]
malune_ has joined #ocaml
moconnor has joined #ocaml
<moconnor> In Haskell you can do something like "l@(x::xs)" in a pattern match, where l is equal to the whole list x:xs. How can you do that in OCaml? I saw some Standard ML which was using "(l as (x : xs))" but that doesn't seem to be working for me.
<moconnor> oops, I got the cocat operator backwards between Haskell and OCaml in my above example, but ignore that.
<Smerdyakov> The operand order of 'as' is reversed in OCaml compared to SML.
<moconnor> ahh
<moconnor> Smerdyakov: thanks, that was the problem.
malune__ has quit [Read error: 110 (Connection timed out)]
malune__ has joined #ocaml
ed-t8 has joined #ocaml
<flux> hmm.. where are the ocaml unary operators listed? atleast ~ and ! are ones.
<flux> (that is: which operator characters may be used for custom unary operators..)
<flux> browsing through the operators I can't pick others..
<Smerdyakov> How about the manual section on the language grammar?
<flux> that's what I'm peering
<Smerdyakov> I found it almost instantly.
<flux> oh :)
<flux> thanks. I was looking at 015
<flux> obviously lexing was the more proper page
<flux> (in retrospect atleast :)
<flux> it refers to them as 'prefix symbols' and 'infix symbols'.. I guess prefix symbol is not much different from any normal symbol such as z, except in precedency - prefix symbols are before application
malune__ has quit [Read error: 104 (Connection reset by peer)]
<flux> hmm.. it lists ? as a prefix symbol.. but you can't have a function called ? or ??, but ?+ and ?! are ok
malune_ has quit [Read error: 110 (Connection timed out)]
<flux> ? is listen in operators chars too
<flux> s/ten/ted/
malune_ has joined #ocaml
ita|afk is now known as ita
ed-t8 has quit [Read error: 104 (Connection reset by peer)]
<twobitsprite> where can I find more info on streams? I'm intrigued now, but I'm still not grokking them...
<flux> there's not much there, except the tutorials that come with the documents of the ocaml distribution
<flux> but I take it you've read them
<twobitsprite> yeah... it mostly talks about them briefly in the context of parsing
<flux> I would actually be able to answer some questions if you have some (perhaps, after digging my stream-using-sources atleast..) but I'm going to leave in a few moments
<twobitsprite> I don't have any specific questions... I'd just like to see a good overview of the semantics involved...
<flux> twobitsprite, so you've found the file file:///usr/share/doc/ocaml-doc/camlp4-tutorial.html/tutorial002.html ?
<flux> and related files
* twobitsprite apt-gets the ocaml-doc pkg
<twobitsprite> I see
<twobitsprite> and, are streams general fairly efficient?
<flux> I don't know about that
<ita> twobitsprite: compared to what ?
<twobitsprite> oops... pasted that second one as php code :P
<ita> twobitsprite: what is your intent ?
<twobitsprite> ita: something like pythons generators
<ita> twobitsprite: the answer is "yes"
cjeris has joined #ocaml
<twobitsprite> how do you compile things with streams? I've tried "ocamlopt -I +camlp4 gramlib.cmxa test.ml"
<twobitsprite> gives me a syntax error at "[<>]"
<pango> ocamlopt -pp camlp4o should do
<twobitsprite> hmm... yeah, the streams version looks very similar to my non-streams version, and is only 14 more lines of asm
<twobitsprite> flux, ita: thanks for the educational experience, I think I might be falling in love with streams now that I understand them better
<ita> twobitsprite: heh
ygrek has joined #ocaml
the_dormant has joined #ocaml
the_dormant has quit [Client Quit]
ygrek has quit []
mikeX has quit [Read error: 60 (Operation timed out)]
postalchris has quit [Read error: 110 (Connection timed out)]
ita is now known as ita|afk
moglum has quit []
sourcerror has joined #ocaml
moglum has joined #ocaml
Mr_Awesome has joined #ocaml
dark_light has quit [Connection timed out]
* mbishop reads some more of Ocaml for Scientists
love-pingoo has quit ["Connection reset by pear"]
jlouis_ has joined #ocaml
jlouis has quit [Read error: 104 (Connection reset by peer)]