dark_light changed the topic of #ocaml to: OCaml 3.09.2 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/
mpc has quit []
pango_ has joined #ocaml
swater has quit ["Quat"]
mpc has joined #ocaml
pango has quit [Remote closed the connection]
sponge45 has quit ["zzzzzzzzzz"]
Leonidas has quit ["An ideal world is left as an exercise to the reader"]
bluestorm has quit ["Konversation terminated!"]
quarkalone_ has joined #ocaml
quarkalone_ has quit ["Abandonando"]
malc_ has quit ["leaving"]
Smerdyakov has joined #ocaml
johnnowak has joined #ocaml
johnnowak has quit []
sponge45 has joined #ocaml
johnnowak has joined #ocaml
m3ga has joined #ocaml
Smerdyakov has quit ["Leaving"]
m3ga has quit ["disappearing into the sunset"]
sponge45 has quit ["zzzzzzzzzz"]
batdog|gone is now known as batdog
llama33 has joined #ocaml
danly has joined #ocaml
mpc has quit []
Morphous is now known as Amorphous
b00t has joined #ocaml
sponge45 has joined #ocaml
danly has quit [Remote closed the connection]
ikaros has quit [Read error: 60 (Operation timed out)]
danly has joined #ocaml
ikaros has joined #ocaml
llama33 has left #ocaml []
pauldia has joined #ocaml
pauld has quit ["leaving"]
pauld has joined #ocaml
dibblego has quit ["Leaving"]
dark_light has joined #ocaml
<dark_light> is there any set_of_list or set_of_array in stdlib?
Skal has joined #ocaml
pauld has quit ["leaving"]
pauld has joined #ocaml
pauld has quit [Client Quit]
pauld has joined #ocaml
pauld has quit [Client Quit]
pauld has joined #ocaml
ikaros_ has joined #ocaml
ikaros has quit [Read error: 110 (Connection timed out)]
rashnu has joined #ocaml
<rashnu> Hello, could someone take a look at a code snippet and help me out? Can't figure out what's wrong with it
<rashnu> i've pasted it here http://nopaste.php-q.net/255208
<dark_light> rashnu, what it should do? heheh
<dark_light> do you tried to debug?
<rashnu> the error it gives is this
<dark_light> i got a bunch of warnings,
<rashnu> This expression has type (int * (string * int) list) list
<rashnu> but is here used with type (int * (string * int)) list
<dark_light> and a unexistent flatten function
<rashnu> hum?
<dark_light> it's List.flatten?
<rashnu> yes
<dark_light> Hm
<rashnu> i have open List;; and open Str;;
<rashnu> forgot to include those
<dark_light> well your dec function isn't passing on toplevel warnings
<rashnu> it's pattern matching warnings
<dark_light> about "should have type unit" and "pattern not exaustive", i think you are missing something
<dark_light> rashnu, that's ok?
<dark_light> you might want to use the ignore function
<dark_light> and a _ final pattern
<dark_light> rashnu, well i will try to understand your error
<rashnu> what's the ignore function? Sorry, i'm new to ocaml, started coding this week :p
<dark_light> it's just fun x -> ()
<dark_light> so if you do: 1; print_endline "test", you should do: ignore 1; print_endline "test"
<dark_light> rashnu, and you do not need those ;;, you need them only in toplevel =)
<rashnu> yea, i have them as i was working on toplevel
<dark_light> why you have a string in the dec parameter?
<dark_light> let dec ("ch", v) ("ch1",v1) = if "ch"="ch1"
<dark_light> it just don't make sense
<dark_light> "ch" isn't a variable, it's a constant value
<rashnu> because of the way p1 is declared
<rashnu> oh
<rashnu> i wanted to use the string passed earlier
<rashnu> the one from p1
<dark_light> so you should use a named variable
<dark_light> btw, do you speak portuguese?:)
<rashnu> yea
<rashnu> i'm portuguese :p
<dark_light> i was thinking you were from UFRN
<rashnu> from where? :p
<dark_light> because it's the only university i know that uses ocaml to teaches programming
<dark_light> rashnu, from here :) Natal, Brazil
<rashnu> ah
* dark_light still don't get the point
danly has quit ["Leaving"]
<rashnu> hm..
<rashnu> you speak portuguese? if you do will be easier to explani
<dark_light> but you are using "multiplica_componente" where you should have used multiply_component
<rashnu> yea, i was translating the names of the functions to english
<rashnu> so people could understand better
<rashnu> forgot to change that one
<dark_light> ehehehehehe
<rashnu> let's talk in priv msg in portuguese, easier
pauldia has quit ["Leaving"]
bluestorm has joined #ocaml
_JusSx_ has joined #ocaml
dark_ has joined #ocaml
_fab has joined #ocaml
<dark_> dark_light, boo
dark_light has quit [Connection timed out]
microcape has joined #ocaml
dark_ has quit [Client Quit]
dark_light has joined #ocaml
dark_ has joined #ocaml
dark_ has quit [Read error: 104 (Connection reset by peer)]
Schmurtz has joined #ocaml
sponge45 has quit ["zzzzzzzzzz"]
johnnowak has quit []
dark_ has joined #ocaml
dark_light has quit [Connection timed out]
dark_ is now known as dark_light
slipstream-- has joined #ocaml
dark_light has quit [Read error: 104 (Connection reset by peer)]
dark_light has joined #ocaml
slipstream has quit [Read error: 110 (Connection timed out)]
bluestorm has quit ["Konversation terminated!"]
swater has joined #ocaml
Leonidas has joined #ocaml
Leonidas has quit [Read error: 104 (Connection reset by peer)]
Leonidas has joined #ocaml
<dark_light> does anyone know why module FloatMap = Set(struct type t = float let compare = compare) don't works? there are any similar syntax to make a "module closure"?
<dark_light> i don't want really to make a OrderedFloat module :(
<dark_light> (the name should be FloatSet, heh)
b00t has quit [Client Quit]
<pango_> you forgot and "end"
<pango_> s/and/an/
<pango_> also it's Set.Make, not just Set
<pango_> module FloatSet = Set.Make(struct type t = float let compare = compare end)
<dark_light> wonderful
pauld has quit ["leaving"]
malc_ has joined #ocaml
Oxyd has joined #ocaml
pauld has joined #ocaml
pauld has quit ["leaving"]
buluca has joined #ocaml
pauld has joined #ocaml
pauld has quit [Client Quit]
pauld has joined #ocaml
pauld has quit [Client Quit]
pauld has joined #ocaml
pauld has quit [Client Quit]
swater_ has joined #ocaml
pauld has joined #ocaml
swater has quit [Read error: 110 (Connection timed out)]
pauld has quit ["leaving"]
pauld has joined #ocaml
pauld has quit ["leaving"]
pauld has joined #ocaml
Oxyd has quit ["Vanitas vanitatum et omnia vanitas."]
dark_ has joined #ocaml
bluestorm has joined #ocaml
<dark_light> anyone want take a look on my little simulator?=) http://nopaste.tshw.de/1163946634ddbdf/ it's a poor gravitational simulator
<bluestorm> hum
<bluestorm> why "sqrt epsilon_float" ?
<bluestorm> ah
<bluestorm> ok
<bluestorm> you don't want epsilon² to be 0
<dark_light> hmmm, i don't want somethinglittle * epslion to be 0
<malc_> dark_light: in ( X% ) i would go for pattern matched version instead of repeatedly using fst/snd.. and for speed i would go with records
<dark_light> malc_, i though the fst/snd would be compiled in pattern matching
<bluestorm> (what's your language where "vector" is "vetor" ?)
<dark_light> portuguese :)
<bluestorm> ok
<malc_> dark_light: less typing
<bluestorm> hm
<dark_light> malc_, ahahahaha
<dark_light> malc_, why records?
<malc_> dark_light: ocaml has special "optimized" represetation for records with only float fields
<malc_> dark_light: faster
<bluestorm> let ( -% ) (a1, b1) (a2, b2) = a1 -. a2, b1 -. b2
<dark_light> hmm yes
<bluestorm> hm
<dark_light> malc_, wow
<pango_> dark_light: it's not for performance in that case, but rather for readability :)
<dark_light> malc_, but the same applies to arrays, not? and tuples too as tuples are represented as arrays
<bluestorm> let ( -% ) {a = a1; b= b1)} {a = a2; b= b2} = {a = a1 -. a2; b = b1 -. b2 }
<bluestorm> ^^
<malc_> dark_light: for arrays yes, for tupples no (to the best of my knowlege)
<malc_> knowledge rather
<dark_light> pango_, i was using fst and snd in the places i putted the -%, so i was just redoing what was being done ad-hoc, not much thinking about it
<dark_light> malc_, hmmmmm
<dark_light> well i was early using type vetor = { x = float; y = float } and using in the code p.pos.x and etc, but i though acessing things in the middle of code was unecessary
<dark_light> oops, mutable
<dark_light> malc_, the same things apples to vectors with mutable fields?
<dark_light> records
<dark_light> applies
<dark_light> :)
<malc_> dark_light: yeah
<pango_> malc_ seems correct that floats are boxed in tuples... http://caml.inria.fr/pub/old_caml_site/ocaml/numerical.html
<malc_> ocaml is funny when performance of floating point stuff is concerned
swater_ is now known as swater
<bluestorm> hm
<dark_light> what is exactly "boxed"?
<bluestorm> but dark_light, why would you need mutable fields ?
<bluestorm> mutable is a bit evil :-°
<dark_light> bluestorm, well, you are saying about the mutable field : campo ?
<dark_light> because i need to make it depends the position
<dark_light> just because i am lazy
<dark_light> bluestorm, i can't make depending on position unless the record is already set
<dark_light> (and, well, otherwise i must make a generic field function that receives the origin position and the destiny position)
dark_ has quit [Read error: 104 (Connection reset by peer)]
<pango_> dark_light: I think you should replace *% with scalar multiplication
<dark_light> even in p.pos <- p.pos +% (p.vel *% Const.epsilon_pair) ?
<Schmurtz> dark_light, floats are stored in memory as a structure containing a tag specifying that it's a float, followed by the float value
<dark_light> i tried to make this look like /\s = v*/\t
<dark_light> Schmurtz, it's a "boxed" float?
<Schmurtz> it allow the garbage collector to know that it's a float and not a pointer to another sructure
<Schmurtz> dark_light, I think it's what mean "boxed"
<pango_> dark_light: you need to build Const.epsilon_pair in the first place because of your bizarre *%
<pango_> (I wonder if it has a mathematical name)
<dark_light> :)
<dark_light> pango_, i though it was a constant
<dark_light> no, i am sure
<pango_> floats need to be boxed because they're usually bigger than a "word"
<dark_light> :o
<dark_light> pango_, in C they are boxed?
<pango_> C is not garbage collected
<dark_light> ah
<pango_> and doesn't support polymorphism
<dark_light> i am thinking why i need to know if something is float at memory level
<dark_light> if the compiler knows if something is float, it can build a "organic" garbage collector that is specialized in knowing that variable is a float :)
<pango_> to support polymorphism, all values must have a common format... in OCaml that's a word (word with tag 1 for direct values, tag 0 for pointers)
<dark_light> hmm..
<pango_> OCaml's GC doesn't know about program types
<dark_light> i was reading some insane things about genetic algorithms
<dark_light> but i don't saw any code (yet)
<pango_> let ( *%) (x, y) k = (x *. k, y *. k) then p.pos <- p.pos +% p.vel *% Const.epsilon
<dark_light> ocaml's GC seems to be too.. static, i think the GC should be modified with each variable, at compile time, to know exactly what is the needs of each of it
<dark_light> pango_, i don't need the () ?
<pango_> you can read the paper on the site showing that the performance is about the same
<dark_light> performance of what? your *% and mine?
<pango_> and making the Gc unaware of program's types losen their dependancy, which is a good thing
<dark_light> ah
<pango_> dark_light: you don't need the parenthesis, the priority of infix operators depends on their first character
<pango_> dark_light: +% has the same priority as +, *% has the same priority as *, so everything goes fine
<dark_light> !!!!
<dark_light> pango_, it is just odd
<pango_> dark_light: the performance between type aware and type unaware garbage collectors
<dark_light> + is after * in ascii character?
<pango_> what does that have to do with operators precedence ?
pauld has left #ocaml []
<dark_light> pango_, but.. but.. well, i am fascinated with some "organic" ideas on computing, i think it's a good idea to bring it to compilers..
<dark_light> pango_, well, there must be a "general rule" to operators
<dark_light> or a mini-nonalpnanumeric-table with all precedence :)
pauld has joined #ocaml
<pango_> sure, in user manual
<dark_light> where is the user manual?
<dark_light> ah
<dark_light> that manual, i never seen a table there
<pango_> I don't know what you mean by "organic"
<dark_light> hmm i think i mean using some nondeterministic ways to generate the code
<pango_> mmh I can find associativity, but still looking for priorities...
<pango_> dwim compiler ? thanks, but no thanks
<Schmurtz> perhaps the definition order
<dark_light> dwin?
Smerdyakov has joined #ocaml
<Schmurtz> DWIM = Do What I Mean
<pango_> ah, correct "The constructions with higher precedence come first"
<pango_> dark_light: Do What I Mean
<dark_light> the program doesn't need to compile in the way you expect, it needs just to be correct
<pango_> a compilation is a translation, so if the result is different from what you expect, it means the translation is faulty
<dark_light> a good "code generator" could achieve better performance than the programmer (well it's what i think)
<dark_light> pango_, a functional program is just a semantic description
<dark_light> the compiler can handle the things the way it wants
<pango_> as long as the semantic is preserved, yes
<dark_light> yes, that is :)
<pango_> that's basically what compilers do today, I don't see how the non-deterministic behavior of your "organic ideas" will get better performance. Computers being basically deterministic, non deterministic behavior must be "emulated"
<dark_light> another idea i currently have is: you don't need to know how a list is represented. a list of ints may be represented as an array, as an linked list, or in a odd way the evolutionary generator thinks is better
<pango_> so far "organic" sounds like "magic" :)
<dark_light> pango_, hmm, but the idea is.. generate random code that does what you mean, and eliminate the worse
<bluestorm> :D
* dark_light is talking about: genetic algorithms
<bluestorm> hm
<dark_light> pango_, for me it's still magic :) (but i plan to learn this!)
<bluestorm> i heard of something like that
raspberry-lemon has quit [Read error: 110 (Connection timed out)]
<mellum> dark_light: well, you at least need to know the time complexity of the operations, or you'll write inefficient code.
<bluestorm> a VM can change its parameters at runtime
<pango_> will genetic algorithm come to sqrt(n) space efficient implementation of vectors after you teach them about list and array implementations ?
<bluestorm> pango_: but for example
<bluestorm> you know, there is an usual trick when using quicksort
<dark_light> pango_, well ahaha it may (with compression)
<bluestorm> it's using a simple sort to the small arrays
<dark_light> if it thinks space is a problem, not time
<bluestorm> (one in square time, but with a very little constant factor)
<bluestorm> the length of a "small" array may vary
<pango_> dark_light: well O(sqrt n) wasted space, actually
<bluestorm> 8, 32, and so on
<dark_light> mellum, if the compiler manages complexity, it may find a good structure to do my code with lower complexity
<bluestorm> usually, librairy writer have to do a static choice
<bluestorm> but they could say to the compiler that it's a parameter
<dark_light> pango_, mmmm why? arrays has O(n) space
<bluestorm> and let him choose the good one but guessing what you'll use the sort for
<mellum> dark_light: you don't want to rely on that in the real world.
<bluestorm> s/but/by/
<dark_light> mellum, not in the current real world
<dark_light> :D
<dark_light> bluestorm, yes, that's a simple idea
<pango_> dark_light: dynamic arrays (aka vectors)
<dark_light> what is the space complexity? trying to find..
<dark_light> Stacks can be implemented in O(1) worst case time per operation, and O( p n) worst case extra storage.
<dark_light> didn't understand what is O(p n)
<pango_> p.3 "The extra storage at any point in time is O(sqrt n), which is shown up to a constant factor."
pauld has left #ocaml []
Yorick has joined #ocaml
<dark_light> hm
<dark_light> well how store something in sqrt space? :o
<dark_light> well, if infinite monkeys types in infinite typewriters during an infinite time, they will eventually write the entire hamlet (and make comments between the pages in ocaml syntax! :)
<pango_> it's a bound on wasted space, not used space
<dark_light> ah
<pango_> and during that time, they'll use cpu cycles :)
<dark_light> when you have an infinite time, it isn't actually a problem
<pango_> and thrash cpu caches
<pango_> I'm afraid I don't
<dark_light> well, it's a compiler problem
Oxyd has joined #ocaml
<dark_light> and the cpu-intensive compiling would be needed only in final realeases of popular softwares
<dark_light> The ocamlopt compiler is poorly named because it basically does not optimize the user's code. That is, everything will be executed pretty much as written in the source.
<dark_light> hey :(
<pango_> minesweeper ?
<pango_> well, I agree it would be cool if we could get away with learning algorithmics, but I'm still skeptical ;)
<Yorick> dark_light: Opinions differ.
<dark_light> Yorick, well, sure
<dark_light> pango_, well, i want to abstract things more and more :(
<dark_light> i don't like to concern about actual implementation, it's too linked to real world for me :)
<bluestorm> do the cleanest thing you can at your level
<Smerdyakov> dark_light, use MLton instead. It does a plateful of optimization.
<dark_light> Smerdyakov, well, i may try, but, but.. :P
<Smerdyakov> dark_light, what?
<dark_light> nothing
<dark_light> the differences about list and array simply annoys me :(
<dark_light> i am with an implementation that uses a variable only to do List.iter or Array.iter, doesn't matter. i am not sure what is better (and i am not actually concerned; i am using arrays, i think)
<dark_light> i think the compiler could do a better job for finding the better structure, because it really doesn't matter for me
<Yorick> dark_light: Very few compilers will do such a choice for the user. Perhaps for very high level languages such as SQL or SETL, where the user has limited control.
<dark_light> Yorick, you are right. well, if i designed a language, i would first make a deterministic compiler, for those that want control
<Yorick> dark_light: What do you mean by determinstic compiler? One that always gives the same result for a given input? Most compilers do that.
<dark_light> Yorick, i was thinking: i could generate random programs that makes what the user wants and doing some evolution based on these
<dark_light> i read that a programmer made a sorting algorithm that way, and that algorithm was very good
<Yorick> dark_light: Ah. That is a very interesting approach, and probably lots of fun. But I don't know how useful it is in practice :)
<dark_light> Yorick, well i am reading a book that is actually to say this is useful (among other things)
<dark_light> and i am very fascinated, and, wow, that's funny too :)
<dark_light> s/funny/fun/
<Yorick> dark_light: Yes, I've heard fascinating stories where genetic algorithms have proven useful in special cases at least.
<Smerdyakov> You don't need genetic algorithms for that, as a variety of SQL servers show.
<dark_light> Smerdyakov, well so what you need?
<Smerdyakov> Read a book on RDMSs and see. :)
<dark_light> rdm?
<Smerdyakov> RDBMS, I mean.
<dark_light> (btw the book is http://www.amazon.com/gp/product/0684868768 )
<dark_light> relational dbs?
<Smerdyakov> Yes
<dark_light> i didn't knew that sql is so cool
<dark_light> Smerdyakov, it must be a very deep dark magic
<dark_light> i need to read a entire book just to have a glance what it is :)
<Yorick> dark_light: cool is definitely not the word for sql, but databases is a multi-billion dollar industry so there are very strong incentives in making it go fast.
<dark_light> well i basically hate the idea of sending the code and the data in the same string
<dark_light> or in other words, data "embedded" in the code string
<pango_> look at placeholders
<dark_light> placeholders? another DB query format?
<pango_> no, in SQL queries
<pango_> '?'
<dark_light> hmmm
<dark_light> well if there were a really good api that ensure safety i would use sql
<pango_> it does
<dark_light> Hm
<dark_light> pango_, the "sql api" i know produced "WHERE 1 = 1" in php code
<dark_light> (that basically explains why i don't think php is safe)
<pango_> is that the only reason...
<dark_light> it's a strong evidence :P
<dark_light> i was thinking in doing a type-safe api for ocaml just to learn some more of sql
<Yorick> dark_light: I think there's an ocamlp4 hack for sql somewhere - perhaps you have seen it?
<dark_light> no, and, cool :)
<Yorick> http://merjis.com/developers/pgocaml <- one implementation, and links to others
<dark_light> o_o
<dark_light> how it made the 'a -> string function?
<Smerdyakov> Yorick, I think the "cool" most certainly _os_ the word for SQL.
<dark_light> Smerdyakov, (os?)
<Smerdyakov> dark_light, and conflation of code and data in transmitting SQL queries has never been necessary. The earliest versions have completely safe ways of using parameterized queries.
<Smerdyakov> os->is
<dark_light> Smerdyakov, but what i see is that in php scripts you always needs to filter the data you get.. (yes, php is my only experience with sql)
<Smerdyakov> dark_light, right, PHP has nothing to do with best practices for anything.
<dark_light> well, is good to know sql may be safe
<Smerdyakov> SQL is fundamentally safe.
<Smerdyakov> It's PHP that isn't.
<dark_light> Yorick, the insert function don't know nothing about $name or $salary, so it must know a way to convert "any type" to string, that annoys me
<Yorick> dark_light: Sorry, I don't know how that code works. Are you sure they are not required to be strings implicitly?
<dark_light> hmm no
<dark_light> insert "Ann" 10_000_l None;, , 10_000_l is an int32, it must be a lowlevel code
<dark_light> or camlp4 has some magic
<dark_light> #
<dark_light> # Many data types are not implemented. I am adding them as I use them. Adding a data type is pretty simple: look at /usr/include/postgresql/catalog/pg_type.h to find the OID for your type, edit pGOCaml.ml:name_of_type function to add the appropriate OID to type name mapping, and then add two functions type_of_string and string_of_type to perform the translation to and from strings.
<dark_light> Hmmmmmm
<dark_light> Very fun :)
<Yorick> yes
<dark_light> but still not 'a -> string
<dark_light> i am about to discover that magic function someday
buluca has quit ["Leaving."]
batdog is now known as batdog|gone
quarkalone_ has joined #ocaml
<quarkalone_> hi
<quarkalone_> I'm looking for help with streams and parsers
<dark_light> quarkalone_, what is your problem?
<quarkalone_> thanks!. I'm writing a parser using streams and when I compile with ocamlc -pp camlp4o test.ml I get a Stream.Error("'and' or 'in' expected (in [expr])")
<dark_light> well, i don't know how to use streams with [<>] syntax
<quarkalone_> Is there another way ?
<dark_light> ps: well hmm actually we are talking about Genlex, right?
<pango_> quarkalone_: could you paste the offending code to some nopaste site ?
<dark_light> the module Genlex has an alternative way to handle [< >] parses (that is a bit more verbose and inconvenient but is written in ocaml)
<dark_light> (well at least the signature is in ocaml, :)
Schmurtz has quit ["Plouf !"]
<quarkalone_> well... what I'm looking is a very simple example of using streams for a hand writing parser, but i'm lost with camlp4.
<flux__> dark_light, you could implement "magic datastructures" with a library that would provide a datastructure that would allow you to do "everything"..
<flux__> then the library would perform profiling (or do some magic with callgraphs) and decide the appropriate datastructure
<flux__> no actual compiler trickery involved..
<dark_light> flux__, are you saying about the genetic algorithm thing or the 'a -> string thing?
<flux__> but that would be a cool library ;)
<flux__> no
<flux__> uh
<flux__> the genetic one
<dark_light> ah
<dark_light> that's interessing, but *still* very static
<pango_> quarkalone_: an example: http://nopaste.tshw.de/1163958411b6865/
<flux__> I'm sayung it wouldn't maybe have to be genetic optimizer..
<bluestorm> flux__:
<dark_light> i wanted something that the programmer of the compiler/library could not do directly, eg. millions use-cases
<dark_light> each with an especific data structure
<flux__> dark_light, it could also perform profiling runtime and switch datastructures on-fly
<dark_light> flux__, hmm..
<bluestorm> some people had done something where you could compile your program in a special profiling mode, then give it a lot of example input data, and then use the profiling data to re-compile the program with strong specialized optimizations
<quarkalone_> thanks pango_ !.
<dark_light> bluestorm, maybe the program may have a "memory" of use cases, just like spam filters
<flux__> bluestorm, I've heard only about stuff related to branch prediction optimization.. which iks still quite tame ;)
Zeitgeist has joined #ocaml
<flux__> but, the andrea boccelli concert is about to begin, better close the irc (just had to mention ;))
<dark_light> he is doing a concert in your home? (just had to ask)
<setog3> I have this error what can I do : The type of this expression, ('_a * '_b list) list -> ('_a *
<setog3> contains type variables that cannot be generalized
<setog3> when I do a ocamlc
<bluestorm> setog3:
<bluestorm> could you show the code ?
<bluestorm> ( http://pastebin.be )
<pango_> setog3: the type of some things couldn't be determined before the end of the file... It's often solved by giving some type hints, for example
<quarkalone_> thanks bluestorm. I'll study the samples.
<setog3> thx, but if I do that I loose genericity no ?
<pango_> setog3: actually it's already lost, inferred types are weak types
<setog3> ok :/
<pango_> setog3: so if functions are supposed to be polymorphic, you have a bigger problem
<bluestorm> weak type often append where manipulating mutable variables
<setog3> functions not realy need to be polymorphic
Leonidas has quit ["An ideal world is left as an exercise to the reader"]
<pango_> (hard to tell without actually seeing code :) )
<setog3> i'll put all in the same file
dark_light has quit [Remote closed the connection]
dark_light has joined #ocaml
<setog3> another quick question, how to compile a ml with a load module .cmo ?
<setog3> please
<Smerdyakov> What does that mean?
<pango_> you mean, that depends on another (already compiled) module ? ocamlc othermodule.cmo module.ml ?
<setog3> yes pango I love you !!
<Smerdyakov> NO, pango is MINE!!
<pango_> *g*
rashnu has quit [Read error: 104 (Connection reset by peer)]
jajs has joined #ocaml
<Yorick> Does anyone know on what level functions are inlined in ocaml?
<Yorick> I'm trying to understand why inlining a polymorphic function doesn't make it monomorphic.
<Zeitgeist> Scuse me, but what do you call inlining a polymorphic function ?
<Yorick> Zeitgeist: say, let lt a b = let inner x y = x < y in inner a b
bluestorm is now known as bluestorm_aw
<Yorick> here, inner is polymorphic, but small enough to be inlined (and it will be).
<Yorick> but if we change this to let lt (a:int) b = ..., then lt is monomorphic
<Yorick> but will still inline the polymorpic version of inner
<Zeitgeist> but as far as I know, inlining occurs during compilation time ?
<Yorick> Zeitgeist: Exactly. So the compiler knows statically the types of everything involved.
<Zeitgeist> yes.
<Zeitgeist> so the compiler can replace in the 'main' functions, every calls to 'inlined' functions. Doing that, it will use the type informations to do it 'correctly', isn't it ?
<Yorick> but it doesn't.
<Zeitgeist> in what sense ?
<Yorick> Let's simplify: consider the two definitions: let f a b = a < b;; let g a (b:int) = f a b
<Yorick> Zeitgeist: Here, f is polymorphic ('a->'a->bool) and g monomorphic (int->int->bool).
<Yorick> Zeitgeist: But when f is inlined into g, it's inlined as a polymorphic function.
<Zeitgeist> ah ok
quarkalone_ has quit ["Abandonando"]
<Zeitgeist> but during compilation, the infered type 'should' be discarded : the code produced by the compiler doesn't carry type annotations, isn't it ? So, even if the polymorphic function is inlined (and I don't know how you can say it's inlined), it's not wrong ?
<Yorick> No, but it is a missed opportunity and generates worse code than it could.
<Smerdyakov> Conclusion: Use MLton instead. :)
<Yorick> So you get the silly situation that f is int->int->bool, but contains a call to the generic "less_than" comparison routine.
<Zeitgeist> ok
<Zeitgeist> Then, i understand :)
johnnowak has joined #ocaml
<Yorick> Zeitgeist: I meant g instead of f in the last sentence, but you seem to have understood that :)
bluestorm_aw has quit [Read error: 110 (Connection timed out)]
<Zeitgeist> yeah, no problem
<Zeitgeist> it's interesting
<Yorick> pango_: Thank you
<pango_> looking for "inlining" in caml mailing list gives some interesting results (well, actually looking for anything in the caml mailing list gives interesting results :) )
<Yorick> pango_: Yes, that's true.
<Yorick> pango_: The message you showed just retold the problem, but didn't explain why it exists.
<malc_> heh.. first hit on gg.. and im right there spreading wisdom
<Smerdyakov> Yorick, the OCaml team isn't really concerned about optimization, that's why.
<Yorick> pango_: If it's very difficult to do for some deep reason, I'd like to know.
<malc_> and it uses.. fp records.. peculiar day
Skal has quit [Read error: 104 (Connection reset by peer)]
<pango_> (some of the answers to previous msg)
swater has quit ["Quat"]
<Yorick> pango_: Thanks. Unfortunately, I found no explanation at all in the answers - the one that came closest referred to binary compatibility with external modules, and that only makes sense if ocaml can inline functions defined in separately compiled modules (can it?)
<Yorick> pango_: Even so, it only indicates a bug in the external representation and would in any case not affect functions in the same compilation unit.
jajs has quit [Remote closed the connection]
<pango_> it does
rillig has joined #ocaml
<pango_> I wonder if the answer is not "use MetaOCaml" (multistage programming) http://caml.inria.fr/pub/ml-archives/caml-list/2003/10/a7723a0e7c90bd6cbf8e4e5e50cc4401.en.html
<Yorick> pango_: That's cool, I didn't know that.
<Yorick> pango_: Maybe it is, but I don't see why multistage programming would be necessary for this.
<pango_> yes, it gives/require more control to/from the programmer :)
<Yorick> pango_: I mean, even c++ can do this (with all its faults)
<pango_> there's more people working on c++ compilers...
<Yorick> pango_: But typically they write them in c++, which is quite a handicap :)
<Smerdyakov> Look, the social development model for OCaml is just deeply flawed. If you care about performance, you shouldn't be using OCaml.
<Yorick> pango_: You are good at searching the archives. Very neat
<pango_> Yorick: actually I stumbled on the last one just at the right time ;)
<pango_> I'm still looking at "inlining" occurences
<Yorick> pango_: The question is then how inlinable functions are stored in the .cmx files. For reasonable performance, they should be stored as source or parse trees, but definitely not as compiled native code.
<pango_> as you asked before, it's related to the moment inlining happens in the compilation process
<pango_> and I don't know the answer
<Yorick> pango_: Thanks for your searching skillz anyway.
Lectus has joined #ocaml
<pango_> I'm trying not to c&p too many URLs in the channel; I guess you can search for "inlining" and find the gems yourself :)
<Yorick> pango_: Yes of course, now you have showed me where to look.
Lectus has left #ocaml []
<malc_> Yorick: they are stored as AST
<Yorick> malc_: I'm happy to hear that. It should permit the compiler in theory to monomorphise the function, should it not?
<malc_> Yorick: sure
<Yorick> malc_: Thank you for the good news. It would be tempting to fix the compiler, but maybe there are problems I haven't thought of.
<malc_> Yorick: correction though, it's not the first pass AST. it's the ulambda (more or less) from asmcomp/clambda.ml
<malc_> been a while since i last touched all of this
<Yorick> malc_: I suppose I have some reading to do. I found article by Bjørner, _Minimal Typing Derivations_, that looks promising.
<malc_> Yorick: my interest of inlined function spured from a different source, so i wouldn't be of any help, with whatever is that you are trying to accomplish
<Yorick> malc_: Good native code, mostly :) Whence are your interests in them?
<malc_> Yorick: dynamic linking
<Yorick> malc_: Ah.
<Smerdyakov> Yorick, so you are just ignoring my suggestions to use MLton, or what?
<malc_> Smerdyakov: MLton might be a tad bit heavyweight for regular use don't you think?
<Smerdyakov> malc_, so use SML/NJ the rest of the time.
<malc_> Smerdyakov: wonderful, wonderful and what's most important very practical advice
<malc_> shrug
Oxyd has quit ["Vanitas vanitatum et omnia vanitas."]
vitriol___ has joined #ocaml
vitriol___ has quit [Client Quit]
jajs has joined #ocaml
jajs has quit ["Quitte"]
<flux__> dark_light, no, actually I used mobile irc from the concert hall
Skal has joined #ocaml
smimou has joined #ocaml
_fab has quit []
Zeitgeist has quit ["Leaving."]
sponge45 has joined #ocaml
microcape has quit [Connection reset by peer]
danly has joined #ocaml
sponge45 has quit ["zzzzzzzzzz"]
johnnowak has quit []
smimou has quit ["bli"]
microcape has joined #ocaml
Yorick has quit ["Leaving"]
Skal has quit [Remote closed the connection]
dark_light has quit [Connection timed out]
_JusSx_ has quit [Read error: 113 (No route to host)]