flux 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.org | Public logs at http://tunes.org/~nef/logs/ocaml/
ottbot has quit [Ping timeout: 264 seconds]
q66 has quit [Remote host closed the connection]
brianmwaters has quit [Ping timeout: 245 seconds]
mcstar has quit [Quit: mcstar]
darkf has joined #ocaml
dwmw2 is now known as dwmw2_gone
fasta has joined #ocaml
fasta_ has quit [Read error: Connection reset by peer]
sw2wolf has joined #ocaml
emmanuelux has quit [Quit: emmanuelux]
madroach has quit [Ping timeout: 248 seconds]
madroach has joined #ocaml
mattrepl has quit [Quit: mattrepl]
weie has joined #ocaml
amaloz has joined #ocaml
amaloz has left #ocaml []
ollehar has joined #ocaml
ollehar has quit [Ping timeout: 258 seconds]
ollehar has joined #ocaml
ollehar has quit [Ping timeout: 260 seconds]
amaloz has joined #ocaml
<gnuvince> Is there a way in OCaml to create an uninitialized array? I am writing my own little heap data structure (for school), and I'd like to have a function create : unit -> 'a t to create the heap, however I don't know how to create an 'a array of length 16 (initial size)
yacks has joined #ocaml
amaloz has quit [Quit: ERC Version 5.3 (IRC client for Emacs)]
josch has quit [Ping timeout: 260 seconds]
ulfdoz has joined #ocaml
adotbrown has quit [Ping timeout: 256 seconds]
<zorun> gnuvince: you can't really build a polymorphic structure this way
<flux> gnuvince, uninitialized datastructures don't quite work in ocaml in the general case, because they would create (accidentally) references to other objects, confusing garbage collection..
ulfdoz has quit [Ping timeout: 264 seconds]
<flux> gnuvince, there is an unsafe solution, though. but I don't know if you school would want you to use it.
<flux> or if you can use existing implementations of such arrays (I think Batteries has Vect?) then that's one way
ollehar has joined #ocaml
adotbrown has joined #ocaml
adotbrown has quit [Ping timeout: 252 seconds]
awm22 has quit [Quit: Leaving.]
PM has quit [Remote host closed the connection]
PM has joined #ocaml
Cyanure has joined #ocaml
ttamttam has joined #ocaml
ttamttam has quit [Read error: Connection reset by peer]
ttamttam has joined #ocaml
Kakadu has joined #ocaml
Enjolras has quit [Changing host]
Enjolras has joined #ocaml
Yoric has joined #ocaml
Yoric has quit [Ping timeout: 264 seconds]
ollehar has quit [Ping timeout: 248 seconds]
djcoin has joined #ocaml
ontologiae has joined #ocaml
Snark has joined #ocaml
Cyanure has quit [Remote host closed the connection]
cago has joined #ocaml
sw2wolf has left #ocaml []
thomasga has joined #ocaml
ontologiae has quit [Ping timeout: 246 seconds]
ttamttam has quit [Quit: ttamttam]
ttamttam has joined #ocaml
awm22 has joined #ocaml
mika1 has joined #ocaml
<orbitz> gnuvince: why not Bigarray and mmap or somethign?
hkBst has joined #ocaml
hkBst has quit [Changing host]
hkBst has joined #ocaml
<companion_cube> gnuvince: in ocaml, it's generally better style to write heaps as algebraic types rather than in arrays
ollehar has joined #ocaml
ontologiae has joined #ocaml
<invariant> Is there no way to create uninitialized arrays in ocaml? Even Haskell allows doing that.
<adrien_oww> in a module named Unsafe, no?
<adrien_oww> there are ways but you can find funnier ways to kill your programs
<invariant> It is not unsafe, if your code is correct.
<invariant> I don't mind it crashing when I make a mistake.
<companion_cube> then Array.make 42 (Obj.magic 0) ;)
<invariant> Although, even then ideally I should drop in the debugger.
<companion_cube> how comes Haskell allows that, by the way? what happens if you access an uninitialized element ?
<invariant> companion_cube, isn't that's still linear?
<invariant> -'s
<companion_cube> invariant: err, probably, so what?
<companion_cube> I mean, OCaml tries its best at being a type-safe and memory-safe language
<invariant> companion_cube, the whole point of uninitialized arrays is that it is an O(1) operation....
<companion_cube> uninitialized blocks of memory don't fall in this category
<flux> companion_cube, my guess this would simulate haskell: Array.make 10 (lazy (failwith "no"))
<companion_cube> invariant: sure, but then you should be writing C
<invariant> If people create a programming language without such an operation, I cannot really consider them other but inexperienced developers.
<companion_cube> flux: you still have to create n thunks
<companion_cube> invariant: write C, not OCaml
<companion_cube> only C allows such a thing
<invariant> companion_cube, so, because I want to use such features in 0.05% of a program, I should switch to C?
<companion_cube> (and you have to use malloc, not calloc
<companion_cube> invariant: no, but you can write this piece of code in C, I assume
<invariant> I suppose I could just implement one module in C, but it seems rather silly to handicap a language like that.
<companion_cube> well, no, Ocaml is not C, that's all
<companion_cube> I'm really curious about your claim that haskell does it in O(1)
<invariant> It's not like it would be hard to modify the GC to allow for such features.
<adrien_oww> proof?
<companion_cube> invariant: err, how do you cope with garbage in the memory block?
<companion_cube> garbage that would look like pointers, that is
<invariant> companion_cube, you just indicate that a particular region of memory is uninitialized memory.
<adrien_oww> which slows down the GC
<companion_cube> invariant: ok, and if you put some values in it, how do you know they are there?
<adrien_oww> you add a special case, it's more work for the GC
<invariant> adrien_oww, I think these comparisons can run in parallel.
<invariant> Using ILP.
fds_ is now known as fds
mika1 has quit [Quit: Leaving.]
<invariant> companion_cube, how do you mean?
mika1 has joined #ocaml
<companion_cube> invariant: well, you say "this memory is uninitialized" to the GC, so that it doesn't think the garbage is pointers
<companion_cube> but then, you write a value somewhere in the array
<companion_cube> and then the GC runs
<companion_cube> what prevents the GC of collecting the value?
<companion_cube> since it does not scan the array because you told it not to do
<invariant> companion_cube, you put that in the compiler, when you alllocate the memory?
Yoric has joined #ocaml
<companion_cube> 'that' ?
<companion_cube> this cannot be determined at compile time
<invariant> companion_cube, you only need primitive types in such arrays.
<companion_cube> because if you call UnsafeArray.set a i my_val, i is not known at compile time
dwmw2_gone is now known as dwmw2
<companion_cube> anyway, array creation and initialization is OCaml is a C primitive, it should be fast enough for most users
<companion_cube> unless you create lots of big arrays that you barely use
<invariant> companion_cube, that's not what I meant.
<invariant> companion_cube, the whole idea is that such an UnsafeArray is potentially extremely unsafe.
<companion_cube> invariant: then use Obj
<companion_cube> Obj.new_block
<companion_cube> it should be unsafe enough ;)
<invariant> companion_cube, if you write to an index outside of the size of the uninitialized memory, then of course it is going to do weird things.
<invariant> companion_cube, that would still require linear time.
<companion_cube> I don't think so
<companion_cube> Obj.new_block probably just allocates a block, that's it, you hav to do the rest
<companion_cube> (like using no_scan_tag ;))
dezzy_ has joined #ocaml
<companion_cube> but still, why do you need such fast allocation of arrays??
<invariant> Obj.new_block might be constant time, depending on the implementation of the underlying malloc.
<invariant> companion_cube, that should have been documented.
<companion_cube> no, because it's actually much too unsafe
<invariant> You cannot point to something as being constant time, when it isn't documented to be so.
<companion_cube> and I don't see why you would need uninitialized arrays
<invariant> This is something I like in C++.
<companion_cube> which is not type-safe
<companion_cube> oh, C++ does provide uninitialized arrays?
ski_ has joined #ocaml
<companion_cube> interesting.
nimred_ has joined #ocaml
lusory_ has joined #ocaml
alxbl_ has joined #ocaml
<invariant> companion_cube, did you graduate from university?
<companion_cube> yes.
<companion_cube> and I believe that std::vector and such would call the element constructor of every element of the array.
<invariant> companion_cube, C++ even offers to allocate an array on the stack, if you run new.
<companion_cube> new allocates on the heap
<companion_cube> (I mean, seriously??)
mika1 has quit [Quit: Leaving.]
olasd_ has joined #ocaml
<invariant> Which is why you wouldn't use vectors for that purpose...
<invariant> Anyway, this is pointless.
mika1 has joined #ocaml
<companion_cube> yes, I know, there are C arrays which are unsafe enough
<invariant> If you want to know why this is interesting, go and look it up yourself.
<invariant> New does not allocate on the heap.
<companion_cube> ...
olasd has quit [Disconnected by services]
olasd_ is now known as olasd
<invariant> It only shows you don't know a lot about C++.
<invariant> Also, there is not even a stack in C++.
<companion_cube> http://en.wikipedia.org/wiki/New_%28C%2B%2B%29 <-- "free store"
asmanur_ has joined #ocaml
<invariant> There is no stack and there is no heap.
<companion_cube> ok, so free store, not heap
<invariant> Those are just particular implementations which happen to be used by practically all implementations.
<companion_cube> so what ?
asmanur has quit [*.net *.split]
lusory has quit [*.net *.split]
alxbl has quit [*.net *.split]
dezzy has quit [*.net *.split]
ski has quit [*.net *.split]
nimred has quit [*.net *.split]
<invariant> new can be user-defined in C++ too.
<companion_cube> that's cool.
<invariant> In general, if the library author for C++ did something stupid you can fix it while remaining within the language.
<companion_cube> but here it's #ocaml, in which uninitialized memory is not featured because it's not safe
<invariant> That's another reason people like C++.
<companion_cube> I thought it was for its simple syntax and powerful type inference
<djcoin> :D
<invariant> Just alone for the ability to compile to such primitives, it is nice to have it documented and available.
<invariant> Imagine someone writing a Coq library for safe interaction with such structures.
<invariant> Then they want to extract to OCaml and then they first need to figure out whether and how well OCaml supports such things.,
<invariant> Leaving useful features out is simply a bad idea.
dezzy_ is now known as dezzy
dezzy has quit [Changing host]
dezzy has joined #ocaml
<invariant> Because those people instead will just extract to something else, which doesn't have this problem.
<companion_cube> you can look at Bigarray.Array1
<companion_cube> coq extraction only extracts to functional programs, I think, so that rules out uninitialized arrays...
mika1 has quit [Quit: Leaving.]
mika1 has joined #ocaml
<invariant> companion_cube, no, it doesn't.
<invariant> Coq only allows functional programs.
<invariant> That's a completely different statement.
<companion_cube> http://coq.inria.fr/refman/Reference-Manual027.html "We present here the Coq extraction commands, used to build certified and relatively efficient functional programs, extracting them from either Coq functions or Coq proofs of specifications."
<companion_cube> note the "functional programs"
<companion_cube> but really, try to use Bigarray.Array1
ottbot has joined #ocaml
Enjolras has quit [Ping timeout: 255 seconds]
mcclurmc has quit [Ping timeout: 260 seconds]
madroach has quit [Ping timeout: 248 seconds]
madroach has joined #ocaml
<invariant> companion_cube, I'd advise you to listen better to what I say, since I know I am right.
<invariant> companion_cube, you are free to continue to have wrong ideas about the world, however.
ski_ is now known as ski
<companion_cube> invariant: thanks for your permission
<companion_cube> now I know that OCaml should be as unsafe as C
<invariant> Please argue with the SafeHaskell extension people.
<rixed> invariant: don't know what you are trying to do, but uninitialized arrays can't work with the GC, so you have to malloc them outside ocaml's heap. that's what bigArray does, so you should have a look at it since it's apparently the closest thing to what you are after.
<rixed> that, or write your own bigarray like module in C (if the types supported by bigarray does not suit your need).
<rixed> There are very few languages that allow to mix GC memory and manually managed memory ; I could name only two : rust and ATS. Maybe you should also give them a try ?
mika1 has quit [Ping timeout: 264 seconds]
hcarty_ is now known as hcarty
awm22 has quit [Quit: Leaving.]
awm22 has joined #ocaml
_andre has joined #ocaml
sgnb has quit [Remote host closed the connection]
sgnb has joined #ocaml
ottbot has quit [Quit: WeeChat 0.4.0]
tane has joined #ocaml
mcclurmc has joined #ocaml
anderse has joined #ocaml
ontologiae has quit [Ping timeout: 252 seconds]
mika1 has joined #ocaml
ttamttam has quit [Ping timeout: 258 seconds]
ttamttam has joined #ocaml
awm22 has quit [Quit: Leaving.]
ontologiae has joined #ocaml
mika1 has quit [Quit: Leaving.]
mika1 has joined #ocaml
sgnb has quit [Remote host closed the connection]
sgnb has joined #ocaml
awm22 has joined #ocaml
wwilly has joined #ocaml
<wwilly> hi
ollehar has quit [Ping timeout: 260 seconds]
ollehar has joined #ocaml
mika1 has quit [Ping timeout: 276 seconds]
walter has joined #ocaml
mfp has quit [Read error: Connection reset by peer]
mfp has joined #ocaml
thomasga has quit [Quit: Leaving.]
travisbrady has joined #ocaml
rixed has quit [Remote host closed the connection]
<Kakadu> hey
travisbrady has quit [Quit: travisbrady]
rixed has joined #ocaml
hkBst has quit [Remote host closed the connection]
hkBst has joined #ocaml
travisbrady has joined #ocaml
hkBst has quit [Ping timeout: 258 seconds]
hkBst has joined #ocaml
hkBst_ has joined #ocaml
hkBst_ has quit [Changing host]
hkBst_ has joined #ocaml
hkBst has quit [Ping timeout: 255 seconds]
q66 has joined #ocaml
amaloz has joined #ocaml
hkBst__ has joined #ocaml
hkBst_ has quit [Ping timeout: 264 seconds]
smondet has joined #ocaml
darkf has quit [Quit: Leaving]
hkBst__ has quit [Read error: Connection reset by peer]
hkBst has joined #ocaml
zorun has quit [Ping timeout: 264 seconds]
zorun has joined #ocaml
amaloz has quit [Read error: Connection reset by peer]
amaloz has joined #ocaml
tac has joined #ocaml
hkBst has quit [Quit: Konversation terminated!]
cago has left #ocaml []
Kakadu has quit []
ottbot has joined #ocaml
ttm is now known as The_third_man
ollehar has quit [Ping timeout: 255 seconds]
thomasga has joined #ocaml
tac has quit [Ping timeout: 245 seconds]
awm22 has quit [Quit: Leaving.]
The_third_man has quit [Ping timeout: 255 seconds]
osa1 has joined #ocaml
walter has quit [Quit: This computer has gone to sleep]
The_third_man has joined #ocaml
mattrepl has joined #ocaml
Kakadu has joined #ocaml
ollehar has joined #ocaml
travisbrady has quit [Quit: travisbrady]
z_- has joined #ocaml
Yoric has quit [Ping timeout: 252 seconds]
<z_-> Requesting some help, I have a list of lists and want to do a map() for each element of each sub-lists. Is there a quick way to retrieve those elements?
<asmanur_> you can do a map inside a map
<asmanur_> or use List.flatten
<asmanur_> using List.flatten will loose your 2-dimensional structure though
<z_-> Yes, i can't do that sadly, will have to do some map-ception.
wwilly has quit [Remote host closed the connection]
<Qrntz> «List.map (List.map (fun _ -> …)) list»
<z_-> Qrntz: and then take this and put it in my map() function ?
<z_-> Will give it a shot.
<Qrntz> you certainly could
ttamttam has quit [Quit: ttamttam]
<Qrntz> s/could/can/
djcoin has quit [Quit: WeeChat 0.3.9.2]
z_- has quit [Quit: Page closed]
<ousado> haha, "inexperienced developers"
nimred_ has quit [Quit: leaving]
travisbrady has joined #ocaml
IbnFirnas has quit [Read error: Operation timed out]
IbnFirnas has joined #ocaml
bobry has quit [Ping timeout: 255 seconds]
ollehar has quit [Ping timeout: 256 seconds]
ollehar has joined #ocaml
nimred has joined #ocaml
osa1 has quit [Ping timeout: 276 seconds]
mcclurmc has quit [Ping timeout: 252 seconds]
UncleVasya has joined #ocaml
IbnFirnas has quit [Ping timeout: 252 seconds]
lopex has quit [Ping timeout: 256 seconds]
ttamttam has joined #ocaml
lopex has joined #ocaml
ontologiae has quit [Ping timeout: 264 seconds]
awm22 has joined #ocaml
osa1 has joined #ocaml
sivoais has quit [Ping timeout: 252 seconds]
travisbrady has quit [Ping timeout: 251 seconds]
Yoric has joined #ocaml
sivoais has joined #ocaml
sivoais has quit [Ping timeout: 264 seconds]
sivoais has joined #ocaml
sivoais has quit [Ping timeout: 256 seconds]
sivoais has joined #ocaml
anderse has quit [Quit: anderse]
sivoais has quit [Ping timeout: 255 seconds]
yacks has quit [Quit: Leaving]
sivoais has joined #ocaml
sivoais has quit [Read error: Connection reset by peer]
sivoais has joined #ocaml
sivoais has quit [Read error: Connection reset by peer]
<adrien> I saw references to a mailing-list platform@lists.ocaml.org but where is that?
julm has joined #ocaml
sivoais has joined #ocaml
<adrien> hmm, ok, thanks; so it's completely unrelated to http://ocaml.org/mailing_lists.html
ottbot has quit [Ping timeout: 260 seconds]
anderse has joined #ocaml
anderse has quit [Client Quit]
bobry has joined #ocaml
<adrien> well, looking at the mailing-list archives, it seems I'm the only one not having noticed it
<adrien> actually, no
<adrien> I noticed it but I've been uninterested; what drove me to it was discussion that was actually outside the scope of the "platform" (i.e. namespaces)
<adrien> (because I consider SDKs/Platforms to be packaging failures)
IbnFirnas has joined #ocaml
travisbrady has joined #ocaml
zzz_ has quit [Remote host closed the connection]
zzz_ has joined #ocaml
beginner42 has joined #ocaml
_andre has quit [Quit: leaving]
ttamttam has quit [Read error: Operation timed out]
beginner42 has quit [Quit: irc2go]
osa1 has quit [Ping timeout: 256 seconds]
Kakadu has quit []
jamii has joined #ocaml
UncleVasya has quit [Quit: UncleVasya]
smondet has quit [Ping timeout: 264 seconds]
amaloz has quit [Remote host closed the connection]
yacks has joined #ocaml
dezzy has quit [Ping timeout: 260 seconds]
dezzy has joined #ocaml
mcclurmc has joined #ocaml
adotbrown has joined #ocaml
ottbot has joined #ocaml
Snark has quit [Quit: Quitte]
tane has quit [Quit: Verlassend]
oriba has joined #ocaml
Yoric has quit [Ping timeout: 252 seconds]
Icarot has joined #ocaml
ollehar has quit [Ping timeout: 260 seconds]
<travisbrady> I just received this: https://gist.github.com/travisbrady/5157387 when trying to install cohttp via opam. Anyone seen this?
<travisbrady> Hmmm..looks related to the latest Async
jamii has quit [Ping timeout: 252 seconds]
emmanuelux has joined #ocaml
amaloz has joined #ocaml
Icarot has quit [Ping timeout: 272 seconds]
Icarot has joined #ocaml
mcclurmc has quit [Ping timeout: 260 seconds]
LukeSun has joined #ocaml
travisbrady has quit [Quit: travisbrady]
travisbrady has joined #ocaml