mika1 has quit [Read error: Connection reset by peer]
mika1 has joined #ocaml
cago has joined #ocaml
mika1 has quit [Read error: Connection reset by peer]
mika1 has joined #ocaml
djcoin has joined #ocaml
Sablier has joined #ocaml
Submarine has joined #ocaml
Submarine has quit [Changing host]
Submarine has joined #ocaml
andreypopp has joined #ocaml
kaustuv has quit [Ping timeout: 240 seconds]
mika1 has quit [Ping timeout: 240 seconds]
Yoric has joined #ocaml
mika1 has joined #ocaml
cago has quit [Quit: Leaving.]
mika1 has quit [Ping timeout: 250 seconds]
ankit9 has joined #ocaml
Obfuscate has quit [Ping timeout: 272 seconds]
tmaedaZ has quit [Ping timeout: 250 seconds]
milosn has quit [Ping timeout: 256 seconds]
SanderM has joined #ocaml
tmaedaZ has joined #ocaml
Snark has joined #ocaml
Hussaind has joined #ocaml
Hussaind has left #ocaml []
milosn has joined #ocaml
tufisi has joined #ocaml
letrec has joined #ocaml
benozol has joined #ocaml
ulfdoz_ has joined #ocaml
ulfdoz has quit [Ping timeout: 252 seconds]
ulfdoz_ is now known as ulfdoz
ulfdoz_ has joined #ocaml
ulfdoz has quit [Ping timeout: 244 seconds]
ulfdoz_ has quit [Ping timeout: 244 seconds]
ulfdoz has joined #ocaml
fraggle_ has quit [Ping timeout: 248 seconds]
fraggle_ has joined #ocaml
ulfdoz_ has joined #ocaml
ulfdoz has quit [Ping timeout: 252 seconds]
ulfdoz_ is now known as ulfdoz
avsm has joined #ocaml
<adrien>
that's a long release anouncement
_andre has joined #ocaml
Obfuscate has joined #ocaml
Yoric has quit [Ping timeout: 264 seconds]
Yoric has joined #ocaml
cago has joined #ocaml
rossberg has quit [Remote host closed the connection]
rossberg has joined #ocaml
<phao>
are high the performance penalties of functional programming due to lots of copies that happen?
<phao>
copying*
<Hodapp>
copying of what?
<phao>
the value usually
<phao>
not copyign actually, but the construction of a new value from an old one, which is done instead of assignment, even if most of the value (most of its parts, when it has parts that you can deal with separatedly) is re-usable
<phao>
you could do record.field receives 3 with assignment, but in something more functional, you'd generate a new record, having the field's value "updated" to be 3
<phao>
it's almost copying sometimes, if your data structure is big, and you wanna update only one field of it
lin has joined #ocaml
<lin>
hi all, what am I supposed to handle the following situation
<flux>
phao, often values are arranged in tree-like structure in functional languages
<lin>
I have two modules, say a.ml and b.ml, and type a is defined in a.ml, type b is defined in b.ml
<flux>
phao, because you don't modify existing values, you can easily rebuild a tree and only copy its spine; then the values you don't modify can simply refer to the old version
<phao>
flux, what about the process of "copying the spine"
<flux>
that's not to say there is no cost involved, but it's small and there are benefits
<phao>
isn't that expensive?
<phao>
hmm
<phao>
are there benchmarks, trying to show how small the cost is?
<flux>
maybe the language shootout is
<phao>
I could do these, I think, but it's too much work hehe -- and I am really on the flow of the ocaml book I am reading
<flux>
of course, you are able to use imperative approaches as well in ocaml
<lin>
they are both record types
<phao>
yes, I know that; this is more a question I am having again, now
<lin>
In module A I want to refer to fields of type b, and in module B I want to refer to fields of type a
<phao>
but I really had this doubt back when I was learning scheme (before I had set!) some years ago, and then again last year when checking out haskell
<flux>
lin, x.A.fieldname, y.B.fieldname
<phao>
but never got to look about it
<flux>
phao, there's also another cost related to this that's probably bigger than the copying
<flux>
because you create new values and let the old ones die, garbage collection takes some time
<phao>
what is it?
<phao>
hmm
<phao>
got it
<flux>
on the other hand typical functional language GCs handle short-lived values well
<lin>
flux, but when I compile, it seems to report something like "Circular build detected"
<lin>
since I refer to module A in module B, and vice versa
<flux>
lin, oh, sorry, I didn't read fully and assumed you had the traditional problem :-)
<flux>
lin, basically you need to move the dependency to another module that both A and B depend on
<lin>
am i supposed to group type defs in a base file like type.ml?
<flux>
or, you can introduce it in one file and use recursive modules
<flux>
or you can perhaps use polymorphic types to go around it
<flux>
but yes, types.ml is one approach I've used as well
<lin>
Yeah, It takes me a while to figure this out , because in my daily work , I mainly do C programming
<lin>
it's quite natural to include header files mutually
<flux>
I had that issue when I started OCaml quite some time ago, but it seems to go away, perhaps by learning to subconciously use the workarounds ;-)
<flux>
that's not to say a large project wouldn't bump into that issue, though
<flux>
the basic solution is to "write smaller modules, write more independant modules"
<flux>
typically that happens with polymorphicity and with the module system
<lin>
hmm, good suggestion
<lin>
i think i have a long way to go in the ocaml world
<flux>
it makes great for reusability as well, easier to pull functionality out
<flux>
for example MLDonkey is not a good example of that :(
<flux>
I once tried pulling its torrent file handling out of it, and it was painful
<lin>
so which project can be a good example?
<flux>
good question. I haven't read that much other project's source code..
<lin>
recently i am reading janestreet's async library
<lin>
maybe i can find some light there
<flux>
libraries are a slightly different breed of code than applications, though
<flux>
but I have no doubts that's a good read
Ptival has quit [Read error: Connection reset by peer]
benozol has quit [Read error: Connection reset by peer]
benozol has joined #ocaml
kaustuv has left #ocaml []
<rixed>
Is there a way to avoid the "Multiple definition of the module name OCAML__prof_Profiling" error when compiling a module which includes another one with ocamlcp?
<thelema_>
rixed: odd, I've never gotten that error even when using include...
ankit9 has quit [Ping timeout: 252 seconds]
<lin>
hi all
<lin>
I have different types of workers to handle different kind of tasks. Now it seems I am trying to acheive two conflicting goals:
<lin>
1. I want to keep all workers in a hash table. This requires they have a unique type.
<lin>
2. Since different types of workers are for different tasks, their types can't be the same.
<lin>
The reason I want to keep all workers in a hash table is because a worker is used to hold a service conversation with a network peer,
<thelema_>
lin: the common way to handle this is to expose only a run() function that's unit -> unit and have all the type specific stuff hiding inside
<lin>
thus I need to pick out a specific worker according to a packet I receive from the socket.
<thelema_>
of course this can be adapted to your specific situation
<thelema_>
but clearly you can't have a hashtable of functions of different parameters and expect to request a specific function and pass it the right value
<lin>
oh thanks, let me think about it
<lin>
it sounds reasonable, but one problem: there seems to be no way to hold intermediate states for every worker
<thelema_>
lin: make your workers as closures, with some mutable state hidden inside them
<thelema_>
let worker () = let my_state = ref ... in fun () -> ...; ()
<lin>
ok, let me think about it
lin has quit [Quit: Leaving]
eni has quit [Remote host closed the connection]
lin has joined #ocaml
<mehdid>
thelema_: is the first "()" needed?
<mehdid>
(in "let worker () = …")
<thelema_>
mehdid: if you want to make multiple workers with independent my_state cells
<mehdid>
ah, fair enough
<thelema_>
if you just want one worker, then yes, drop the ()
<thelema_>
I guess that should be "let make_worker () = ..."
Obfuscate has quit [Ping timeout: 260 seconds]
<mehdid>
indeed, avoids ambiguity
lin has quit [Quit: Leaving]
lin has joined #ocaml
<phao>
mfp, that ocaml book you recommemd me is really great
<phao>
I am finishing chapter 6 here -- cool exercises, and I liked the explanations
<djcoin>
phao: which one are you reading ?
<phao>
Introduction to Objective Calm
<phao>
Jason Hickey
<mfp>
AFAIK Hickey's book (draft) is (still) widely considered the best introduction
<csmrfx>
Possible to have unlabeled optional parameters?
jaar has joined #ocaml
<pippijn>
how would you call that?
<csmrfx>
I dont even know how to call labeled optional params properly! 8D
lin has quit [Remote host closed the connection]
jaar has quit [Ping timeout: 245 seconds]
<wmeyer`>
pippijn: burs seems to be the right choice - i've already started to think how to describe this - Lambda RTL seems to be choice - but undocumented. I have my own ideas though
avsm has quit [Quit: Leaving.]
pangoafk is now known as pango
Tobu has joined #ocaml
Tobu has quit [Changing host]
Tobu has joined #ocaml
<csmrfx>
How do I make this accept any type: let foo ?huh = match huh with None -> false | Some x -> x
<thelema_>
csmrfx: can't - the return type has to be bool because one branch of the match returns bool
<flux>
csmrfx, think what the function type would be in that case
avsm has joined #ocaml
<flux>
csmrfx, best make two functions.
<mrvn>
or use an exception
<csmrfx>
but, I read that a ?param has the optional type None x option = None | Some of x ... or something like that
Kakadu has joined #ocaml
<thelema_>
csmrfx: yes, the problem is the `-> false`, which makes the output type have to be bool
<thelema_>
csmrfx: and because of `Some x -> x`, the input type must be `bool option`
cdidd has quit [Remote host closed the connection]
<jonafan>
there should be a bot that detects people asking about history in the repl because i paste that every few days
<thelema_>
csmrfx: match is an expression that is like a case/switch statement in other languages, but more powerful, as each branch uses a pattern to test the structure of the input expression and bind identifiers to parts of that structure.
<thelema_>
csmrfx: also, partial application is normally done on the first parameter(s)
<mrvn>
csmrfx: unit is the only value used for "no (more) arguments"
<mrvn>
And total/partial application is a tricky thing. A function can be fully applied but still return a function.
<mrvn>
or in other words partial application can do computations too
<mrvn>
or a function might not even know it returns a function because it is polymorphic.
johnnowak has joined #ocaml
andreypopp has joined #ocaml
<tchell>
csmrfx: I like the post
sgnb has quit [Read error: Connection reset by peer]
<csmrfx>
So I am not mistaken in that partial applied f is a 'new' function? "another" function?
<csmrfx>
tchell: 8)
sgnb has joined #ocaml
<thelema_>
csmrfx: a function of type `int -> int -> int` can be thought of as taking two integer parameters and returning an integer
<thelema_>
it can also be thought of as `int -> (int -> int)`, meaning that it takes one integer parameter and returns a function that takes another integer parameter and returns an int
<thelema_>
this is the basis for partial application
<Drakken>
If a function returns a function, "fully applied" doesn't really say anything meaningful.
<csmrfx>
I kind of think I know what partial application is, never got what is so big about it
<Drakken>
because you can make functions easily. like ((+) 1) is an incrementor.
<Drakken>
thelema's second answer is better if you really want to understand currying.
sgnb has quit [Read error: Connection reset by peer]
<csmrfx>
BTW I hope you dont mind me quoting you
<Drakken>
every function takes one argument. If it looks like it takes more arguments, that just means the function returns a function, which returns another function, etc.
<csmrfx>
If you want, just msg and I can remove nick or quote even
<csmrfx>
It's just notes for myself for later, though
sgnb has joined #ocaml
<thelema_>
even though functions take one argument, the compiler does keep track of "arity" or the number of arguments to a function, for optimization purposes, i.e. so that all those intermediate functions don't have to actually be created
johnnowak has left #ocaml []
<thelema_>
also, a single argument can be a tuple (1,2,'x') of multiple values together. The compiler tries to optimize this as well so that the tuples aren't actually created every time the function is called.
<csmrfx>
Drakken lambda?
bobry has quit [Remote host closed the connection]
lopex has quit [Read error: Connection reset by peer]
joewilliams has quit [Remote host closed the connection]
<Drakken>
what about it?
IbnFirnas has quit [Remote host closed the connection]
<csmrfx>
what you described, "the function returns a function, which returns another function, etc"
IbnFirnas has joined #ocaml
<Drakken>
fun/lambda is a macro/syntax.
<Drakken>
it creates a function at compile time.
joewilliams has joined #ocaml
<Drakken>
partial evaluation returns a function at run time.
<Drakken>
so (( * ) 2) is a function that doubles numbers.
<Drakken>
and (List.map (( * ) 2)) is a function that doubles all the elements in a list.
<csmrfx>
doesn't return a ref to compiled function?
<Drakken>
almost everything is a reference/pointer in ML and Lisp languages.
<Drakken>
you don't have to worry about pointers or references.
Sablier_ has joined #ocaml
<csmrfx>
true and thats why I want to use ocaml
<csmrfx>
was wondering rather superficially
<thelema_>
OCaml has things called "ref": 'a ref, which is a mutable value of type 'a.
<Drakken>
It's a record that contains one field, which is mutable.j
<csmrfx>
yes, should have used the term "memory address pointer" or something
<Drakken>
a ref is more than just a pointer.
<Drakken>
It's a record.
<thelema_>
csmrfx: nice. I ish we had the ocaml-tutorial wiki up still instead of just this read-only mirror of it (which may be of use, csmrfx) http://mirror.ocamlcore.org/ocaml-tutorial.org/
<csmrfx>
yes, I was referring to the post-compile-time function decomposition
<csmrfx>
hm, decomposition is not a good word, either
<csmrfx>
but I ramble
Sablier has quit [Ping timeout: 245 seconds]
mfp has quit [Ping timeout: 245 seconds]
<Drakken>
It's too bad refs aren't called "vars". Lots of people would like that better :)
<Hodapp>
It's interesting how sometimes I have to look to see if I'm in #scala or #ocaml. I guess it means I'll have an easy transition back...
avsm has quit [Quit: Leaving.]
lopex has joined #ocaml
_andre has quit [Quit: leaving]
mfp has joined #ocaml
everyonemines has joined #ocaml
Nahra has quit [Quit: leaving]
BiDOrD has joined #ocaml
BiDOrD_ has quit [Ping timeout: 252 seconds]
fraggle_ has quit [Ping timeout: 260 seconds]
Kakadu has quit [Quit: Konversation terminated!]
fasta has quit [Quit: Quit]
fasta has joined #ocaml
fasta has quit [Client Quit]
fasta has joined #ocaml
manu3000 has joined #ocaml
fraggle_ has joined #ocaml
Xizor has quit [Ping timeout: 260 seconds]
bobry has joined #ocaml
eni has joined #ocaml
eni has quit [Ping timeout: 246 seconds]
Snark has quit [Quit: Quitte]
Sablier_ has quit [Quit: Quitte]
avsm has joined #ocaml
tonyg has quit [Quit: leaving]
avsm has quit [Client Quit]
SanderM has quit [Remote host closed the connection]
<manu3000>
hello, any easy way to generate PDF with OCaml ?