gildor changed the topic of #ocaml to: Discussions about the OCaml programming language | http://caml.inria.fr/ | OCaml 3.12.0 http://bit.ly/aNZBUp
joewilliams_away is now known as joewilliams
joewilliams is now known as joewilliams_away
boscop_ has quit [Ping timeout: 240 seconds]
myu2 has joined #ocaml
oriba has quit [Quit: Verlassend]
Nutssh has joined #ocaml
doodo has joined #ocaml
joewilliams_away is now known as joewilliams
<doodo> stupid ocaml. why did i ever think you were hard to understand
alexyk has quit [Quit: alexyk]
opla2 has joined #ocaml
ccasin has joined #ocaml
Amorphous has quit [Ping timeout: 272 seconds]
bzzbzz has quit [Quit: leaving]
joewilliams is now known as joewilliams_away
jcwjcw has joined #ocaml
<jcwjcw> ocaml n00b here
<jcwjcw> does anyone know how to say that a typt must be a subtype of more than one type
<jcwjcw> like "I have a function that takes an object that must be a "car" and and a "toy""
sepp2k has joined #ocaml
<jcwjcw> ?
<jcwjcw> and also, how do we make one type automatically inherit all of the attributes of another type (not the implementation, just the signature)
ccasin has quit [Quit: Leaving]
Amorphous has joined #ocaml
alexyk has joined #ocaml
snarkyboojum has left #ocaml []
alexyk has quit [Read error: Connection reset by peer]
<thelema> jcwjcw: only doable for objects
<jcwjcw> interesting.
<jcwjcw> Haven't even got there yet
<jcwjcw> Trying to make objects out of records right now
<thelema> and the typing of objects is not nominal, so the names of the types don't matter
<thelema> the typing of objects is structural, meaning that the structure of the object is what's important
<jcwjcw> i see.
<jcwjcw> So you can still pattern match on objects just like anything else
<jcwjcw> What about structural subtyping
<jcwjcw> Do you really need objects for this?
<jcwjcw> I don't think so right?
<jcwjcw> If my structure has MORE fields than you require, it is still a subtype
<thelema> no, you can't pattern match on objects
<jcwjcw> whaaa?
<jcwjcw> no pattern matching on objects
<jcwjcw> that's horrible
<jcwjcw> That's the best feature of Ocaml.
<thelema> you can call methods on objects, that's about it.
<thelema> yes, objects are not quite first class
<jcwjcw> Seems like I could just create my own oo system
<jcwjcw> out of records
<thelema> well, they're first class, but they're not quite equal
<jcwjcw> and helper constructor functions
<thelema> you almost could, except records can't inherit and are nominally typed, not structurally typed
<jcwjcw> nominal vs structure?
<jcwjcw> by name you mean?
<thelema> meaning you have to pre-declare the type with all its fields
<thelema> and the name of the type is important.
<jcwjcw> Right, but I'm experimenting with mixing records and multitypes
<jcwjcw> and it seems like you can pretty much get really rich objects
<jcwjcw> You can create an object that has state and methods that operate on the state
<jcwjcw> You just also need to make sure that all of these methods accept the state as a param
<jcwjcw> (like 'this') in other languages
opla2 has quit [Ping timeout: 240 seconds]
<jcwjcw> It's just the inheritance that I can't get.
<jcwjcw> It's just a matter of having to explicitly retype all of the fields in a record
<jcwjcw> not that big of a deal
<jcwjcw> Maybe there's some cool macro
<thelema> Well, it's possible to cheat the type system to get a form of inheritance with records, but I wouldn't recommend it
alexyk has joined #ocaml
<thelema> in any case, try doing what you want withough objects, you may find them unneeded.
<jcwjcw> true true.
<jcwjcw> Hey thelema i just read that ocaml can fail on an equal comparison at runtime with an exception
<jcwjcw> don't you feel like this is inconsistent with the rest of the language?
<jcwjcw> What's the best workaround?
<thelema> ocaml silently overflows on int operations, this is also inconsistent with safety guarantees of the rest of the language
<thelema> the best workaround is to know when to use (=) and when to use (==)
<thelema> (=) can fail on recursive structures (ones with pointers in a cycle)
<jcwjcw> hmm.
<jcwjcw> Doesn't sound like ML IIRC
<jcwjcw> A different ball game perhaps
<thelema> for these, it's important to use (==) which does pointer comparison
<thelema> ocaml isn't sml, that's true
<jcwjcw> I want a language, where there at the very least is a way to code such that runtime errors rarely occur
<jcwjcw> Hey, I suppose both Ocaml and SML are better than any of the other languages with null
<jcwjcw> <- from that doc, trying to understand what polymorphic invariants are
<jcwjcw> do you have a good way of explaining the?
<jcwjcw> *variants
<thelema> like regular variant types, but structural instead of nominal
<thelema> i.e. you can make up and use them without any pre-declaration, and the structure of how you use it determines the type
<jcwjcw> interesting
alexyk has quit [Read error: Connection reset by peer]
<thelema> the type possibilties can cause horrible type errors that are very difficult to debug, but they're very useful at times
<jcwjcw> You know, I see no analog of this for nominal records
<jcwjcw> With polymorphic variants as described
<jcwjcw> You can pass it any data that has the Type in it's multitype definition
<jcwjcw> But there is no equivalent for records
<thelema> variant : polymorphic variant :: record : objects
<jcwjcw> I suppose the *default* for ocaml is to have polymorphism on records
<jcwjcw> hmmm i know nothing but i think i disagree a little.
<jcwjcw> Seems like even without objects.
mlh has joined #ocaml
<jcwjcw> Ocaml has polymorphism on records
<jcwjcw> If you define a function that operates on its parameters
<jcwjcw> and accesses fields in its parameters
<jcwjcw> isn't it then implicit that that method can accept any method that has parameters that you accessed in that method
<jcwjcw> *function
<thelema> polymorphism <> "polymorphic variant"
<thelema> and no, it's not implicit that that function can accept any record with the required field
<jcwjcw> I know.
<jcwjcw> ^^ *I didn't know*
<thelema> only for methods
<thelema> record fields are just named indices. methods are looked up at runtime
alexyk has joined #ocaml
<jcwjcw> But this works type coord = {x : int; y : int};; let addCoord c = c.x + c.y;; let mycoord: coord = {x=1; y=2} in addCoord mycoord;;
<jcwjcw> The function accepts the mycoord because it has the required types
<jcwjcw> right?
<jcwjcw> Then i can add a z field to coord type
<jcwjcw> and it still works
alexyk has quit [Read error: Connection reset by peer]
Associat0r has quit [Quit: Associat0r]
<jcwjcw> I thin
<jcwjcw> I think
<jcwjcw> whoa i don't think i can!
<jcwjcw> I can't even do this: type coord = {x : int; y : int; z:int};; type coord4 = {x : int; y : int; z:int; h:int};;
<jcwjcw> Now I see what you mean
<jcwjcw> You must use objects to get the subtyping
<jcwjcw> I simply can *not* accomplish this without objects
alexyk has joined #ocaml
Nutssh has quit [Quit: Client exiting]
alexyk has quit [Read error: Connection reset by peer]
<jcwjcw> thelema, couldn't accomplish this by simply using a tuple?
<jcwjcw> Tuples are exactly what I want except that i can't name the members in the tuple
<jcwjcw> Seems like maybe 15 lines of a script to write some helper parser that takes some macro $createTupleFrom(fieldOne: Int = 4, fieldTwo: Int = 48)
<jcwjcw> And spits out (4,48)
<jcwjcw> in the actual source code
alexyk has joined #ocaml
alexyk has quit [Read error: Connection reset by peer]
myu2 has quit [Remote host closed the connection]
ztfw has quit [Remote host closed the connection]
alexyk has joined #ocaml
<kaustuv_> You don't need a script:
<kaustuv_> let create_tuple_from ~field1 ~field2 = (field1, field2)
<kaustuv_> let x0 = create_tuple_from ~field2:"foo" ~field1:"bar"
asmanur has quit [Ping timeout: 260 seconds]
kaustuv_ has quit [Quit: off to work]
sepp2k has quit [Ping timeout: 260 seconds]
NaCl has quit [Quit: leaving]
alexyk has quit [Read error: Connection reset by peer]
alexyk has joined #ocaml
alexyk has quit [Client Quit]
jcwjcw has quit [Ping timeout: 265 seconds]
myu2 has joined #ocaml
<doodo> man i can't figure out how to write functions for traversing abstract syntax trees
ikaros has joined #ocaml
Yoric has joined #ocaml
LeNsTR|away has joined #ocaml
LeNsTR|away has quit [Changing host]
LeNsTR|away has joined #ocaml
LeNsTR|away is now known as LeNsTR
eye-scuzzy has quit [Quit: leaving]
eye-scuzzy has joined #ocaml
ygrek has joined #ocaml
doodo has quit [Quit: Page closed]
hto has joined #ocaml
hto_ has joined #ocaml
hto__ has joined #ocaml
hto__ has quit [Client Quit]
hto_ has quit [Client Quit]
hto has quit [Quit: Lost terminal]
hto has joined #ocaml
edwin has joined #ocaml
Yoric has quit [Quit: Yoric]
ikaros has quit [Quit: Leave the magic to Houdini]
ttamttam has joined #ocaml
LeNsTR has quit [Remote host closed the connection]
Snark has joined #ocaml
cyanure has joined #ocaml
Yoric has joined #ocaml
ftrvxmtrx has quit [Quit: Leaving]
_andre has joined #ocaml
ubunut has joined #ocaml
ubunut has quit [Remote host closed the connection]
ygrek has quit [Remote host closed the connection]
mcclurmc has joined #ocaml
Yoric has quit [Read error: Connection reset by peer]
Yoric has joined #ocaml
Yoric has quit [Read error: Connection reset by peer]
Yoric has joined #ocaml
ftrvxmtrx has joined #ocaml
jonathandav has joined #ocaml
ubuntu has joined #ocaml
<ubuntu> can someone tell me where i get unix.cmxa file?
<adrien> how do you get an error asking for it?
<ubuntu> Error: Cannot find file unix.cmxa
<ubuntu> i just compiled the latest version of ocaml on my system (ubuntu 10.10) and now that file seems to be missing
<adrien> you compiled by yourself?
<adrien> (could be with godi)
<adrien> if so, you need to run 'make opt' to get the .cmxa files, but if you haven't, you shouldn't have 'ocamlopt' or anything asking for .cmxa files. Could you be mixing two installations of ocaml?
<ubuntu> how do i find out? i thought i have removed the old version entirley
<adrien> which command do you run?
<ubuntu> i removed it with atp-get purge ocaml
<adrien> I meant, for the compilation
* adrien still knows nothing about debian
<ubuntu> ./configure then make opt i followed the instructions in the install file
<adrien> I mean, the one telling you that it can't find unix.cmxa :p
<ubuntu> my mistake, i tried to compile a file for work, which only runs with the ocaml 3.12 version
<adrien> ok
<adrien> if I create a bytecode file on one computer, is it supposed to run on another computer with its own ocamlrun (same versions)?
boscop_ has joined #ocaml
boscop_ has quit [Read error: Connection reset by peer]
boscop_ has joined #ocaml
<ubuntu> is that a rhetorical question=
<ubuntu> ?
BiDOrD_ has joined #ocaml
<adrien> no, it's an actual one ;-)
<ubuntu> adrien: do you have some idea where the problem could be, and do you know any command to find out the version which is installed on my computer of ocaml?
BiDOrD_ has quit [Quit: BiDOrD_]
<adrien> "which --all ocamlopt" should show if you have several "ocamlopt" executables installed
<ubuntu> Illegal option --
<adrien> /bin/which --all ocamlopt
BiDOrD has joined #ocaml
<ubuntu> again illegal argument
<ubuntu> illegal option
<ubuntu> what could be wrong ?
<adrien> try with: IFS=':'; for p in $PATH; do if [ -e $p/ocamlopt ]; then echo $p/ocamlopt; fi; done
<ubuntu> the output: /usr/local/bin/ocamlopt /usr/bin/ocamlopt
<adrien> /usr/bin/ocamlopt is most probably from the distribution package
<ubuntu> so deleting it?
<adrien> you said you wanted to remove the ocaml from the distribution packages, it looks like something is still here, so check with apt or synaptics or something else
<ubuntu> if i do now apt-get remove ocaml, do i remove then the ocaml 3.12 version?
<adrien> which has been installed how?
<ubuntu> the old ocaml version was installed via apt, the new one i compiled by myself
myu2 has quit [Remote host closed the connection]
myu2 has joined #ocaml
myu2 has quit [Remote host closed the connection]
<adrien> apt will only remove what it installed
<ubuntu> apt-get remove or apt-get purge?
<adrien> I think remove should do it, but again, I know almost nothing about apt
<ubuntu> nothing happend
jm has joined #ocaml
<gildor> ubuntu: were you able to install 3.12 ?
<ubuntu> yes, BUUUUUUUUUT now i have two ocamlopt...^^
Associat0r has joined #ocaml
<ubuntu> gildor: any idea how to solve that?
<gildor> ubuntu: you install through apt ?
<mrvn> remove leaves conffiles behind, purge removes them also. But for something that has no confiles there is no difference.
<ubuntu> gildor: yes the old version was installed via apt, the new one compiled by myself
<ubuntu> gildor: now the problem is if i try to compile some work files which demand the new ocaml version it says, cannot find unix.cmxa
<gildor> ubuntu: dpkg -S /usr/bin/ocamlopt to find the package that install ocamlopt and remove it
<gildor> probable ocaml-nox or ocaml-native-compilers
<gildor> you should be able to live with remaining conffiles
<ubuntu> gildor: it contains ocaml-nox
<ubuntu> should i simply delete it?
<gildor> apt-get remove ocaml-nox
<ubuntu> how do i find out which version of ocaml i am using?
<flux> ocamlc -v
<ubuntu> Cannot find file unix.cmxa
<gildor> ubuntu: start with which ocamlc
<gildor> ubuntu: start with 'which ocamlc'
<flux> mv ~/.ocamlinit ~/.ocamlinit-disabled
<ubuntu> gildor: /usr/local/bin/ocamlc
<gildor> ubuntu: have you use "rm /something/" to uninstall ocaml related stuff ?
<gildor> ubuntu: and 'which ocamlopt'
sepp2k has joined #ocaml
<gl> hello #ocaml
<gildor> hello gl
<gl> do you know guys if the llvm/ocaml binding is good?
<gl> i wonder if i can use it in production
<gildor> not that bad, but you must use it to know if there are problems
<gl> i didn't code in ocaml for ages
<ubuntu> gildor: /usr/local/bin/ocamlopt
<thelema> gl good for what? compiling ocaml to llvm - no.
<ubuntu> and i removed it via apt-get remove ocaml-nox
<gildor> thelema: gl is probably talking about libllvm-ocaml-dev
<gl> thelema: compiling a homemade subset of sql to llvm
<gildor> ubuntu: is ocamlopt still there ?
<ubuntu> gildor: yes
<gildor> ubuntu: is there still a result when you run "dpkg -S /usr/bin/ocamlopt"
<ubuntu> gildor: noe
<ubuntu> no
<gildor> so this file doesn't belong to any package
<gildor> this is not good at all
<gildor> ubuntu: run /usr/bin/ocamlopt -v
<ubuntu> The Objective Caml native-code compiler, version 3.12.0 Standard library directory: /usr/local/lib/ocaml
<gildor> ubuntu: seems like on exec of your self compiled ocaml ended up in the wrong place
<gildor> ubuntu: did you do it on purpose ?
<ubuntu> i just the default folder
<ubuntu> just used the default folder
<gildor> ubuntu: by default, prefix should be set to /usr/local, just as for the stdlib dir
<gildor> ubuntu: paste me the result of "ls /usr/bin/*caml*"
<ubuntu> dh_ocaml dh_ocamlinit ocaml-lintian ocamlrun dh_ocamldoc ocaml ocaml-md5sums ocamltags
<gildor> ubuntu: apt-get remove dh-ocaml ocaml-interp
<gildor> ubuntu: but ocamlopt doesn't appear in this list. Why ?
<ubuntu> gildor: removed
<gildor> ok
<gildor> ubuntu: (you mean ocamlopt removed or the package dh-ocaml and ocaml-interp)
<ubuntu> gildor: dh-ocaml and ocaml-interp
<ubuntu> are removed
<gildor> so why ocamlopt doesn't appear in /usr/bin/*caml*
<mrvn> don't forget hash -r / rehash
<ubuntu> gildor: good question
<gildor> anyway, check that ls /usr/bin/*caml* is almost empty (ocamltags can stay)
<ubuntu> it contains ocamlrun and ocamltags
<gildor> and give me the result of 'which ocamlopt'
<ubuntu> gildor: /usr/local/bin/ocamlopt
<gildor> ocamlrun -> apt-get remove ocaml-base-nox
<gildor> (I think it will erase what remains of your 3.11.2 ocaml installation)
<gildor> ubuntu: ocamlopt location -> this is better
<ubuntu> gildor: should i command apt-get remove ocaml-base-nox
<gildor> yes
smerz has joined #ocaml
<gildor> ubuntu: ^^
<ubuntu> gildor: done
<gildor> ubuntu: ls /usr/bin/*caml*
<ubuntu> gildor: ocamltags
<gildor> ubuntu: ls /usr/lib/ocaml/
<ubuntu> ls: cannot access /usr/lib/ocaml: No such file or directory
<gildor> ubuntu: perfect
<gildor> ubuntu: you are now in a clean state
<ubuntu> gildor: oookay, AND what now?^^
<gildor> ubuntu: so what command output the unix.cma missing stuff
<gildor> ?
myu2 has joined #ocaml
<ubuntu> Error: Cannot find file unix.cmxa
<gildor> what is the command that output that ?
<ubuntu> make
<gildor> make for which project ?
<ubuntu> work
<gildor> what is work ?
<gildor> do you have any other output ?
<gildor> e.g. command invoked before the crash
<ubuntu> gildor: the project from my job
<gildor> make should be a little more verbose, it usually output the command associated with the error
<gildor> ubuntu: what say "env | grep -i caml"
<ubuntu> gildor: nothing
<gildor> ubuntu: ls /usr/local/lib/ocaml
<gildor> ubuntu: seems you have a partial installation of .cmxa
<gildor> e.g. missing str.cma, bigarray.cma
<ubuntu> gildor: how can such a thing be missing, if i installed the newest version of ocaml
<gildor> ubuntu: did you run "make opt" before "make install" ?
<gildor> ubuntu: .cmxa (native compilation) is an option, you must explicitely build it
<ubuntu> gildor: make world and then make opt
<ubuntu> following the advise in the install file
Associat0r has quit [Quit: Associat0r]
<gildor> ubuntu: and you don't get the .cmxa ?
<gildor> ubuntu: what is your arch
<ubuntu> gildor: what is arch?
<gildor> (amd64, i386)
<ubuntu> gildor: i have a 64 bit dual core and ubuntu 10.10 64 bit
<gildor> 64 bit "intel/amd" dual core ?
<adrien> I don't think ubuntu is on any other 64bit arch
<ubuntu> gildor: intel
<gildor> maybe arm ?
<gildor> ubuntu: ok you should be able to compile
<gildor> ubuntu: check in the ocaml source tree you compiled, that .cmxa are presents
<gildor> ubuntu: most probably in otherlibs/unix
<gildor> e.g.
<ubuntu> gildor: can i make locate .cmxa
<gildor> no, locate depends on a DB that is updated once a day
<gildor> that is not precise enough
<gildor> find ./ -name "*.cmxa"
<gildor> w
<thelema> "sudo updatedb" updates the locate database
<gildor> thelema: not faster than find ;-)
<ubuntu> gildor: finds nothing
<gildor> rerun "make opt" in the ocaml source tree
<gildor> and check if there are any errors
<gildor> ubuntu: make clean && make world
<gildor> let start again
alexyk has joined #ocaml
oriba has joined #ocaml
<ubuntu> gildor: done
<gildor> ubuntu: make opt
<gildor> (this time you shouldn't have any errors)
<ubuntu> gildor: done
<gildor> ubuntu: no errors ?
<ubuntu> gildor: after make opt, no errors appeared
<gildor> have a look at "find ./ -name "*.cmxa""
<gildor> ubuntu: make install
alexyk has quit [Read error: Connection reset by peer]
<gildor> and look if unix.cmxa is installed in /usr/local/lib/ocaml/
<ubuntu> gildor: yes it s there
<gildor> retry your work makefile
<ubuntu> Failure: Error while running: ocamlfind list.
<gildor> full error ?
<gildor> (but the answer is: you have to build findlib)
<ubuntu> gildor: /bin/sh: ocamlfind: not found Failure: Error while running: ocamlfind list.
<gildor> ubuntu: you have to build findlib
<gildor> and if you use findlib this probably because there are various other library to build
<ubuntu> gildor: sounds bad?
<gildor> ubuntu: depends on your level of patience
<ubuntu> gildor: always willing to learn more
<gildor> ubuntu: I don't care building libraries but I am used to
<gildor> ubuntu: if you have time go ahead
<ubuntu> gildor: so how do i start, and is that normally done via apt?
<gildor> give me the output of grep pkg_ _tags of your project
<gildor> ubuntu: something around 99% are normally handled by apt, but since you work with a non-released version, you'll need to download and build every library
<ubuntu> gildor: how many library are we talking about?
<gildor> the answer is in "grep pkg_ _tags" in your project dir
<ubuntu> pkg_str, pkg_unix
<gildor> ok this will be quick
<gildor> just fetch and download findlib from http://projects.camlcity.org/projects/findlib.html
<gildor> and that should be ok
<gildor> (and build it of course)
alexyk has joined #ocaml
<ubuntu> gildor: ./configure?
<gildor> yes
<gildor> there should be an INSTALL file
<ubuntu> gildor: if i make ./configure then i get this reply configure: m4 not in PATH; this is require
joko has joined #ocaml
<ubuntu> there is a INSTALL file
<gildor> apt-get install ma
<gildor> apt-get install m4
<ubuntu> whats ma and m4
<gildor> ma is an error
<gildor> m4 is a macro language used in autoconf, e.g.
<ubuntu> cant follow why do i want an error?
<gildor> ma is a typing error from me
<gildor> ma -> m4
<joko> Hello, I want to create a set of unique elements (just integers to be precise). Should I use a map or is there another data structure more optimal?
<ubuntu> gildor: ./configure is done
boscop_ has quit [Read error: Connection reset by peer]
<gildor> ubuntu: follow the INSTALL file: make all && make opt && make install
boscop_ has joined #ocaml
<gildor> joko: use the Set datastructure
boscop_ is now known as boscop
<ubuntu> gildor: done
<joko> gildor: Thanks!
pheredhel has quit [Read error: Operation timed out]
<ubuntu> gildor: unbelievable, thanks so much, you saved me an unimagible amount of trouble, thnaks
alexyk has quit [Quit: alexyk]
pheredhel has joined #ocaml
joewilliams_away is now known as joewilliams
alexyk has joined #ocaml
Anarchos has joined #ocaml
<Anarchos> Are the tests in testsuite maintained ?
ashish has joined #ocaml
<Anarchos> (or, how to test ocamlopt ?)
ccasin has joined #ocaml
<adrien> I think they are, I remember seeing some changes not so long ago
ubuntu has quit [Quit: http://irc2go.com/]
<Anarchos> adrien because in testesuite/tests/asmcomp/i386.S, i see only a difference for Sys_linux_elf
alexyk has quit [Read error: Connection reset by peer]
<Anarchos> and a FUNCTION_ALIGN set to 16
ashish is now known as agarwal1975
<thelema> Anarchos: yes, they're added to when a new bug is found, but definitely not complete
<Anarchos> thelema i just need a way to test my ocamlc.opt, cause it crashes only on some ml files in caml_oldify_local_roots
boscop has quit [Read error: Connection reset by peer]
boscop has joined #ocaml
<thelema> Anarchos: the compiler crashes? what about make bootstrap?
<Anarchos> make bootstrap is fine
<Anarchos> thelema i had to make some tricks to let it compile on my i586-pc-haiku
agarwal1975 has quit [Quit: agarwal1975]
agarwal1975 has joined #ocaml
<thelema> Anarchos: hmm, and what happens when you run make all in the testsuite directory?
<Anarchos> some pas some failed (most fails)
<thelema> clearly you have a broken ocaml - I'd pick a simple test and start tracing down what's wrong
<Anarchos> thelema can i pass all the tests only with ocamlc ? and after ocamlopt ?
<thelema> Anarchos: you'll probably have to hack testsuite/makefiles/makefile.several to disable ocamlopt
boscop has quit [Read error: Connection reset by peer]
boscop has joined #ocaml
<Anarchos> thelema ok thanks
<Anarchos> will do that
ftrvxmtrx has quit [Quit: Leaving]
<hcarty> Are the dll*.so files generated for C bindings used at run time by native code binaries, or only for bytecode/toplevel?
<Anarchos> no idea, should be in the manual
<hcarty> Anarchos: It probably is. I think I'm just missing it, or misunderstanding the relevant portion.
<thelema> hmm, which is faster: using in_channel_length and a single really_input to read a file into a string, or using a Buffer.t and reading chunks into that buffer?
<hcarty> From an experiment it looks like the dll*.so files are not used by native code binaries. But I'm not sure if that is a function of the library + compilation flags, or if that is generally true.
<hcarty> thelema: Is the input processed as a whole, or as it is read? Reading it all in at once should be faster from an IO perspective.
<thelema> hcarty: since I'm processing it with bitstring, it has to be all in memory at once
<adrien> hcarty: I _think_ you don't need them for native cod
<adrien> e
<hcarty> thelema: Then I would think all-at-once would be faster, though I doubt there would be a huge difference either way
<thelema> hcarty: fair enough.
<hcarty> thelema: I expect the IO overhead would drown out the extra allocations needed for the Buffer case.
<thelema> I imagine for a large file (>100MB), the buffer reallocations wouldn't be insignificant, but yes, IO is expensive
* thelema wonders if there's a way to magic a mmaped byte bigarray into a string
<hcarty> adrien: Thanks, it looks that way
<hcarty> thelema: I've been wondering the same. A C stub could probably be used to do something similar.
<hcarty> thelema: If it did work, it would probably be fragile. The internal representations are different, so String.length would probably not work.
<hcarty> thelema: But an OCaml string value pointing to the data from a byte Bigarray may do the trick.
<kaustuv> wouldn't it be easier to port bitstring to bigarrays?
Anarchos has quit [Quit: Vision[0.9.7-H-090423]: i've been blurred!]
boscop_ has joined #ocaml
boscop has quit [Read error: Connection reset by peer]
joewilliams is now known as joewilliams_away
joewilliams_away is now known as joewilliams
<thelema> kaustuv: possibly. The thought has crossed my mind.
<thelema> hcarty: the string value would have to have its header written right before the mmaped value in memory
<thelema> and the string tail would have to be written after the last byte
<hcarty> thelema: In that case, the process sounds more complex :-)
<thelema> the string value itself is the pointer to the data, there's only the one level of indirection.
boscop has joined #ocaml
boscop_ has quit [Read error: Connection reset by peer]
<hcarty> thelema: Then it sounds like it could work the other way (Bigarray pointing to a string) but not a string pointing to a Bigarray.
<hcarty> Which probably doesn't help much in this case
<thelema> yup, definitely easier the other way
<kaustuv> that doesn't work either because the gc can move the string but it won't update the pointer inside the bigarray
<hcarty> thelema: If IO speed is a concern then staging the file(s) to be processed in /dev/shm (or some other ramdisk space) may help
<thelema> kaustuv: good point.
ulfdoz has joined #ocaml
<mfp> thelema, kaustuv: not if the string is allocated outside the OCaml heap... but then again, what was then point of having the bigarray point at it if you're mmapping by hand?
<mfp> +the
<thelema> mfp: you're suggesting mmaping diretcly into the string?
<mfp> you want 0-copy String access to a mmapped area, right?
<thelema> yes
* thelema wonders if core already has this code...
<mfp> one way would be to malloc the string, then mmap giving ptr + sizeof(long) as the start param
<mfp> then you have to generate a header
<mfp> and do something about the last word of the string if you want String.length to work
<mfp> you won't get a segmentation fault if you don't cross a page boundary at the end, right?
<thelema> actually, since bitstring uses string slices, String.length probably isn't a problem
<thelema> and core does have a bigstring library that seems to be able to do this
<kaustuv> If your IO is the bottleneck, why not just Std.input_file first?
<thelema> except their bigstring library is a bunch of functions to treat a stringy bigarray as a string
<thelema> kaustuv: I am reading the whole file into memory and then using bitstring to parse it completely, and then doing my other work
<thelema> I'm just wondering if I can skip step 1 in terms of memory overhead
<kaustuv> What are you optimizing for? Size? Throughput?
<thelema> time
<mfp> hmm actually, if String.length isn't used, can't you just give the mmapped pointer to the functions expecting a string?
<thelema> but within a memory constraint
<mfp> as long as the header isn't used, there's no diff
<mfp> the pb is that you can't tell what's using String.length and what isn't
<mfp> without reading the code
<thelema> I might try that. once I get this TCP reassembly code happy
<kaustuv> mfp: according to bitstring docks, it uses checked accessors for reading strings, so I bet they use String.length all the time
<kaustuv> *docs
<thelema> kaustuv: actually, bitstring.t = (string * int * int) - a string slice
<thelema> most likely it carries its own bounds to check against
<mfp> then the only way to have 0-copy access would be with the synthetic header + "placement mmap"
Vinnipeg has joined #ocaml
<kaustuv> thelema: http://code.google.com/p/bitstring/wiki/FAQ says that they use "safe string functions", whatever that means
<kaustuv> If they mean String.get/set, then they do read the header
Vinnipeg has quit [Remote host closed the connection]
<thelema> yup, no unsafe access here...
<thelema> :(
<kaustuv> If you're processing the data in a stream, you can chunk it up and even reuse the same chunk string
<thelema> no help there - once I'm done bisttring parsing, the file string gets GC'ed quickly
<kaustuv> Surely it would be cheaper for your boss to buy you 32GiB of memory than to pay you for the time taken to develop a more constrained solution?
ftrvxmtrx has joined #ocaml
ikaros has joined #ocaml
<thelema> That would make sense. Don't you work at a university, and understand that universities don't do things that make sense?
<adrien> "sense"? what's that?
alexyk has joined #ocaml
boscop has quit [Read error: Connection reset by peer]
boscop has joined #ocaml
alexyk has quit [Quit: alexyk]
Yoric has quit [Quit: Yoric]
boscop_ has joined #ocaml
boscop has quit [Read error: Connection reset by peer]
ttamttam has quit [Remote host closed the connection]
<jm> The type signatures of BatMap.fold and BatMap.S.fold are not the same. Is that intentional?
* thelema checks
<jm> (The former hides the keys whereas the exposes them to the user.)
<jm> *the latter
<thelema> yes, batmap has fold and foldi, for whether or not you want the keys
<thelema> if we wanted to break backwards compatibility with stdlib, we could make the same change to batmap.s, but we don't
<jm> Ok, thanks!
ftrvxmtrx has quit [Ping timeout: 240 seconds]
oriba has quit [Quit: Verlassend]
ftrvxmtrx has joined #ocaml
Associat0r has joined #ocaml
ftrvxmtrx has quit [Read error: Connection reset by peer]
ftrvxmtrx has joined #ocaml
Yoric has joined #ocaml
boscop_ has quit [Read error: Connection reset by peer]
boscop_ has joined #ocaml
_andre has quit [Quit: leaving]
kaustuv_ has joined #ocaml
kaustuv_` has joined #ocaml
kaustuv_ has quit [Read error: Operation timed out]
kaustuv_` is now known as kaustuv_
kaustuv_ has quit [Remote host closed the connection]
boscop_ has quit [Ping timeout: 240 seconds]
kaustuv_ has joined #ocaml
jonafan_ has joined #ocaml
jonafan has quit [Ping timeout: 276 seconds]
smerz has quit [Quit: Ex-Chat]
Snark has quit [Quit: Ex-Chat]
kaustuv_ has quit [Remote host closed the connection]
kaustuv_ has joined #ocaml
kaustuv_ has quit [Remote host closed the connection]
kaustuv_` has joined #ocaml
kaustuv_ has joined #ocaml
kaustuv_ has quit [Remote host closed the connection]
kaustuv_ has joined #ocaml
kaustuv_ has quit [Client Quit]
kaustuv_` has quit [Ping timeout: 276 seconds]
ftrvxmtrx has quit [Ping timeout: 255 seconds]
theDroggl has joined #ocaml
theDroggl has quit [Remote host closed the connection]
ftrvxmtrx has joined #ocaml
edwin has quit [Remote host closed the connection]
lamawithonel has joined #ocaml
mfp_ has joined #ocaml
ulfdoz has quit [Ping timeout: 260 seconds]
mfp has quit [Ping timeout: 255 seconds]
<thelema> is there a way to get a function declared in a menhir .mly available in its interface?
agarwal1975 has quit [Quit: agarwal1975]
spicey has joined #ocaml
adrien is now known as adrien_
adrien_ is now known as adrien
cyanure has quit [Remote host closed the connection]
<spicey> Are there drawbacks in using labels? i.e. why are the separate Strings and StringLabels packages needed at all: why can't there be just one - labeled - package?
<adrien> labels didn't always exist
<thelema> spicey: backwards compatibility, it's harder to pass a function with labeled args as a value to another function
Yoric has quit [Quit: Yoric]
<thelema> i.e. let add1 ~x = x + 1 in List.map add1 [1;2;3] doesn't work
* thelema checks
<thelema> yes, it doesn't work
<spicey> aha, makes sense (in it's own twisted way)
avsm has joined #ocaml
jonafan_ is now known as jonafan
<spicey> Awww, let ($) a b = b a is a wonderfully perverted (reverted) way to avoid parentheses, "foo" $ Digest.string $ Digest.to_hex $ Printf.printf "%s" , it even feels slightly natural
dooode has joined #ocaml
<dooode> can you have a function that takes a list of one type and return a list of another type?
<dooode> like i have a fucntion that takes a list of tuples with 3 elements
<spicey> can you have a function that takes an int and returns a float?
<hcarty> dooode: See the List module. List.map in particular
<dooode> can i do: let rec reduce num = match num with []->[] | (a,b,c)::dx -> (a,b):: (reduce dx)
<hcarty> dooode: Try it! :-)
<dooode> not sure how....
<hcarty> spicey: ( |> ) is commonly used for that. It's defined in Batteries, for exaple.
<hcarty> s/exaple/example/
<spicey> hcarty, ok, I'll know that now; yet for a moment I felt like the inventor of the greatest thing in the universe
<hcarty> spicey: You were. Just not the first inventor. Discovery on your own of something nifty which has already been discovered is Still Cool.
<hcarty> spicey: Part of the reason for using ( |> ) over ( $ ) is that $ has a special meaning for camlp4
<dooode> i didn't work
<dooode> it gave a type errror
<dooode> # let rec num ml = match ml with []->[] | (a,b,c)::xs -> (a,b)::(num xs);; val num : ('a * 'b * 'c) list -> ('a * 'b) list = <fun> # num [(1,2,3),(4,5,6)];; Error: This expression has type (int * int * int) * (int * int * int) but an expression was expected of type 'a * 'b * 'c
<dooode> o wait nvm
<spicey> [(1,2,3);(4,5,6)]
<dooode> yeah semi colon
<dooode> damnit it still fails
<dooode> or not maybe
<dooode> it doesn't print anything
<gl> why should it?
<dooode> exactly
<dooode> i only have 5.5 hours to learn enough ocaml and to finish a coding assignment
jm has quit [Remote host closed the connection]
<gl> good luck with that
ccasin has quit [Quit: Leaving]
ikaros has quit [Quit: Leave the magic to Houdini]
Associat0r has quit [Quit: Associat0r]
gmarik has quit [Remote host closed the connection]
<dooode> got an extension..awwwwww yeaaaah
lewis1711 has joined #ocaml
myu2 has quit [Remote host closed the connection]
<spicey> dooode, so I guess you can hold off learning ocaml until five hours until the end of the extension now
<dooode> yeah pretty much
myu2 has joined #ocaml
lars9 has joined #ocaml
<lars9> anything can do autocompletion for ocalm toplevel?
<spicey> Is there any other way to cancel ocaml toplevel input other than ^C? I just installed ocaml-batteries-git and it seems to have a bug - "foo;<enter><ctrl-c>" kills the toplevel with the exception instead of just cancelling the input
<lewis1711> hmm, ctrl-D or ctrl-z usually works
<spicey> For some reason it insists on parsing the input even on ctrl-d but at least doesn't explode the ocaml. Weird weirdness is this batteries thing