Alpounet changed the topic of #ocaml to: Discussions about the OCaml programming language | http://caml.inria.fr/ | 3.11.1 out now! Get yours from http://caml.inria.fr/ocaml/release.html
ksson has quit [Read error: 113 (No route to host)]
Pimm has quit [Read error: 54 (Connection reset by peer)]
Pimm has joined #ocaml
Associat0r has quit []
<palomer> (:o
ikaros has quit ["Leave the magic to Houdini"]
kaustuv has joined #ocaml
<kaustuv> Thanks thelema and the rest[1] who are working on the AAA Batteries release. This appears much closer to something I can directly use in my own projects.
<kaustuv> [1] Sorry, I've not been following closely enough to remember who the rest are...
Pimm has quit [Read error: 60 (Operation timed out)]
<mfp> kaustuv: which hurdles do you see left?
alp_ has quit [Read error: 110 (Connection timed out)]
joewilliams has quit [Remote closed the connection]
joewilliams has joined #ocaml
<thieusoai> how do I put a star * in comments ?
<thieusoai> I tried this (* This is a star \* *) but it gives syntax error
<mfp> (* this is a star * *)
<palomer> so...who wants to try a wicked cool library? :P
<palomer> I need testers :o
<mfp> (* This is a star \* *) is also a valid comment btw., not a syntax error
<thieusoai> oic
<mfp> how doesn't? :)
<mfp> s/how/who/
<thieusoai> I was doing (* \*) *) -> gives error :]
<mfp> <- I need sleep :)
<palomer> (* boom (* bada (* boom *) *) bing *) is also a valid comment
<palomer> it'll take 15 seconds!
<palomer> it's really cool!
mbac has quit [Remote closed the connection]
mbac has joined #ocaml
mfp has quit [Read error: 104 (Connection reset by peer)]
kaustuv has quit ["ERC Version 5.3 (IRC client for Emacs)"]
Boney has quit [Remote closed the connection]
aklt has quit [Read error: 110 (Connection timed out)]
Associat0r has joined #ocaml
struktured has quit [Read error: 60 (Operation timed out)]
<Skolem> /quit
Skolem has quit ["Connection reset by pear"]
mfp has joined #ocaml
joewilliams has quit ["Leaving..."]
joewilliams has joined #ocaml
_unK has quit [Remote closed the connection]
<Tianon> palomer: what's it for?
<Tianon> and will it work in the interactive shell? :)
<Tianon> palomer: PM or hilight me if you are still interested in a tester for your library :)
Associat0r has quit []
caligula_ has joined #ocaml
caligula__ has quit [Read error: 104 (Connection reset by peer)]
demitar has quit ["Ex-Chat"]
demitar has joined #ocaml
morse has quit ["Ex-Chat"]
<palomer> oh crum
bogen has joined #ocaml
jjohnson has joined #ocaml
<jjohnson> Hi. I don't have much experience using objects in ocaml and I'm having some troubles. I have a collection class that holds a list of objects, which might be different subclasses of one class. The "add" method coerces the parameter to the common superclass, but I still have to coerce every object into the superclass before passing it into "add". Is there any way to avoid this?
jjohnson has left #ocaml []
bogen has quit [Read error: 60 (Operation timed out)]
fx_ has joined #ocaml
bogen has joined #ocaml
lloydmoore has joined #ocaml
bogen1 has joined #ocaml
bogen has quit [Read error: 110 (Connection timed out)]
bogen1 is now known as bogen
ksson has joined #ocaml
svenl has quit [Read error: 60 (Operation timed out)]
svenl has joined #ocaml
joewilliams has quit ["Leaving..."]
alp_ has joined #ocaml
Pimm has joined #ocaml
bogen1 has joined #ocaml
bogen has quit [Read error: 110 (Connection timed out)]
_zack has joined #ocaml
zhijie has quit [Read error: 54 (Connection reset by peer)]
demitar has quit ["Ex-Chat"]
zhijie has joined #ocaml
palomer has quit [Remote closed the connection]
bogen1 has quit [Read error: 60 (Operation timed out)]
marteo has joined #ocaml
bogen has joined #ocaml
marteo has quit [Remote closed the connection]
bogen has quit [Read error: 60 (Operation timed out)]
bogen has joined #ocaml
ski_ has joined #ocaml
Associat0r has joined #ocaml
_zack has quit ["Leaving."]
Jan_Flanders has joined #ocaml
<Jan_Flanders> Hey orbitz (and others) :)
<Jan_Flanders> I have almost solved my problem of two days ago. I have just one question left:
<Jan_Flanders> http://pastebin.com/m2a6907e9 Is there anyway I can set the reading position on that ch?
Pimm has quit [Read error: 54 (Connection reset by peer)]
<Jan_Flanders> I'm talking about line 19. I want to know the value of the next byte and split up the actions from there on. But since I have to read the to know the value it has been consumed. So I would want to reset the reading position 1 byte back
ikaros has joined #ocaml
<Jan_Flanders> Hmm pos_in and seek_in seem to be doing what I want. Implementing it is something else...
EliasAmaral has joined #ocaml
demitar has joined #ocaml
ua has joined #ocaml
joewilliams has joined #ocaml
struktured has joined #ocaml
joewilliams has quit ["Leaving..."]
struktured has quit [Read error: 60 (Operation timed out)]
struktured has joined #ocaml
tonyg has joined #ocaml
ikaros has quit ["Leave the magic to Houdini"]
<tonyg> i've been using go a bit recently. is there anything that integrates OCaml sockets with the Event module?
<flux> tonyg, unfortunately not. inefficient bridging is possible (if complicated), though, I have some code you could use.
<tonyg> flux, how inefficient is it?
<tonyg> pretty bad?
<flux> I haven't benchmarked it
<tonyg> ok
<flux> but it looks very bad :)
<tonyg> heh
<tonyg> where do you think the problem lies?
<flux> in that Event is difficult to extend
<flux> disclaimer: it has been tested very little
<flux> in any case it could be optimized
<flux> there's a comment suggesting how to do it
<tonyg> hmm ok
<tonyg> that looks interesting
<tonyg> and nicely short :)
<flux> that particular piece of source spawns a thread for each Unix.select..
<tonyg> what do you think of the approach of having one thread driving all the sockets?
<flux> but should work nicely for toys, barring lurking bugs :)
<tonyg> a single select thread
<flux> I think that would be one realistic alternative
<tonyg> the trick (as ever) would be integrating the select with the command channel
<flux> a better one would be to extend the real Event-module to support sockets IO
<tonyg> ah yes
<flux> that would likely be the best performing one
* tonyg looks at the source code
<flux> tonyg, another thing you might want to look at is Lwt 2.0 (2.0, not any earlier version)
<flux> tonyg, it provides similar primitives but it should integrate with sockets more neatly
<flux> but it requires using monads, which you might or might not be comfortable with
<tonyg> hmm
<tonyg> thanks for the tip
<tonyg> i'll take a look
<flux> good luck :)
<tonyg> heh. monadic style looks interesting.
<tonyg> it reminds me of twisted, but with a proper safety net
<Jan_Flanders> I can't get this thing straight. Could someone take a quick look and tell me how this should be done in an intelligent way? http://pastebin.com/mc007ee7
marteo has joined #ocaml
<flux> jan_flanders, I can only think that pos_in and seek_in use different data types. but I'm not familiar with the libs you're using.
<Jan_Flanders> The silly thing is I got it working at some point but can't remember how. But even then it didn't reset the reading position as I was missing a byte in the final output.
<Jan_Flanders> From the docs I read: seek_in chan pos sets the current reading position to pos for channel chan. This works only for regular files. On files of other kinds, the behavior is unspecified.
<Jan_Flanders> What are regular files?
ztfw has joined #ocaml
<Jan_Flanders> let value = read_byte ch in
<Jan_Flanders> let x = seek_in ch pos in_channel
<Jan_Flanders> let table = match value with
<Jan_Flanders> I changed in to in_channel but I"m getting a syntax error for the last line :s
<Jan_Flanders> How hard can it be to just set the reading position 1 byte back? :s
<thelema> Jan_Flanders: regular files are ones on disk.
<thelema> you can
<Jan_Flanders> thanks. The file is on my disk
<thelema> 't do this for example to a stream that's being piped in from another process
<thelema> or to a network channel
<ksson> how about: seek_in (pos - 1) ch
ztfw has quit [Remote closed the connection]
<thelema> Line 6 in your pastebin needs 'in' at the end
<Jan_Flanders> This function is applied to too many arguments, maybe you forgot a `;'
<Jan_Flanders> to thelema, now I'll try ksson suggestion :)
<thelema> and the number of arguments needs to be reduced
<ksson> (you still have to have a "in" at the end of the line)
<thelema> seek_in takes two arguments, you have 3.
<thelema> it takes a channel and an int (in that order)
<thelema> so [seek_in ch (pos-1);]
<Jan_Flanders> This expression has type IO.input * (unit -> int) but is here used with type int
<ksson> thelema is right; i didn't look in the doc
<ksson> Jan_Flanders: replace line 6 by : let _ = seek_in ch (pos - 1) in
tmaedaZ has joined #ocaml
tmaedaZ is now known as tmaeda
<thelema> ksson: style wise, better to do [let () = ... in] for unit functions
<thelema> but best to do [...;]
<ksson> thelema: in let sequences i prefer keeping the let
<ksson> but you're right about the () pattern
<Jan_Flanders> No, none of the suggestions work
<Jan_Flanders> I keep getting This expression has type IO.input but is here used with type in_channel
<Jan_Flanders> And I have been working on this 1 line of code for 3 hours and have tried about any combination I can think of.
<thelema> Jan_Flanders: you're using batteries / extlib?
<Jan_Flanders> yes
<thelema> well that's the problem - it seems we left off seeking from batteries channels.
<thelema> and I assume the same from extlib channels because they're what batteries started with.
<Jan_Flanders> Can you tell me how to read a byte and set the reading position back after reading that byte?
<ksson> yeah, i can't find anything in the documentation of extlib
<tonyg> (does ocaml have call/cc or delimited continuations anywhere?)
<thelema> Hmm, I don't see an easy way to do this directly with the channel. Of course you can turn the channel into a byte enum with IO.bytes_of, and then just peek the first char of the enum.
<thelema> (This assumes batteries. I dunno if extlib has IO.bytes_of - I think that might have been added by us.)
<Jan_Flanders> let pos = pos_in ch in
<Jan_Flanders> let value = read_byte ch in
<Jan_Flanders> let x = [seek_in ch (pos-1);] in
<Jan_Flanders> That should work according to your suggestion?
<Jan_Flanders> I don't care about x, I just want to reset the reading position
<thelema> Jan_Flanders: At the moment, you can't seek in batteries/extlib IO channels.
<thelema> and the syntax would be:
<thelema> let value = read byte ch in
<thelema> seek_in ch (pos-1);
<thelema> ...
<thelema> but you can't do that because the channels that batteries/extlib provide do not allow seeking.
<thelema> If you want to read a byte multiple times, you should turn the channel into an enum, and get the head of that enum multiple times.
<thelema> Or switch to legacy IO, which keeps more of the 'bare metal' capabilities than batteries/extlib IO.
<Jan_Flanders> let pos = pos_in ch in
<Jan_Flanders> let value = read_byte ch in
<Jan_Flanders> seek_in ch (pos-1); This expression has type IO.input but is here used with type in_channel
<ksson> Jan_Flanders: we know :)
<Jan_Flanders> Maybe I'm not using 'batteries/extLib' cause this worked before
<ksson> seek_in doesn't exist for IO.input values
<thelema> Again - seek_in is a function that works on values of type in_channel, not IO.input
<thelema> you are using either batteries or extlib, as you have a value of type IO.input
<Jan_Flanders> let ch = IO.input_channel (open_in_bin file) in
<ksson> what would happen if one applied seek_in to the underlying in_channel ?
<ksson> let inch = open_in_bin file in
<ksson> let ch = IO.input_channel inch in
<Jan_Flanders> I can't believe I got this to compile a few hours ago without problems and can't remember how I did it. :s
<ksson> ...
<ksson> seek_in inch (pos - 1);
<ksson> kind of a hack :)
<thelema> ksson: batteries wraps open_in_bin to give a IO.input
<thelema> s/wraps/replaces/
<Jan_Flanders> It worked before so it must be possible. It's just a syntax question atm
<ksson> ah hm
<thelema> It worked before you switched to batteries to get read_ui16 and nread
<Jan_Flanders> no :)
<thelema> I guess you could be using extlib for those...
<thelema> There's no seek function for IO.input channels.
<thelema> The right way to do this one byte thing is to hold on to that one byte and pass it where it's needed.
<Jan_Flanders> I guess so
<thelema> if value = 0xff then parse_jpg_table ch 0xff
<thelema> else "" ??
<thelema> You make an empty buffer, do nothing with it, and then return its contents?
<thelema> err, put its contents in [table]?
<thelema> I'll assume there's more code that'll go in there.
<thelema> Do you have any idea how big the strings you'll be reading are?
<thelema> the strings you'll be putting into the buffers
<thelema> 3 bytes? 10 bytes? 100 bytes? 1MB?
<Jan_Flanders> no they are jpeg, png bytes and can be very small or really big
<Jan_Flanders> parse_jpg_table will fail in the pastebin because I've allready read the first byte, so it will never encounter 0xFF in that function
<thelema> do you have a minimum size estimate? 20 bytes?
<Jan_Flanders> I guess the header size +1 pixel? :)
<thelema> which is...
<Jan_Flanders> I don't really know how big a jpeg table is but the header for png and gif is 7 bytes I think
<thelema> I'm just trying to get you to use some value for Buffer.create other than 0, as it's a really bad value.
<thelema> just for performance reasons.
<Jan_Flanders> It's kind of a hack to have something to put in there yes
<thelema> as to your 0xff problem, just write the function without the flag, as you're guaranteed to have read 0xff once before entering the function
<Jan_Flanders> true
<thelema> and just prepend the byte you do read to the results of nread
joewilliams has joined #ocaml
joewilliams has quit [Remote closed the connection]
<Jan_Flanders> Thanks but I have no idea how to do that. I'll just ask the author who know Ocaml very well and it will cost him less than 15 seconds to write this.
<Jan_Flanders> I still find it weird that after trying so many hours myself and all the people who say they know Ocaml have tried, nobody has even been able to come up with a line that compiles without syntax errors.
<Jan_Flanders> From all the other languages I code it, this seems like such a trivial thing
<ksson> Jan_Flanders: you showed us only half of the code, without saying which library you were using - not so easy for us
<Jan_Flanders> The entire code is tens of thousands of lines
<ksson> also, it seems that the library you are using doesn't support what you want to do - so it's really difficult :)
<Jan_Flanders> Yeah I understand that. :)
<ksson> Jan_Flanders: since you seem to be using extlib (and not batteries), you could try my hack from 15:37
<ksson> but it's a hack, and thelema's solution looks better to me
<Jan_Flanders> I would love to if I knew how. :)
<ksson> but for that you need to know ocaml a bit :)
<Jan_Flanders> I don't know any Ocaml :P
<Jan_Flanders> I was only trying to change 1 line of code which I hoped I would be able to do. Guess not...
<ksson> Jan_Flanders: what I wrote at about 15:37
<thelema> Jan_Flanders: what's the original code, and what's the desired change you want?
<thelema> ok
<thelema> you want to fix this: (*let table = match read_byte ch with 0x89 -> nread 7; "" | 0x47 -> nread 5; "" | 0xFF -> parse_jpg_table ch*)
<Jan_Flanders> Someone gave me that line but that didn't work either
<thelema> yes, it wouldn't.
<Jan_Flanders> let table = parse_jpg_table ch in (that was the original code)
<thelema> yes
<Jan_Flanders> But it assumes that there will be jpeg bytes
<Jan_Flanders> while there can be a png or gif file (bytes) as well
<thelema> you might have png or other graphics format
<thelema> ok. How do you tell which it'll be?
<Jan_Flanders> By checking the first byte. ;)
<Jan_Flanders> 0xFF is jpeg, 0x89 is png 0x47 is gif
<Jan_Flanders> IN the case of png or gif there is no jpeg_table and I would just need (len-2) bytes
<Jan_Flanders> and an 'empty' table (hence the Buffer.create 0)
<thelema> what do you need the 0x89 or 0x47 or 0xff for more than just checking the type?
<Jan_Flanders> I need to write that byte along with the following bytes in the end
<Jan_Flanders> I miss that byte if I read it first since it has been consumed. It will even error on trying to read beyond eof because (len-2) has to be (len-3)
<thelema> ok.
<Jan_Flanders> I got this working but I missed that byte, since I read it, which lead me to trying to reset the reading position so I could read it once for checking file type and then read it again so it's in data
<Jan_Flanders> and data is written eventually to a file
<thelema> oh, you'll need the byte too...
<thelema> hmmm...
<thelema> I'm cheating by putting it in the table, but it seems they're just written out one after the other, so...
ksson has quit ["christmas"]
Smerdyakov has joined #ocaml
<thelema> not the right escape.. hmm
<Jan_Flanders> let data = nread ch (len - 2 - String.length table) in (*This expression has type 'a -> string but is here used with type string*)
<thelema> \xnn
<Jan_Flanders> I hadn't thought of the table trick :)
<thelema> oops, the pos argument of parse_jpg_table2 isn't needed.
<thelema> let parse_jpg_table2 ch =
<Jan_Flanders> Unbound value parse_jpg_table (the function is used in other places as well)
<Jan_Flanders> I just got a note that the original author is trying to make the changes atm.
<thelema> yes, you have to add the new function parse_jpg_table2
<Jan_Flanders> Sorry missed the fact that you created a new one, I just replaced the old one
<thelema> no problem, easy mistake
joewilliams has joined #ocaml
<Jan_Flanders> where do I put or what do I do with the \xnn ?
<thelema> instead of "\0x89", it should be "\x89"
<thelema> similar for "\x47"
joewilliams has quit [Client Quit]
tonyg has quit [Read error: 60 (Operation timed out)]
<Jan_Flanders> This expression has type 'a -> string but is here used with type string // let data = nread ch (len - 2 - String.length table) in
Smerdyakov has quit ["Leaving"]
fission6 has joined #ocaml
<flux> merry christmas! I'm sooo stuffed..
<thelema> Jan_Flanders: that is caused by the extra argument in parse_jpg_table2 - did you remove 'pos' from its declaration?
<thelema> flux: merry christmas
<fission6> anyone here work for jane capital
<Jan_Flanders> hehe I did before but forgot it now :)
<Jan_Flanders> It has been solved. :) I really appreciate all the effort you put in to it. :)
<thelema> you're welcome.
<thelema> let's see if nicholas likes this solution or his better.
<Jan_Flanders> my last paste is his
<Jan_Flanders> got it a minute ago
<Jan_Flanders> Yours is compiling as well atm, though but a bunch of warnings about the pattern not being fuly matched.
<Jan_Flanders> Time to test it :)
<thelema> odd - the match i added is fully matched - the ... oops!
<thelema> you'll need some parentheses to separate the internal match from the enclosing match
<Jan_Flanders> no warnings this time :)
<thelema> better. There was a big semantic error without the ()
_unK has joined #ocaml
<Jan_Flanders> You're a genius! It works!
bogen has quit [Read error: 60 (Operation timed out)]
quelqun_dautre has joined #ocaml
<quelqun_dautre> hi
<thelema> hi
<Jan_Flanders> Thanks again thelema. (Nicholas' solution works as well. So I have to working solutions. nice. :)
<Jan_Flanders> You know him btw?
<orbitz> Not this again
<Jan_Flanders> Or did you just get his name from the source file?
<thelema> never met him, but I know his name.
<Jan_Flanders> hehe orbitz :P
<flux> jan_flanders, now it's a good time to start using a version control system :)
<Jan_Flanders> :)
<orbitz> Jan_Flanders is in a particular situation whre he doesn't actually know what he is doing.
<Jan_Flanders> true :D
<Jan_Flanders> trying hard though :P
<Jan_Flanders> I've written similar stuff (swf assembler) in other languages (AS3 and haXe) so I know what it does, but I don't know any OCaml(syntax)
<orbitz> Why are you doing this in Ocaml then/
_unK has quit [Remote closed the connection]
<Jan_Flanders> Because it's the haXe(syntax) compiler as well besides being an swf assembler
<orbitz> I'm not sure how that answers my question
<flux> let the man try :)
<flux> atleast he's got persistence
<flux> 90%, 10%, etc ;)
<Jan_Flanders> I remember
<orbitz> I'm not telling him to stop. I'm just wondering why he is trying to do this in a language he doesn't know (which means he basicaly just asks us to do it for him)
bogen has joined #ocaml
<Jan_Flanders> That is true to some extend, although I try myself first for a few hours before asking.
<orbitz> That still doesn't answer my question :)
_unK has joined #ocaml
<Jan_Flanders> I answered it. I know what every part in the Ocaml source actually does because I have written the same script in another language. So the biggest problem is syntax not logic
<orbitz> Jan_Flanders: you can probably learn enough Ocaml to do this if you spend a day just reading throuhg a tutorial/ocaml documetnation btw. The synta isf airly concise. And then you'll be in love with Ocaml and only write Ocaml
<orbitz> Jan_Flanders: No you told me something about haxe. I'm curious what you are doing if you've already written swf assemblers in other languages. As in, I don't just go around and start mucking in a language I don't know on a project I don't know for no reason at all
<Jan_Flanders> 'for no reason' meaning I allready have an swf assembler of my own?
<orbitz> When I asked why you are doing this you said because HaXe is implemented in Ocaml. I don't see what this has to do with anything. I am asking why you are modifying this code
<Jan_Flanders> I am modifying it because it lacks features it should have according to the official swf specs. I had asked the original author before to make the changes but he didn't react to my question (back then). He has now. There are people using my swf assembler and feeding the swf's it makes to the haXe compiler, but that complains about an invalid swf.
<orbitz> ok
<Jan_Flanders> brb
demitar has quit ["Ex-Chat"]
joewilliams has joined #ocaml
bogen has quit [Read error: 60 (Operation timed out)]
demitar has joined #ocaml
bogen has joined #ocaml
albacker has joined #ocaml
ice_four_phone has joined #ocaml
bogen has quit [Read error: 60 (Operation timed out)]
ice_four_phone has quit [Client Quit]
fx_ has quit [Read error: 110 (Connection timed out)]
bogen has joined #ocaml
albacker has quit [Remote closed the connection]
albacker has joined #ocaml
bogen has left #ocaml []
albacker has quit ["."]
tmaeda0 has joined #ocaml
tmaeda has quit [Read error: 110 (Connection timed out)]
Amorphous has quit [Read error: 104 (Connection reset by peer)]
ski_ has quit ["Lost terminal"]
ski_ has joined #ocaml
tmaeda0 is now known as tmaedaZ
Amorphous has joined #ocaml
struktured has quit [Read error: 60 (Operation timed out)]
CcSsNET has quit [Connection timed out]
EliasAmaral has quit [Read error: 60 (Operation timed out)]
lloydmoore has quit ["gotta run"]
EliasAmaral has joined #ocaml
tmaedaZ has quit [Read error: 60 (Operation timed out)]
tmaedaZ has joined #ocaml
animist has joined #ocaml
ua has quit [Read error: 110 (Connection timed out)]
ua has joined #ocaml
joewilliams has quit ["Leaving..."]
joewilliams has joined #ocaml
ua has quit [Read error: 60 (Operation timed out)]
_unK has quit [Remote closed the connection]
ikaros has joined #ocaml
fraggle_laptop has joined #ocaml
mehdid has quit [Read error: 110 (Connection timed out)]
fraggle_laptop has quit ["Quitte"]
smimram has quit ["bli"]
EliasAmaral has quit [Remote closed the connection]