smimou changed the topic of #ocaml to: OCaml 3.08.3 available! | Archive of Caml Weekly News: http://sardes.inrialpes.fr/~aschmitt/cwn/ | 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/
vezenchio has quit ["\o/ in mochintin namocniuh \o/"]
Sylvain has joined #ocaml
<Sylvain> hello !
<ulfdoz_> hi
<Sylvain> so i am not alone here :)
alark has joined #ocaml
<Smerdyakov> Far from it!
<ulfdoz_> Not really.
<ulfdoz_> Smerdyakov: You normally go to bed when I'm getting up. :)
<Sylvain> does anybody know why the ocaml team is changing the signal management ^
<Sylvain> ?
<Smerdyakov> Sylvain, beats me. I've never used it!
<Sylvain> I didn't use it too but i check the source regularly on the CVS ;)
Sylvain has quit [Read error: 110 (Connection timed out)]
alark has quit ["Chatzilla 0.9.68a [Firefox 1.0.4/20050511]"]
Smerdy has joined #ocaml
Smerdyakov has quit [Read error: 60 (Operation timed out)]
pattern_ has joined #ocaml
Smerdy is now known as Smerdyakov
cmeme has quit ["Client terminated by server"]
mellum has quit [kornbluth.freenode.net irc.freenode.net]
mw has quit [kornbluth.freenode.net irc.freenode.net]
Mike_L has quit [kornbluth.freenode.net irc.freenode.net]
cmeme has joined #ocaml
mw has joined #ocaml
Mike_L has joined #ocaml
mellum has joined #ocaml
pattern has joined #ocaml
Saulzar has quit [Read error: 110 (Connection timed out)]
threeve has quit [Remote closed the connection]
threeve has joined #ocaml
Snark has joined #ocaml
Saulzar has joined #ocaml
skylan has joined #ocaml
Smerdyakov has quit []
<zvrba> ok, I've found one thing that I dislike in the Ocaml standard library
<zvrba> why are the function for data structures, e.g. queue designed so that the structure comes as the *last* argument
<zvrba> for example, Queue.add 1 q
<Snark> the last?
<zvrba> instead of Queue.add q 1
<Snark> oh
<zvrba> wher q is a queue
<zvrba> it's reversed from most of the other languages
Esine has quit [Read error: 110 (Connection timed out)]
<Snark> zvrba: the question is: do you want to "add 1 to q" or "add q to 1" ?
<zvrba> ah, so it's *that* way of looking on things :)
<shrimpx> that mindset comes from the retardedness of OOP and the structure of method call.
<zvrba> yes
<zvrba> it's obvious that I've been programming in C, C++ and python for quite some time, isn't it :)
<shrimpx> i guess
<zvrba> disregarding the OO crap, IMHO, I find it more intuitive when a function operates on the data structure, that the structure operated upon comes first.
<zvrba> for example, the Hashtable.find has signature ('a, 'b) t -> 'a -> 'b
<shrimpx> that shouldn't be a standard thing to do. it leads to some things that are utterly unintuitive
<shrimpx> but whatever =)
<zvrba> I don't mind either convention, but I like having things *consistent* throughout the library
<shrimpx> wrap the queue data structure and change the call order =)
<zvrba> shrimpx: the inconsistencies are what is bugging me: look at hashtable find
<zvrba> it takes the table as its FIRST argument
<zvrba> so, as a beginner, I have to look up into the manual quite often although I know what the arguments are..
<zvrba> I just don't know the ORDER because it's .. well.. incosistent across functions
<shrimpx> heh ok
<zvrba> (hehe.. the funny thing is that after 10 years of C and C++programming I *still* don't know the order of arguments in fgets, fread and fwrite)
<zvrba> every signle time I have to look them up in the manual just to double check
<shrimpx> so what are you complaining about again?
<zvrba> the incosistency
<zvrba> in the C library.. these 3 functions are the only FILE related functions taking the file as its LAST argument
<zvrba> adn there are also incosistencies in the Ocaml std library.. I have already shown an example
<zvrba> (no, I'm not going to write a wrapper :))
ski has joined #ocaml
ski has quit [Client Quit]
ski has joined #ocaml
Enveigler_ has joined #ocaml
<shrimpx> there are two types of langauges. those that everyone bitches about, and those that no one uses
<zvrba> hahaha, good point :)
<zvrba> ok, i'm not saying it's a major shortcoming, but it is a minor.. nuisance
<Saulzar> Seems it's more natural when it comes to currying as well
<zvrba> well, it doesnt. why would I want to add the same value to different queues? more likely, I'd like to add different values to the same queue
<zvrba> but, that's just my point of view
<Saulzar> True
<Saulzar> No - I meant the other way around is more natural :)
<zvrba> aha, ok :)
<Saulzar> I noticed that too
<zvrba> i would not argue which convention is more natural, but I really appreciate _consistency_ :)
<zvrba> ok, in Ocaml it's harder to make argument position mistakes because of strict type checking
<Saulzar> I've noticed something about using mutable values... eg. as soon as I use a Hashtbl in a data structure then everything from there on down is 'infected' with being mutable
<Saulzar> Yeah, consistancy is very important ...
<Saulzar> If something is inconsistant it just wastes your time looking back and forth to the docs
<zvrba> exactly
<zvrba> now consider a library which arbitrarily switches the meanings of two arguments (e.g. starting position and length in a hypothetical string library)
<Saulzar> If there was a nice IDE with argument listing it could make something like that much less of a problem though :)
<zvrba> the type checker won't catch your mistake, but you'll lose a lot of time to figure out that you've switched the order of arguments
<Saulzar> Yeah, true
<zvrba> agreed. but Ocaml doesn't have such a HUGE std lib like Java that it is really needed
<zvrba> still, it is a bit irritating that you know all the arguments to the function, but just don't know their order :)
<Saulzar> The standard containers end up being much smaller than say.. the C++ stl
<Saulzar> Since you don't have such concepts as iterators
<zvrba> but you lose some flexibility of operating on just a part of the container.. which reminds me, a feature that I've never needed
<zvrba> almost
<Saulzar> Yeah, true..
<Saulzar> Actually I ran into that, I was trying to figure out how to implement a priority queue which was hashed as well
<zvrba> the only instance I can remember of iterating over something other than begin() to end() is after the remove() algorithm
<Saulzar> In C++/stl then I just store an iterator to an element in the queue in a hashtable
<zvrba> Saulzar: I don't get you. what do you mean hashed PQ?
<Saulzar> Well I want a PQ, but I want to be able to look up elements in O(1) time by hashing as well
<Saulzar> eg. I want to detect if an item is already in the PQ and update it rather than adding it again
<zvrba> ok, now I get it
<zvrba> :)
<zvrba> hm... interesting problem :)
<zvrba> Ocaml doesn't have a PQ in its std lib, so I guess you've implemented it yourself?
<Saulzar> I've used a set
<zvrba> doesn't == I can't find it in the reference
<zvrba> so you use Set with reverse ordering so that the greatest element is at the root of the tree?
<zvrba> greatest from POV of the PQ
ski has quit ["rogntudjuu"]
Enveigler_ has quit [Read error: 110 (Connection timed out)]
Saulzar has quit [Read error: 110 (Connection timed out)]
Saulzar has joined #ocaml
__DL__ has joined #ocaml
smimou has joined #ocaml
ski has joined #ocaml
threeve has quit []
Enveigler_ has joined #ocaml
Esine has joined #ocaml
Enveigler has joined #ocaml
Enveigler_ has quit [Read error: 110 (Connection timed out)]
petter has joined #ocaml
vezenchio has joined #ocaml
__DL__ has quit [Read error: 54 (Connection reset by peer)]
__DL__ has joined #ocaml
Boojum has joined #ocaml
Snark has quit [Nick collision from services.]
Boojum is now known as Snark
__DL__ has quit [Remote closed the connection]
ski has quit ["suck"]
ski has joined #ocaml
mikeX has joined #ocaml
mikeX has quit ["Leaving"]
Enveigler has quit [Read error: 110 (Connection timed out)]
Smerdyakov has joined #ocaml
__DL__ has joined #ocaml
Zyroth has joined #ocaml
<Zyroth> is there a command to let ocaml print out a variable to stdout regardless what its type is?
<Smerdyakov> I doubt it.
<Zyroth> but the interpreter can do it...why is there now command? :(
<Smerdyakov> If by "command" you mean "OCaml function," then clearly this function is impossible to write in OCaml. It would have to be another hacky built-in thing.
<Zyroth> ya...
* Snark wonders if it's not in the faq
Snark has left #ocaml []
__DL__ has quit [Remote closed the connection]
Zyroth has left #ocaml []
Snark has joined #ocaml
<petter> Zyroth: The interpreter knows about types, and so does the compiler, but the resulting program has no way of knowing the type of your variable
<fluxx> aren't there infact some data dumping libraries in caml hump? of course they aren't as good as the interpreter
<fluxx> I'm not sure if they are pure ocaml though. but ocaml itself provides some access too
<Smerdyakov> OCaml has built-in marshalling.
<Smerdyakov> Or it has marshalling implemented in a library that uses non-OCaml code.
<Smerdyakov> One or the other, neither very palatable. ;)
<smimou> extlib has a dump : 'a -> string function
<petter> You could make your own variant type for the types you want to handle, that would be osrt of adding your own dynamic typing
<petter> then you could make some new syntax extension to make it smoother
<petter> if you have: "type ios = Int of int | String of string"
mauke has quit [Remote closed the connection]
mauke has joined #ocaml
<petter> and: "let myprint x = match x with Int i -> print_int i | String s -> print_string s;;"
<petter> then you could define syntax transforming "let a = @ 1" and "let b = @ \"hello\"" into "let a = Int 1" and "let b = String \"hello\"" respectively
<Smerdyakov> Oh, yes, @ is much nicer. OP
<petter> I mean something like that
<Smerdyakov> Why not just use short variant tag names?
<Smerdyakov> There's no need for overloading.
<petter> just to let camlp4 do some work for you, writing "let a = Int 1" is specifying the type information twice
<Smerdyakov> So?
<Smerdyakov> "let a = N 1" is just as long as "let a = @ 1"
<petter> + I just learned how to write syntax extensions, so I have to use them all the time :-)
<petter> yes, as long, but "N 1" contains the type information twice
<Smerdyakov> Why is that bad?
<petter> I suppose it's not that bad, I just like to think up things to use camlp4 for
Zyroth has joined #ocaml
<Zyroth> Is there a parameter like "ocaml -xxx source.ml" which makes ocaml run source.ml and stay in the interpreter console afterwards?
* Zyroth didn't find anything in the help
<Saulzar> Hmm, I think ocamltop will compile a specific toplevel for you...
<Saulzar> I've not used it though
<Zyroth> okay, i'll look into it
<Zyroth> thx
<Saulzar> Sorry, ocamlmktop
<Saulzar> Probably can substitute it for ocamlc in your makefile and have it produce a toplevel
<Saulzar> Seems to work like that
Zyroth is now known as Zyr
Zyr is now known as [Zyr]
[Zyr] is now known as Zyr
Zyr is now known as Zyroth
threeve has joined #ocaml
Zyroth has left #ocaml []
Saulzar has quit ["Leaving"]
Snark has left #ocaml []
ChoJin has joined #ocaml
<ChoJin> hello
<ChoJin> anyone here for a stupid/simple question?
<mauke> maybe
<ChoJin> great :)
<ChoJin> I have a file sectioninfo.mli, module type Sectioninfo = sig type sectioninfo end
<ChoJin> then I have another file, binaryfile.mli
<ChoJin> but when I try to use Sectioninfo.sectioninfo it says
<ChoJin> Unbound type constructor Sectioninfo.sectioninfo
<petter> hmmm, doesn't type constructors have to begin with a capital letter?
<ChoJin> the module name is Sectioninfo, and the type is sectioninfo
<ChoJin> (abstract type)
<petter> Sectioninfo.sectioninfo is the type
<petter> you need som way of creating values of that type
<ChoJin> but it's an .mli, I'm just defining the interface
<petter> yes, but if it says "Unbound type constructor Sectioninfo.sectioninfo", it means you tried to create a value a think
<ChoJin> in my binaryfile.mli I have:
<Smerdyakov> .mli is not a first class citizen.
<Smerdyakov> You should put your signature in a .ml.
<ChoJin> val getSectionInfo: binaryfile -> int -> Sectioninfo.sectioninfo
<petter> ChoJin: hmm, I think that should work...
<Smerdyakov> .mli files introduce _nothing_ into the module namespace.
<Smerdyakov> They are a completely orthogonal mechanism to signatures or structures.
<ChoJin> how do I do to say "hey, there is an abstract type "sectioninfo", it doesn't matter what it is exactly"
<ChoJin> ?
<petter> hmm, I think I need to read up on those sections of the manual :-)
<Smerdyakov> type sectioninfo
<ChoJin> I'm basically doing a binaryfile loader, for PE, ELF...
<Smerdyakov> PE? Abstract IL has something related to that. :)
<ChoJin> Smerdyakov: type sectioninfo is in sectioninfo.mli
<zvrba> ChoJin: what are you using to interface Ocaml with C structs?
<ChoJin> no
<ChoJin> just plain ocaml
<zvrba> ChoJin: how do you map e.g. ELF section header to ocaml?
<zvrba> read_binary_int and friends?
<ChoJin> yes
<zvrba> uf. it must be boring to code it that way :/
<ChoJin> any better way?
<ChoJin> :)
<ChoJin> that's the beginning of a project
<zvrba> well, no. I thought you have so I asked :)
<ChoJin> it's always boring at the beginning ;)
<ChoJin> there is some research along description language
<ChoJin> for binary format
<zvrba> hm.. I'd say exactly the opposite.. it's always boring at the END.. when you are 90% finished and the rest 10% are bugs and UI polishing, etc...
<ChoJin> but there are not there yet
<zvrba> ChoJin: any links to research?
<Smerdyakov> ChoJin, type sectioninfo in file.mli only serves to hide type sectioninfo in file.ml; it _doesn't_ introduce a type.
<zvrba> I thought to start my own project along those lines
<ChoJin> zvrba: look for 'slr' simple retargeatable loader
<zvrba> ok..
<Smerdyakov> ChoJin, I already told you the solution early on: use a .ml file instead when you want to define things.
<Smerdyakov> ChoJin, .mli files only constrain .ml files.
<petter> how about using Stream parsers to parse a stream of bytes?
<ChoJin> petter: it's not always easy to defined a grammar for a binary format
<ChoJin> Smerdyakov: ok, I see, but then I have another question
<petter> no, just an idea
<ChoJin> my binaryfile.mli is basically the interface I want to enforce for different ml later. for example peformat.ml, elfformat.ml ...
<ChoJin> will it works when I will use the abstract type "binaryfile" defined from binaryfile.mli ?
<Smerdyakov> You can't do it directly. You can define a signature S in some file.ml, then define modules in other .ml files, saying they ascribe to signature File.S.
<ChoJin> I think I need to re-read some stuff about module. my mind is too OO oriented;)
<ChoJin> I basically want to define an interface, for different implementations. So, in the other part of the program, I just use the abstract type
<Smerdyakov> And I just told you how to do it. ;)
<ChoJin> yes, I'm trying to understand it :)
<Smerdyakov> Do this and it should make sense for Java: s/.ml/.java/ s/signature/interface/ s/module/class/
<Smerdyakov> Oh, and s/ascribe to/implement/
petter has quit ["BitchX-1.1-final -- just do it."]
<ChoJin> Smerdyakov: ok, after a lot of thinking: I need to have a signature Binaryfile (from "binaryfile.mli"), then I will have a few .ml which ascribe to the signature Binaryfile. But then, module which want to deal with them, will need to be parameterized. For example: module foo (bar : Binaryfile) = ...
<ChoJin> Smerdyakov: am I right?
<Smerdyakov> No.
<Smerdyakov> Change it to (form "binaryfile.ml").
<Smerdyakov> s/form/from
<Smerdyakov> And probably give the signature a different name to differentiate it from the module it lives in.
<ChoJin> I don't understand why the signature has to be in a .ml
<Smerdyakov> Because .mli files _can't_define_ANYTHING_.
smimou has quit ["?"]
ChoJin has quit [Read error: 110 (Connection timed out)]
mlh_ has joined #ocaml
ulfdoz has joined #ocaml
ulfdoz_ has quit [Read error: 110 (Connection timed out)]
Smerdyakov has quit ["bye"]