ChanServ changed the topic of #ocaml to: Discussions about the OCaml programming language | http://caml.inria.fr/ | OCaml 4.00.1 http://bit.ly/UHeZyT | http://www.ocaml-lang.org
tane has joined #ocaml
ulfdoz_ has joined #ocaml
djcoin has quit [Quit: WeeChat 0.3.7]
ulfdoz has quit [Ping timeout: 264 seconds]
ulfdoz_ is now known as ulfdoz
Developp1r has joined #ocaml
avsm has quit [Quit: Leaving.]
Developper has quit [Ping timeout: 264 seconds]
metadave has quit [Remote host closed the connection]
Jeaye has quit [Ping timeout: 264 seconds]
kmels_ has quit [Ping timeout: 246 seconds]
jamii has joined #ocaml
Anarchos has quit [Quit: Vision[0.9.7-H-090423]: i've been blurred!]
tane has quit [Quit: Verlassend]
emmanuelux has joined #ocaml
madroach has quit [Ping timeout: 244 seconds]
madroach has joined #ocaml
Developp1r has quit [Ping timeout: 252 seconds]
NaCl has quit [Ping timeout: 244 seconds]
ontologiae has joined #ocaml
ontologiae has quit [Ping timeout: 252 seconds]
jamii has quit [Read error: Connection reset by peer]
Yoric has joined #ocaml
Xizor has joined #ocaml
wormphlegm has quit [Read error: Connection reset by peer]
wormphlegm has joined #ocaml
wormphlegm has quit [Ping timeout: 255 seconds]
danblick has joined #ocaml
wormphlegm has joined #ocaml
mjonsson has quit [Remote host closed the connection]
Xizor has quit [Ping timeout: 260 seconds]
ccasin has quit [Read error: Operation timed out]
ccasin has joined #ocaml
answer_42 has joined #ocaml
tufisi has quit [Ping timeout: 246 seconds]
tufisi has joined #ocaml
Snark has joined #ocaml
Developper has joined #ocaml
BiDOrD has joined #ocaml
ankit9 has joined #ocaml
BiDOrD_ has quit [Ping timeout: 260 seconds]
rixed has quit [Ping timeout: 246 seconds]
Derander has quit [Ping timeout: 272 seconds]
Derander has joined #ocaml
Developper has quit [Ping timeout: 260 seconds]
ankit9 has quit [Ping timeout: 246 seconds]
GnomeStoleMyBike has joined #ocaml
Kakadu has joined #ocaml
sepp2k has joined #ocaml
<adrien> holy fucking crap
<adrien> I just gave up building Qt for windows
<adrien> it also reminds me what I with it as a library: qmake, moc, other tools
<adrien> and generally the "we're going to live on our own without system libs" approach
<Kakadu> windows sucks
<xaimus> moc is pretty annoying
<adrien> Kakadu: the issue here isn't windows: it's really what's inside Qt
cdidd has quit [Read error: Operation timed out]
<adrien> wrong flags to GCC/ld, an inability to handle cross-compilation properly
<adrien> not using pkg-config by default for cross-compilation too
<Kakadu> adrien: qt5? Or you are doing crosscompiling?
<adrien> 4.8.2 which is almost the latest stable, cross-compiling
<adrien> I doubt many things have changed with 4.8.3; there's simply too much to fix to put it in a point release
ulfdoz has quit [Quit: deprecated]
ulfdoz has joined #ocaml
ttm has quit [Ping timeout: 246 seconds]
kmels_ has joined #ocaml
Cyanure has joined #ocaml
hto has quit [Read error: Connection reset by peer]
hto has joined #ocaml
Yoric has quit [Ping timeout: 272 seconds]
Yoric has joined #ocaml
hto has quit [Quit: Lost terminal]
Developper has joined #ocaml
Developper has quit [Ping timeout: 248 seconds]
tane has joined #ocaml
fraggle_ has quit [Remote host closed the connection]
Vinnipeg has joined #ocaml
fraggle_ has joined #ocaml
Xizor has joined #ocaml
<wmeyer> morning
ankit9 has joined #ocaml
ankit9 has quit [Ping timeout: 252 seconds]
ankit9 has joined #ocaml
Developper has joined #ocaml
emmanuelux has quit [Remote host closed the connection]
<adrien> hi
<wmeyer> adrien: morning : hi, still doing Qt, moc stuff? moc sucks. (In polish "moc" means "power" btw.)
<adrien> wmeyer: no, gave up
<adrien> I've seen too many crappy things in 30 Minutes
<adrien> considering the size of Qt, I'd have to spend days on it
<adrien> they'll fix their own crap
<adrien> I'll only make it easy for them to see
<wmeyer> yes, it's a bit archaic code base; it's full of crap.
<adrien> fails at cross-compiling, fails at modern tools (pkg-config, yes "modern"), fails at invoking gcc
<wmeyer> :(
* julm scared by that moc power thing :s
pango_ has joined #ocaml
pango has quit [Ping timeout: 246 seconds]
<adrien> you've never done anything with Qt?
<adrien> it parses C++ source files to generate code for QObjects
<wmeyer> fortunately I don't even remember, so maybe i didn't deal with MOC too much, the moc is a meta programming facilyt for slots and signals
<wmeyer> AFAIK
<adrien> yup
ontologiae has joined #ocaml
ankit9 has quit [Ping timeout: 252 seconds]
djcoin has joined #ocaml
<wmeyer> adrien: the idea is nice, but we know nice ideas will often be covered by layers of crap.
<adrien> :-)
<wmeyer> qmake is also not my cup of tea.
<adrien> iirc I found moc had no advantage
Vinnipeg has quit [Ping timeout: 248 seconds]
<adrien> well, you can find the slots and signals in the object hierarchy iirc but that was not useful and didn't catch errors
GnomeStoleMyBike has quit [Ping timeout: 246 seconds]
ankit9 has joined #ocaml
ankit9_ has joined #ocaml
ankit9 has quit [Ping timeout: 246 seconds]
Obfuscate has quit [Ping timeout: 256 seconds]
Drakken has quit [Ping timeout: 256 seconds]
Obfuscate has joined #ocaml
Drakken has joined #ocaml
Submarine has joined #ocaml
othiym23 has quit [Read error: Operation timed out]
othiym23 has joined #ocaml
djcoin has quit [Quit: WeeChat 0.3.7]
mjonsson has joined #ocaml
Haseo has quit [Read error: Connection reset by peer]
Haseo has joined #ocaml
kmels_ has quit [Ping timeout: 260 seconds]
pango_ is now known as pango
kmels_ has joined #ocaml
Kakadu has quit [Quit: Konversation terminated!]
<wmeyer> adrien: are you one of these heros, who want to bring Qt bidings to OCaml? or just packaging qt with yypkg?
Xizor has quit [Quit: So yes it's mIRC under wine under debian double peche capital. ;) I'll soon see in kfreeBSD.]
Yoric has quit [Quit: Instantbird 1.3a1pre -- http://www.instantbird.com]
Yoric has joined #ocaml
ontologiae has quit [Ping timeout: 244 seconds]
mrm has joined #ocaml
<adrien> wmeyer: I'm packaging Qt with yypkg
<adrien> Qt doesn't fit my mind
<adrien> I don't think having bindings for ocaml would make it more usable to me (I've only dabbled with the C++ API)
<mrm> Hello. Can anyone tell me if the latest version of Batteries (the 2.0, which does not depend on Camomile) is useable for production?
<mrm> I want to get rid of Camomile, because it's a pain on Windows :-(
<wmeyer> mrm: but you don't want unicode or you want?
<wmeyer> I mean trunk worked fine; and i was suprised that it didn't have unicode modules anyway; i was that lucky person who wanted to use unicode and upgraded batteries to trunk
<wmeyer> mrm: that was some while ago, and the project was relatively small
<mrm> wmeyer: I don't really need any functionality of Camomile. On Windows it's problematic to distribute binaries dependent on Camomile because it requires some database located on the filesystem
<mrm> "Fatal error: exception Failure("Cannot find camomile database directory ... " :-(
<wmeyer> mrm: Batteries has a testsuite, best to talk to thelema
<mrm> wmeyer: The testsuite ran without a hitch, but I found out that the latest Batteries is not compatible with 1.5
<mrm> and wanted to know if it's worth the effort to port my code to 2.0
<wmeyer> do you have much code dependent on batteries?
<mrm> wmeyer: Several projects, none of which compile with 2.0
<wmeyer> I mean I don't know when the next version of batteries will be released, i cant tell it from gihub
<mrm> wmeyer: I'm currently trying to port one of the smaller projects to 2.0
Neros has joined #ocaml
Developper has quit [Ping timeout: 252 seconds]
<mrm> Well, I have my own extensive testsuites (for my projects). If they pass, then I'll give the latest batteries a try :-)
<wmeyer> mrm: :-)
mcclurmc has joined #ocaml
NaCl has joined #ocaml
NaCl has quit [Changing host]
NaCl has joined #ocaml
tac has joined #ocaml
Neros_ has joined #ocaml
Neros has quit [Ping timeout: 246 seconds]
danblick has left #ocaml []
tac has quit [Quit: Page closed]
tac has joined #ocaml
ankit9_ has quit [Quit: Leaving]
cdidd has joined #ocaml
Neros has joined #ocaml
<vbmithr> Hi
<vbmithr> Do anybody knows how to pass the -ppopt -lwt-debug argument to ocamlfind through ocamlbuild ?
Neros_ has quit [Ping timeout: 240 seconds]
mjonsson has quit [Ping timeout: 260 seconds]
gnuvince has quit [Ping timeout: 260 seconds]
mjonsson has joined #ocaml
<mrm> wmeyer, thelema: Wow. I seem to have stumbled into a bug in the newest batteries. Map.union _always_ throws Not_found
xavierm02 has joined #ocaml
<xavierm02> hey
<xavierm02> is someone there?
<mrm> xavierm02: Yeah. Hello.
<xavierm02> hi
<xavierm02> I have a problem
<xavierm02> I kind of totally new to ocaml and try to get it to read some input
<mrm> xavierm02: What kind of input are you trying to read?
<xavierm02> 3 4
<xavierm02> oo
<xavierm02> o o
<mrm> Ok.
<xavierm02> o o\
<xavierm02> and i did this
<xavierm02> let n = Scanf.scanf "%d " ( fun x -> x ) in
<xavierm02> let m = Scanf.scanf "%d\n" ( fun x -> x ) in
<xavierm02> let pins = Array.init n (fun _ ->
<xavierm02> read_line( )
<xavierm02> ) in
<xavierm02> print_int (n)
<mrm> Scanf.bscanf Scanf.Scanning.stdib "%d %d " (fun a b -> ... )
<xavierm02> it works
<xavierm02> but
<mrm> Yeah. It should work.
<xavierm02> i cant give it a file
<xavierm02> i would like to do
<xavierm02> cat 1.txt | ocaml thing.ml
<xavierm02> but it give
<xavierm02> exception
<xavierm02> en of file
<xavierm02> end*
<mrm> Use Scanf.bscanf and provide a file handler as the first argument
<CmrPantoufle> xavierm02: simpler: <file1.txt ocaml thing.ml
<xavierm02> nah
<xavierm02> i cant do that
<xavierm02> this program
<xavierm02> will be send to another server
<xavierm02> that will give it the input
<xavierm02> not the filename
<xavierm02> :/
<mrm> xavierm02: You solve acm-style problems?
<CmrPantoufle> Huh, seems to be down
<xavierm02> idk what acm is
<CmrPantoufle> oops
<xavierm02> gona google it
<mrm> xavierm02: The ones when you have to send a program to an online judge system?
<mrm> xavierm02: e.g. codeforces.com, spoj.pl and alike
<xavierm02> yeah
<mrm> I did it with OCaml and had no problem with IO whatsoever
<xavierm02> well
<xavierm02> the site i need to send it to
<xavierm02> won't give me a filename
<xavierm02> so
<xavierm02> it should "work" with what i wrote
<mrm> It gives you input through stdin, right?
<xavierm02> yes
<xavierm02> so it should work
<xavierm02> but i dont know
<xavierm02> how to myself give it input though stdin
<mrm> It should.
<xavierm02> i thought
<xavierm02> cat file.txt | ocaml thing.ml
<xavierm02> would work
<xavierm02> but it doesnt
<xavierm02> i can do
vpm has joined #ocaml
<xavierm02> ocaml thing.ml
<xavierm02> and then write all the input
<mrm> xavierm02: Perhaps you forgot the last newline in a file?
<xavierm02> but since i'll have to test amny times
<xavierm02> this is kind of long
<xavierm02> i just added 10 linmes at end of file
<xavierm02> still doesnt work :/
<xavierm02> i think
<xavierm02> it just doesnt get the file at all
<mrm> xavierm02: Send a program somewhere, please. To slexy.com, for example
<mrm> xavierm02: I'll have a look
pango has quit [Ping timeout: 248 seconds]
<xavierm02> it must have something to do with the Array.init n
<xavierm02> because if i only leave
<xavierm02> let n = Scanf.scanf "%d " ( fun x -> x ) in print_int (n)
<xavierm02> in the thing.ml file
<xavierm02> it works
<mrm> Perhaps there is not enough input in your file. Try debugging the problem with print statements (not forgetting to flush IO)
<mrm> xavierm02: I have stumbled upon similar problems when using OCaml in codejam. Once you learn of the corner cases, IO becomes as trivial as trivial it is when using other popular contest-programming languages
<xavierm02> i think
<xavierm02> it might be scanf
<xavierm02> that goes through the whole file
<xavierm02> for some reason
<mrm> xavierm02: Don't think so. Most probably there is a bug in your program or there is not enough data in the input file
<xavierm02> if i remove line 3
<xavierm02> it works
<xavierm02> if not
<xavierm02> the program fails
<xavierm02> T.T
<mrm> Ok. Let me see
<xavierm02> here is the input file i use
<xavierm02> i have tons of new lines at the end
<xavierm02> but pastebin removes empty lines apparently
pango has joined #ocaml
jamii has joined #ocaml
<madroach> hi, is it possible to define this type: type t = < id :int64; .. > ? I get an unbound type variable error in this type declaration.
<mrm> xavierm02: Yeah. Seems to be that Scanf functions break read_line. The following trick works:
<mrm> let my_read_line () = Scanf.bscanf Scanf.Scanning.stdin "%s\n" (fun x -> x)
ankit9 has joined #ocaml
ontologiae has joined #ocaml
<mrm> xavierm02: or "let my_read_line () = Scanf.scanf "%s\n" (fun x -> x)"
<madroach> hmm, never mind. was just confused by the manual...
<mrm> xavierm02: also, I would have written your program in a such way: http://slexy.org/view/s2zso2OPMz
<mrm> xavierm02: those (fun x -> x) are ugly :-)
<xavierm02> thank you very much :)
<xavierm02> (And I'm just starting so I wanted to get things to work before making them look better ^.^)
<xavierm02> I have another question
<mrm> xavierm02: Is it possible to use third party libraries in the competition you participate in? I'd strongly suggest you to use Batteries -- an alternative standard library. OCaml's standard library is just waaay too tiny and limiting for the needs of programming contests. It'd force you to reinvent the wheel over and over again, in each competition :-(
<xavierm02> welll
<xavierm02> i dont think i does
<xavierm02> but it doesnt have extraordinary needs
<xavierm02> mainly simple stuff
<xavierm02> at least at this stage
<xavierm02> so
<xavierm02> i have my string "o o"
<xavierm02> how can I transform that into a list
<xavierm02> of 1 and 0
<mrm> xavierm02: Limited standard library is the main reason why I sometimes prefer Haskell instead of OCaml for programming contests :-(
<xavierm02> well
<xavierm02> I'm not sure that's I'll use Ocaml
<mrm> xavierm02: I'd use a String.map function
<xavierm02> in next stages
<xavierm02> but i need to learn it anyway
<mrm> String.map (function | ' ' -> 0 | 'o' -> 1) str
<xavierm02> but
<xavierm02> if i use this
<xavierm02> when
<xavierm02> then
<xavierm02> i dont get an array / list
<xavierm02> i get another string
<xavierm02> so when I'll compare things
<xavierm02> it'll have to do some useless conversion
<xavierm02> no?
<xavierm02> here is the thing i need to solve
<xavierm02> i get a bunch of lines
<xavierm02> with spaces and o
<xavierm02> and i must make sure
<xavierm02> that if i take two lines
<xavierm02> they only have one o in common
<xavierm02> so i was thinking
<xavierm02> i transform them into lists
<mrm> xavierm02: in common = in one column?
<xavierm02> yeah
<xavierm02> but
<xavierm02> only for 2
<xavierm02> o o
<xavierm02> oo
<xavierm02> oo
<xavierm02> for example
<xavierm02> if you take two
<xavierm02> you always have exactly one whole in common
<xavierm02> i woudl tranform that into
<mrm> xavierm02: Sure, why not. Transform both into lists, then make List.combine (to get a list of pairs), then List.filter (to find adjacent zeros), then List.count
<xavierm02> [1, 0, 1]
<mrm> and check if it's 1
<xavierm02> yeah
<xavierm02> but how do i tranform into lists?
<xavierm02> i have to do a loop etc.?
<mrm> String.to_list
<xavierm02> i wouldve thought there would be a function for that
<xavierm02> meh
<mrm> xavierm02: Oh, wait. It's a function from Batteries!
<xavierm02> it's not listed in here
<xavierm02> ah
<mrm> xavierm02: There is no such function in the std
<xavierm02> >_<
<mrm> And that is an example of why Std sucks so much
<adrien> Std?
<mrm> It misses lots of useful functions
<mrm> Standard library
<adrien> ah, ok
<adrien> it doesn't suck; it's limited on purpose
<mrm> adrien: Yeah :-(
<mrm> xavierm02: Got to go. Cya!
<xavierm02> cya
<adrien> I really wish there was a function to run a command and read its output
<adrien> should be available out of the box
ankit9 has quit [Quit: Leaving]
mrm has quit [Ping timeout: 252 seconds]
tani has joined #ocaml
tane has quit [Ping timeout: 246 seconds]
rickmeizter has joined #ocaml
<rickmeizter> hey guys
<rickmeizter> i'm doing some homework but i've been stuck for hours on something i'm sure it's really stupid
<rickmeizter> and I can't wrap my head around it
<rickmeizter> can anybody give me a hand?
<rickmeizter> basically, the exercise asks to define the function exp x n with the exponentiation by squaring algorithm
<rickmeizter> to obtain x^n
<rickmeizter> i've looked at the solution
<rickmeizter> but i don't see how it can be working
<rickmeizter> and so i would need someone to help me understand how the code works, mixing pattern matching with parameter omission in the fun statement
<xavierm02> well
<xavierm02> post it somewhere
<xavierm02> like pastebin
<xavierm02> and give us a link
<rickmeizter> thank you
<rickmeizter> here you go http://pastebin.com/NystETY5
<xavierm02> well
<xavierm02> what is it you dont get?
<xavierm02> first
<xavierm02> you define
<xavierm02> exp x
<xavierm02> if you get 0 as second argument
<xavierm02> you give 1
<xavierm02> and then
<xavierm02> in the two other cases
<rickmeizter> mostly the part where n is used as a pattern for match to x
<xavierm02> no
<xavierm02> you're not defining
<xavierm02> the function exp
<xavierm02> you're defining the function exp x
<xavierm02> i think
djcoin has joined #ocaml
<xavierm02> im not that experienced
<rickmeizter> you mean e^x?
kmels_ has quit [Ping timeout: 245 seconds]
<xavierm02> normaly
<xavierm02> you use
<xavierm02> function n = ...
kmels_ has joined #ocaml
<xavierm02> and you think
<xavierm02> it is function x
<xavierm02> but it is not
<xavierm02> the x
<xavierm02> is before the function keyword
mrm has joined #ocaml
<xavierm02> you do pattern matching
<xavierm02> on your second argument
<xavierm02> I don't get what you don't get >_<
<xavierm02> write the code
<xavierm02> the way you think it should be
<xavierm02> and I might be able to explain
<rickmeizter> ok
<xavierm02> @mrm : I got it working
<xavierm02> at least the IO
<xavierm02> now I can try to make it more cute
<xavierm02> any ideas?
<xavierm02> <- afk eating for 10min
<mrm> xavierm02: Stop placing parenthesis on separate lines. They make my eyes bleed :-)
<rickmeizter> here's how I'd do it http://pastebin.com/T1fcNU7K
<wmeyer> made my cry today
<rickmeizter> please excuse me for using ^ as the math operator
<mrm> rickmeizter: Are you sure that OCaml won't calculate n mod 2 twice?
<rickmeizter> what do you mean?
<wmeyer> is it possible at all to install pandoc? that needs first order logic inference engine to know.
<rickmeizter> I don't know if that code I just posted works, it's just to represent my idea of how I'd do it
<mrm> rickmeizter: I talk about efficiency. I'm not sure that such kind of a pattern-match sequence is going to be optimized
<mrm> Just being picky :-)
<rickmeizter> oh okay :)
<rickmeizter> well i just started yesterday
<rickmeizter> I just need to get the hang of it
<rickmeizter> and then I will surely have an eye for that as well
* wmeyer joins haskell to ask how to install package or what to do next
<adrien> uninstall haskell :P
<wmeyer> adrien: I need pandoc.
<adrien> wmeyer: heheh, you have to love dependencies in package managers :-)
<wmeyer> adrien: cabal seems to take this dependencies to extreme :-)
<wmeyer> i am not sure if it's not a bug in cabal
<wmeyer> or...
<adrien> I believe repositories should never get into such states: public repos should always be consistent and never ever make it possible for users to have conflicting versions
<adrien> if a conflict can arise, it's not ready
<adrien> (and if you use backports, you're shooting yourself in more than the foot)
<wmeyer> adrien: but that's a pristine version of haskell straight frome debian, i have done cabal upgrade too.
<wmeyer> maybe there is .cabal directory in ~ i am sure there is ~~~
<adrien> I hate most package managers which I consider over-engineered, trying to do too much, and answering the wrong questions
<adrien> well, good luck, crêpes-time \o/
<wmeyer> adrien: thanks for mental support
* wmeyer calling an ambulance anyway
<wmeyer> with my biggest hope: removing .cabal didn't help!
Developper has joined #ocaml
* wmeyer being ignored on haskell. Cabal question? OCaml? or ... ?
ontologiae has quit [Ping timeout: 260 seconds]
<mrm> wmeyer: Why not install Pandoc from the Debian repos?
<mrm> I did so and it works beautifully
rickmeizter has quit [Ping timeout: 255 seconds]
<wmeyer> mrm: I need the newest version
<wmeyer> but i am ok with haskell distro from their website
djcoin has quit [Quit: WeeChat 0.3.7]
<xavierm02> should clarify a few things
sepp2k1 has joined #ocaml
sepp2k has quit [Ping timeout: 260 seconds]
olasd has quit [Ping timeout: 260 seconds]
Kakadu has joined #ocaml
olasd has joined #ocaml
kmels_ has quit [Ping timeout: 265 seconds]
ng__ has joined #ocaml
emmanuelux has joined #ocaml
Cyanure has quit [Remote host closed the connection]
<ng__> how i use while loop in ocaml??? for example : let i=1; while (i <c) do printf("*"); i = i + 1 done;;
<ng__> Is it correct?
* Kakadu never used while loops
<Kakadu> but
<Kakadu> try this
<Kakadu> let i = ref 1 in while !i < c do incr i; done;
<ng__> ok
<ng__> let me see
<ng__> ;D
Dettorer has quit [Quit: WeeChat 0.3.8]
Developper has quit [Ping timeout: 248 seconds]
jbrown__ is now known as |jbrown|
<ng__> omg, i love this channel ;D
<|jbrown|> ng__: while loops are pretty unusual in ocaml code IMO :-)
<ng__> thanks Kakadu
<ng__> yes, but i need practise ;D
<|jbrown|> you know you can use "for i = 1 to c [...]" right? :-)
<ng__> so in this moment i use every loops
<ng__> :D
<ng__> yes
<|jbrown|> ok
* |jbrown| stops interfering :-)
<ng__> ;D
<ng__> thanks |jbrown|
Developper has joined #ocaml
Snark has quit [Quit: Quitte]
sgnb has quit [Read error: Connection reset by peer]
sgnb has joined #ocaml
ImAlsoGreg has quit [Quit: Leaving]
Neros has quit [Read error: Connection reset by peer]
Neros has joined #ocaml
<mrm> wmeyer: I actually had to fix an extremely tricky bug in the latest Batteries before my project's testsuite ran succesfully :-) And it was one of the smaller projects (4k lines)
<mrm> At least I'm going to contribute something back this way :-)
RichN has quit [Ping timeout: 256 seconds]
<wmeyer> mrm: nice!
<mrm> wmeyer: Did you know that "(==) == (==) -> false"?
<mrm> Or that "compare == compare" evaluates to false?
<tac> mrm: were you expecting any meaningful answer for testing if two functions were the same?
RichN has joined #ocaml
<tac> At best, you can do pointer-equality on functions
<mrm> It turns out that different occurences of external primitives are actually different closures during runtime
<tac> at worst, the problem is undecidable
<mrm> tac: Well, these are externals!
<tac> ah, does ocaml actually *do* pointer equality on functions?
<wmeyer> mrm: we should not rely on a functiona equality as tac says
<tac> (I actually find that kinda surprising :)
<mrm> tac: Yes, there is a physical comparison operator (==)
milki has left #ocaml []
<wmeyer> to add (==) is a bit special too
<mrm> wmeyer: Well, (==) is used in Batteries here and there. We have to carefully check each use of the physical comparison operator. It's somewhat tricky
<wmeyer> mrm: I'm not entirelly convinced by the changes you propose to the Batteries
<wmeyer> it looks to me you rely that p_compare will not be inlined, of course now mayb it works
Developper has quit [Ping timeout: 256 seconds]
<mrm> wmeyer: Well, some functions didn't work either way
<wmeyer> and it's very fragile to compare functions anyway, if there is a functional value then you want just implement your own OrderedType
<mrm> wmeyer: For example, polymorphic Map.unite was broken
<mrm> wmeyer: If one needs better static guarantees, one is free to use a functorized interface to Maps
<wmeyer> mrm: it would be better to mention in PMap doc if ever it happens that the user wants to do this, then it's required to use Map with the appropriate module passed
<mrm> wmeyer: The whole point of polymorphic maps is not being required to define a module
<wmeyer> mrm: I agree, but it's a bad practice. There is no compeling reason to not use functorised interface apart from the performance :-)
<mrm> I often find PMaps to be adequate for my uses
<wmeyer> yes, but then if you do define your data type including functionals they are already special
<wmeyer> for instance marshalling is already special, comparision is already special
<mrm> wmeyer: Less typing, less code :-) I want to be able to build prototypes faster. That's why I love polymorphic structures and variants :-)
<wmeyer> mrm: I agree but then you can pass compare functions to be on a safe side
<wmeyer> i really don't like the idea of comparing functional values :-)
<wmeyer> it should not possible at the type level/compilation level
<wmeyer> but then == should not be polymorphic
<wmeyer> and then we hit the problem of requiring some sort of overloading
<mrm> Me neither. I also don't understand in which case one could probably need a map unification/merge procedure that'd work on maps with different comparison functions :-)
<wmeyer> Standard ML has a hack. Haskell has deriving and type classes.
Developper has joined #ocaml
<mrm> I only need a simple PMap with a wired in Pervasives.compare function
<mrm> If I'd ever need to specify a comparison function (I sometimes need), then I'd use the functorized interface
<xavierm02> i have a question
<xavierm02> I have a set of things
<xavierm02> and I need to compare them to one another
<xavierm02> with a symetric binary relation
uselpa has joined #ocaml
<xavierm02> so what I
<xavierm02> do
<xavierm02> is i have two loops
<xavierm02> and check for every combinaison
<xavierm02> but
<xavierm02> I think it would be way better to check it recursively
<xavierm02> set_with_n_elements = set_with_n-1_elements + element
<xavierm02> and i could have a function that would check a set
<xavierm02> one that would check an element against a set
<xavierm02> and one that would check two elements
<xavierm02> and I know how to do that
<xavierm02> but I am using lists
<xavierm02> and I have no idea how to detect if they are emptyu
<xavierm02> in another language
<xavierm02> it would be
<xavierm02> list.head == null
<xavierm02> or something
<xavierm02> but apparently
<xavierm02> if you ask for the head of an empty list
<xavierm02> you get an exception >_<
<xavierm02> ah
<wmeyer> xavierm02: if lst = [] then ... else ...
<wmeyer> or better
<xavierm02> i just though
<xavierm02> i could use length
<xavierm02> but that woudl suck
<xavierm02> cuz geting length
<xavierm02> is O(n)
<wmeyer> match lst with [] -> ... | case1 -> ... | case2 -> ...
<xavierm02> ty :)
<xavierm02> is there a way
<xavierm02> to do
<xavierm02> math lst with [ head, rest... ] ->...
<wmeyer> mrm: actually your patch maybe makes sense in the setting where PMap should do it best to compare reliably, but a hack for documentation would be probably required to let the users of PMap know.
<xavierm02> or something?
<wmeyer> of course
<wmeyer> match lst with head :: rest -> ...
<xavierm02> with that syntax?
<xavierm02> ok
<xavierm02> ty
<wmeyer> match lst with [first_element; second_element] -> ...
<wmeyer> assuming in the second case your list has just two elements.
<wmeyer> if you want to match first two elements and rest
<wmeyer> then
<wmeyer> match lst with first_element :: second_element :: rest -> ...
<wmeyer> which is the same as
<wmeyer> match lst with first_element :: (second_element :: rest) -> ...
<mrm> wmeyer: Sure. It needs to be made very clear to the users that polymorphic containers are dangerous tools which should be used with caution. When I was new to OCaml, I thought that PMaps and PSets from Extlib are the way to go (and surely got my ass burned on several occasions, before learning of all the gritty corner cases).
<wmeyer> mrm: I agree. This http://ocaml-batteries-team.github.com/batteries-included/hdoc/BatMap.html should highlight the cases where it might fail very badly
<wmeyer> it mentions they are not safe
<wmeyer> but adding a sentence or two saying that definitely it's unsafe to use if for the functional values would be great.
tac has quit [Ping timeout: 245 seconds]
Tobu has quit [Quit: No Ping reply in 180 seconds.]
Tobu has joined #ocaml
cdidd has quit [Read error: Connection reset by peer]
<xavierm02> is head :: tail the only way of matching a list of arbitrary length?
<xavierm02> or is there another way of doing it
<xavierm02> if you don;t actually need those two elements?
<xavierm02> _ :: _ ?
andreypopp has joined #ocaml
<adrien> yes, yes
<adrien> you can also _head :: _tail
<adrien> it names the values but indicates you're not going to use them
<adrien> it's handy to show intent
<mrm> wmeyer: The fix which I hacked up has nothing to do with users putting functional values into maps (that'd be quite dangerous with both Maps and PMaps). It is an entirely internal problem which arises when using certain functions (union, diff, intersect) on polymorphic maps. I just propose a hacky workaround to make it work somehow. A proper solution would involve decoupling the code of polymorphic maps from the code of functorized maps
<mrm> to get rid of all the "comparison function comparisons" :-). Perhaps I will do it.
tac-tics has joined #ocaml
<xavierm02> ok
<xavierm02> yet another question
<xavierm02> how can I differentiat
<xavierm02> a list containing lists
<xavierm02> from a list containing interger?
Developper has quit [Quit: leaving]
<adrien> the type system will do it
<adrien> what do you want to do that for?
<xavierm02> well
<xavierm02> i have items
<xavierm02> pins
<xavierm02> and i want to do a function
<xavierm02> no
<xavierm02> i have a binary relation
<xavierm02> between pins
<xavierm02> R( pin1, pin2 ) = true or false
<xavierm02> and
<xavierm02> i want a function
<xavierm02> that would take sets of pins
Neros has quit [Ping timeout: 264 seconds]
<xavierm02> or a pin and a set
<xavierm02> or two pins
<xavierm02> and return whether
<xavierm02> for each combinaison of elements
<xavierm02> R( pin1, pin2 ) is true
<xavierm02> I could do it with 3 functions
<xavierm02> but I find is cooler to do it with one ^.^
<xavierm02> plus I'm doing it to learn anyway
<xavierm02> example
<xavierm02> R(a, b) = true = R(b,a)
<xavierm02> R(a,a) = false = R(b,b)
<xavierm02> so
<xavierm02> f( a, b ) = true
<xavierm02> f( {a, b }, a ) = false because R(a, a ) = false
<xavierm02> f( { a, b }, {a} ) = false for the same reason
<xavierm02> and I represent sets with lists
Neros has joined #ocaml
Tobu has quit [Ping timeout: 260 seconds]
uselpa has quit [Remote host closed the connection]
<ng__> ( n != exponentiation(2)) how i write this in ocaml??
<|jbrown|> the mathematical exponent? Like e^n? "n <> exp 2.0"
Neros has quit [Remote host closed the connection]
Tobu has joined #ocaml
<ng__> |jbrown|, exactly, but a friend mine, said to me something i can use for the exponent with "**"....
<|jbrown|> ** is "pow" in C
<|jbrown|> whereas exp is exp
<ng__> ah ok ;D
<ng__> thanks
cdidd has joined #ocaml
Anarchos has joined #ocaml
<mrm> ng__: By the way, one should be very careful when using equality comparisons with floats. That is almost always a wrong way to go
<ng__> mrm, Oo
<ng__> This expression has type float but an expression was expected of typ
<ng__> I´m trying to solve this ...
<mrm> ng__: Paste the expression you are trying to evaluate
avsm has joined #ocaml
<mrm> xavierm02: Extremely confusing explanation of a problem :-)
andreypopp has quit [Quit: sleep]
<ng__> mrm, for example this : " if ( n != 15.5 ** 2.0 ) then "
<mrm> ng__: It works for me. Provide the complete error message.
<mrm> "This expression has type float but an expression was expected of typ" ... -> what next?
<adrien> != is the wrong operator
<adrien> you would want <>
<adrien> but as previously stated, don't compare floats for equality
<adrien> floats are not exact values
<mrm> Yeah, but he shouldn't get a type error, unless n is not a float
<adrien> adding one and then substracting one to a value might give a different value
jave has quit [Ping timeout: 260 seconds]
<adrien> agreed but good luck getting any (==) equality over floats
<ng__> "This expression has type int but an expression was expected of type float"
<adrien> then 'n' is an int
mnabil has joined #ocaml
<mrm> ng__: != operator requires that its operands to be of the same type
<mrm> ng__: same with other standard infix functions
<ng__> let me see the code mrm
<ng__> it´s better put the code here...
<mrm> ng__: n is an integer in your program
<mrm> and "15.5 ** 2.0" is a float
<mrm> n is an integer because read_int has a signature of [unit -> int = <fun>]
<Anarchos> mrm as read_int gives the hint ;)
<mrm> ng__: the result of ** is a float because the signature of ** is [float -> float -> float = <fun>]
<mrm> ng__: and == is ['a -> 'a -> bool = <fun>]. That is, it expects its arguments to be of the same type
<ng__> yes, but I put as int and equal appears
<ng__> the same message
<mrm> ng__: Because the compiler doesn't understand how to match an int, a float and an equality operator which expects its arguments to be of the same type
<mrm> ng__: I suggest you to read some introductory text on the ML type systems
<ng__> ah ok :D
<ng__> it´s better read
<ng__> ;D
<ng__> thanks
<wmeyer> ng__: Hold on, you have two things to remember: == is equal to comparing by reference in Java or pointers in C++. From standard primitives types nly ints can be compared equaly good with == because they are values not references. Floats are boxed - they are locations on heap, so the == will compare the pointers. = however will compare always the values by traversing into the structures and following it's values. So use always
<wmeyer> exceptions when you want to know if the OCaml values refer to the same location. != is reverse ==, and <> is reverse =. So for floats you need = and <>, plus adrien 's remark that in case of floats standard rules obey - don't check for equality by bits but by epsilon intervals.
<mrm> *I suggest that
<mrm> (tricky verb)
answer_42 has quit [Ping timeout: 276 seconds]
<wmeyer> ng__: apart from that I suggest like ng__ have suggested, reading some good explanatory book about the type system, it might help you understand basic concepts
<mrm> Standard exceptions are checking for NaN's and for zeros (in some very rare cases) :-)
<wmeyer> mrm: I think floats are equaly controversial as polymorphic equality operators :-)
avsm has quit [Quit: Leaving.]
jave has joined #ocaml
<mrm> wmeyer: Yeah. I currently have to deal with code ripe with direct float comparisons (there are some "special" constants like -999.25). It's full of ridiculous float-specific bugs :-(
<ng__> ah ok, thanks... i understand what you said to me :D... sorry for writing too little, but my English is not the best ;D
<wmeyer> ng__: no problem, enjoy :-)
<ng__> :D
jave has quit [Read error: Operation timed out]
<mrm> wmeyer: I had to fix another bug to make my second project pass the tests with the latest Batteries
<mrm> Perhaps there are some more subtle bugs which haven't been detected by my testsuites :-( I think it's currently way too early to switch to the newest Batteries for production work. It took a long time for the 1.x branch to become truly stable.
<wmeyer> mrm: it's best then to send a pull request to approriate people with these bugfixes. Ping thelema, he will be very happy to see these bug fixes.
<mrm> wmeyer: Oh. I somehow thought you were one of the Batteries guys
<wmeyer> mrm: if it's possible I would personaly have a shot with 2, and try to port your bigger programs, and then report back problems.
<wmeyer> mrm: No, I'm not :-)
ontologiae has joined #ocaml
<mrm> wmeyer: By the way, aren't you Wojciech Meyer, the author of DragonKit?
ontologiae has quit [Client Quit]
<wmeyer> mrm: yes
<mrm> wmeyer: Ok. I ask because there is another fp-related wmeyer: https://github.com/wmeyer
<wmeyer> mrm: oh yes
<wmeyer> not this one
<wmeyer> ;)
<wmeyer> mrm: I notice it, but this nick is for legacy reasons.
<mrm> wmeyer: One day I may ask you something about SSA back-translation and register coloring
<mrm> But not right now, because its 3:51 am in my part of Russia
<wmeyer> mrm: happy to answer, dragonkit has very bad coloring algorithm at the moment.
<wmeyer> it's a prototype really, and BTW: the repo is not up to date to be 100% honest
<mrm> wmeyer: I found it to be confusing and hard to follow
<wmeyer> mrm: 3:51 is reasonable. It's sunday isn't ?
<wmeyer> mrm: it's not too bad, once you know the basics
<wmeyer> mrm: but there are some details and optimsations that makes it more fun
ng__ has quit [Quit: Leaving]
<mrm> wmeyer: I know the basics and have designed several optimizing compilers, which are actually used in industry
<mrm> Some time ago I've studied DragonKit to learn how to structure a compiler in OCaml
<mrm> And how to represent graph structures :-)
<wmeyer> mrm: wow, thanks for looking into the code.
<wmeyer> mrm: actually i am impressed anybody bothered ...
<wmeyer> OCaml is really pleasant to write a compiler
<mrm> wmeyer: Not sure about that. I find OCaml to be extremely limiting due to lack of a proper lisp-style macro system
<wmeyer> mrm: in fact the DragonKit already contains a stack of DSLs
<wmeyer> and yes, there will be a lot code generated
<wmeyer> mrm: you are a lisper?
<mrm> I spend shitloads of time debugging my half-assed camlp4 extentions :-)
<wmeyer> mrm: pretty cool.
<wmeyer> mrm: know vsl?
<mrm> (ast visitor generators and such)
<wmeyer> mrm: you surprise me now.
<wmeyer> mrm: I worked on the same
<mrm> wmeyer: I've heard of a person who is known as vsl in Russia, but I don't know him personally
<wmeyer> just sunday
<wmeyer> mrm: Vitaly
<wmeyer> yes, that's my friend.
<wmeyer> mrm: visitors are very important for the compilers!
<mrm> wmeyer: I'm not exactly a lisper, just a person who is very much interested in comptuter languages
<mrm> And OCaml most certainly inspired me in many ways
<wmeyer> mrm: Camlp4 *is* limiting, and full blown dsls are costly
<mrm> wmeyer: I prefer my dsls to be simple and composable
<mrm> This is difficult to achieve with camlp4
<wmeyer> good choice
<mrm> OCaml is lightyears behind Racket in the metaprogramming department
<wmeyer> mrm: I agree, but it has static type system and ADTs
<mrm> But I still enjoy static typing and especially the module system
<wmeyer> oh yes
<Anarchos> mrm why not using cc1 as macro preprocessor ?
<mrm> wmeyer: Typed Racket also has all of this. It's just not as polished
<wmeyer> definitely "lone wolf operations" in Lisp usually equals to crusade in OCaml.
<mrm> Anarchos: You mean... the C preprocessor? :-P
<wmeyer> mrm: if you talk about getting production quality code into the productiona actually.
<Anarchos> mrm yes
<mrm> Anarchos: I have my of source transformation systems. They aren't as powerful as a proper lisp-style macro system
<mrm> *my own
<Anarchos> mrm what is your need exactly ?
<mrm> Anarchos: composable DSLs
<wmeyer> Anarchos: cpp is fine for simple things. mrm talks about extending the language in the same language, stacking dsls, embeding them etc.
<mrm> Preprocessors like camlp4 are just way too clunky to use in practice
<Anarchos> wmeyer does he chase the golden egg chicken ??
<wmeyer> Anarchos: sorry, it's a bit beyond my understanding, what do you mean?
<mrm> Anarchos: I want to spend less time programming stupid boilerplate code
<wmeyer> mrm: DSLs and code generation is great for compilers
<mrm> wmeyer: Not just for compilers, for everything
<wmeyer> mrm: it's barely possible to write a good compiler without it. or risking sanity by throwing 2MLOC like Clang/LLVM
<wmeyer> mrm: yes, they are best abstraction.
<wmeyer> mrm: Agree, but OCaml is already very expressive alone.
<wmeyer> we use a lot code generation at the moment, in the Draon framework, and we try to keep it like this.
<Anarchos> wmeyer it is a french sentence to say he wants something ompossible
<wmeyer> Anarchos: and we are not chasing chickes or dragons :-)
<mrm> wmeyer: My latest project has been an implementation of a python-style dynamic language targeted at inexperienced users
<mrm> It includes several DSLs
<mrm> e.g. a DSL for defining systems of nonlinear equations
<mrm> or a DSL for building a simple gui
<wmeyer> mrm: you talk like VSL
<mrm> and users (which are not programmers, but physicist) actually find these DSLs to be convienient and intuitive to use
<wmeyer> :-) that's actually the biggest compliment you can get.
<wmeyer> mrm: yes, it's needed to define easily domain specific languages targetted for some domain
<wmeyer> (compilation of these is another topic too)
<wmeyer> having intermediate representations defined in similar way, is closely related
<wmeyer> transforms of these, like is also
<wmeyer> combining them like stacking dsls, too!
<mrm> wmeyer: Unfortunately, my choice of tools has made me a hardly replaceable person at my current job :-(
<mrm> It's a Delphi shop
<mrm> And I stuck an intricate piece of OCaml machinery inside the core of a huuuge legacy application written in Delphi :-(
<wmeyer> well i don;t work full time either on any of my tools.
<wmeyer> compile OCaml to Delphi!
<wmeyer> and escape
<mrm> I actually started implementing a simple ML dialect that is compiled to Delphi
<mrm> with global type inference and ADTs and pattern matching
<wmeyer> usually that's what happens to people like you
<wmeyer> they are not-replacable
<mrm> Yeah, I plan to escape. This part of Russia is extremely boring
<wmeyer> plus they develop their own tools that are either, never used by anybody else (Lisp curse) or used at work only by them
<mrm> Yeah. I've developed tons of strange tools here
<wmeyer> mrm: because they allowed you
<wmeyer> at my work, this attemtpts will be proffesinally twarted :-)
<mrm> e.g. a documentation generator, a test framework, a gui generator
* Anarchos thinks that all russian programmers are totally weird and mad
<wmeyer> mrm: full on darkside
* wmeyer polish programmers are also mad, and equally evil and funny.
<mrm> wmeyer: They didn't expect a student to finish the project. Now my module is making money and they can't get rid of me easily :-)
<wmeyer> mrm: yeah, congrats.
<mrm> I don't know whether to be happy or sad.
<wmeyer> mrm: well now you are stuck, in the industry.
<wmeyer> mrm: is a win/lose situation.
<mrm> wmeyer: I hate this industry (oil/gas)
<wmeyer> mrm: Understood!
<mrm> Its all politics
Neros has joined #ocaml
<wmeyer> you should have a beer with vsl
<mrm> wmeyer: Who exactly is vsl?
<mrm> I sometimes hear of him here and there
<xavierm02> Sorry to interupt but do you have any idea while this thing http://pastebin.com/K24Dkt8C
<xavierm02> line 12, characters 32-144:
<xavierm02> Error: This expression has type bool but an expression was expected of type
<xavierm02> 'a list -> bool
<xavierm02> gives this error?
<wmeyer> you missed an argument
<xavierm02> i cant find it >_<
<wmeyer> just a sec
<wmeyer> well you have check_set tail tail
<wmeyer> where check_set is a single arg function
<xavierm02> thank you!
<wmeyer> i would need to feed it to repl, maybe there are other problems
<wmeyer> xavierm02: you welcome.
mnabil has quit [Ping timeout: 256 seconds]
Jeaye has joined #ocaml
<xavierm02> List.fold_left2 ( fun prev i1 i2 -> i1 * i2 + prev ) 0 pin1 pin2 ) = 1
<xavierm02> any idea why it woudl cause a syntax error?
<Anarchos> xavierm02 you miss a (
<wmeyer> or rather sporius )
<xavierm02> ty :)
<xavierm02> i must be tired >_<
<xavierm02> it nearly works
<xavierm02> the result is false
<xavierm02> but it doesn't give errors
<xavierm02> ^.^
<wmeyer> latest 4KB demo of my friend: http://www.youtube.com/watch?v=2UgbKQKD9I4 <--- have failed to convert him to OCaml! :-)
<wmeyer> \o/
Anarchos has quit [Quit: Vision[0.9.7-H-090423]: i've been blurred!]
Yoric has quit [Ping timeout: 240 seconds]
tac-tics has quit [Ping timeout: 245 seconds]
emmanuelux has quit [Excess Flood]
mathieui has quit [Ping timeout: 245 seconds]
Yoric has joined #ocaml
emmanuelux has joined #ocaml
Kakadu has quit [Ping timeout: 246 seconds]
Submarine has quit [Ping timeout: 255 seconds]
<xavierm02> cya
<xavierm02> ty very much for your help :)
xavierm02 has quit [Quit: Leaving]
tani has quit [Quit: Verlassend]
sepp2k1 has quit [Read error: Connection reset by peer]
mnabil has joined #ocaml
kmels_ has joined #ocaml
wormphle1m has joined #ocaml
wormphlegm has quit [Ping timeout: 252 seconds]