<companion_cube>
maybe we need Obj.black_magic and Obj.acceptable_magic to emphasize the difference between hiding mutability and lying about covariance 0:-)
<gasche>
hm
<def`>
gasche: stikl, don't you think it would be cleaner to lie about covariance only in signature?
<def`>
still*
lewis1711 has left #ocaml ["Ex-Chat"]
<gasche>
def`: if I understand your proposal, this means magicking to an abstract ('a ref) type instead of a concrete ('a ref)
<gasche>
('+a ref)
<def`>
in Async, you have 'a Ivar.t and +'a Deferred.t
<def`>
everything internal is definer in term of Ivar
rand_ has joined #ocaml
<def`>
only when exposing a high-level Api do you coerce to a Deferred.t
<gasche>
(do you have an URL to where the lie happen in the code?)
<gasche>
+s
ggole has joined #ocaml
ely-se has quit [Quit: leaving]
<gasche>
well here that would just be StrongRef
<gasche>
or maybe you suggest exposing the underlying immutable structure to let people implement their own splaying strategies?
<gasche>
reading my logs, I must say that quoting Chambart to imply that any use of Obj.magic is unsafe is kind of over-simplifying
Major_Biscuit has joined #ocaml
<gasche>
(and people are starting to wonder whether Menhir will be broken?)
<def`>
:D
<rks`>
gasche: I believe the flambda benchsuite includes menhir generated parsers
<rks`>
chambart will confirm
<def`>
Who quoted chambard? He said that himself
<gasche>
yes
<gasche>
during an OUPS talk I think
<rks`>
def`: chambart :)
<def`>
beh
<gasche>
I think that was a good think of Pierre to say during his talk
<ggole>
I don't think his comment (the one in this channel) was "any use of Obj.magic"
<ggole>
It was more "informed people only"
<gasche>
hm
_andre has joined #ocaml
<def`>
gasche: he wrote that himself on IRC yesterday
<def`>
(I wasn't at OUPS)
<ggole>
<chambart> *DON'T* use Obj.magic if you don't know OCaml backend in details and you know exactly which version of the compiler you are using.
<gasche>
yeah, I can agree with that
<rks`>
def`: neither was he, he was/is in London
<def`>
ok, I was referring to "his talk", might not have been OUPS
<gasche>
my point was more "if you wonder whether an Obj.magic use is safe, send an email to the maintainers before freaking out"
<def`>
I agree
<gasche>
so def` I think the Deferred approach is equivalent to what is done in BatSplay's StrongRef
<gasche>
except I coerce to a non-abstract covariant type instead of an abstract covariant type
<gasche>
(we could change to make the covariant cell abstract, but I don't know if that makes a difference)
<gasche>
also def` , I am not sure the Deffered interface is actually sound
<gasche>
hm
<def`>
I agree with all you say (including soundness of Deffered)
<def`>
(not that I have a specific issue in mind, in doubt it's safer to assume unsoundness :p)
<def`>
So what makes you think it is unsound?
<gasche>
there is a relatively subtle interaction between Ivar.fill, which allows to write into the ivar, and the Deferred interface
<gasche>
it's probably sound due to the fact that Ivar.fill implements single-write only, so it is a monotonic cell
<def`>
ah yes. Lwt has the same subtlety
<gasche>
if I was JST, I would put an intern on trying to implement this in either CFML or Mezzo
<def`>
(lazy_t too)
FreeBirdLjj has quit [Read error: Connection reset by peer]
FreeBirdLjj has joined #ocaml
<def`>
and use M-X doctor to supervise this project
<rks`>
:)
<gasche>
is this to be taken as a literal joke, or a rather amusing nickname for François?
<def`>
a joke :)
Sorella has joined #ocaml
ely-se has quit [Quit: leaving]
_andre has quit [Ping timeout: 255 seconds]
_andre has joined #ocaml
tane has joined #ocaml
darkf__ has joined #ocaml
darkf has quit [Ping timeout: 272 seconds]
dsheets has joined #ocaml
tane has quit [Quit: Verlassend]
caml has quit [Ping timeout: 252 seconds]
rand_ has quit [Ping timeout: 240 seconds]
darkf__ is now known as darkf
pdewacht has joined #ocaml
sz0 has quit [Quit: Connection closed for inactivity]
FreeBirdLjj has quit [Remote host closed the connection]
FreeBirdLjj has joined #ocaml
BitPuffin has joined #ocaml
agumonkey has joined #ocaml
ely-se has joined #ocaml
BitPuffin has quit [Ping timeout: 256 seconds]
badon has quit [Disconnected by services]
badon_ has joined #ocaml
badon_ is now known as badon
rand_ has joined #ocaml
jonludlam has joined #ocaml
vpm has quit [Quit: co'o]
BitPuffin has joined #ocaml
vpm has joined #ocaml
Kakadu has joined #ocaml
chambart has quit [Ping timeout: 255 seconds]
sh0t has joined #ocaml
Sorella has quit [Quit: Connection closed for inactivity]
Haudegen has quit [Ping timeout: 272 seconds]
ely-se has quit [Quit: leaving]
BitPuffin has quit [Remote host closed the connection]
ely-se has joined #ocaml
tane has joined #ocaml
Haudegen has joined #ocaml
rand_ has quit [Ping timeout: 260 seconds]
d0nn1e has quit [Ping timeout: 260 seconds]
d0nn1e has joined #ocaml
chambart has joined #ocaml
slash^ has joined #ocaml
pierpa has joined #ocaml
yomimono has joined #ocaml
<Korhonen>
In Ocaml, if the tail call function is the result of an expression say let f = ((foo bar) baz);; does that still count as a tail call or will the stack fill?
pothepanda has quit [Quit: Leaving]
AlexRussia has joined #ocaml
<ggole>
With some rare exceptions, all tail calls result in the old stack frame being discarded
<Korhonen>
ggole, hmm, any literature on the exceptions.
ggole has quit [Ping timeout: 256 seconds]
<edwin>
if you have annot or binannot files your edit should be able to show you which calls are tail calls
ely-se has quit [Quit: leaving]
<edwin>
in emacs its caml-types-show-call
ggole has joined #ocaml
<def`>
or using merlin (C-c C-t)
ely-se has joined #ocaml
Major_Biscuit has quit [Quit: WeeChat 1.3]
<edwin>
hmm that runs merlin-type-enclosing for me, should that print tail call info too?
<def`>
yes if your expression is in tail call position it sould appear in the mini buffer
ely-se has quit [Quit: leaving]
sh0t has quit [Quit: Leaving]
<edwin>
interesting if I put my cursor on the paranthesis in foo it prints int (* tail call *), but I could't figure how to make it print that with the foo2 function: http://paste.debian.net/349967/
sgnb has joined #ocaml
<edwin>
(The Merlin toolkit version 2.3.1, for Ocaml 4.02.3), def`: what am I doing wrong?
BitPuffin has joined #ocaml
ggole has quit [Ping timeout: 256 seconds]
ely-se has joined #ocaml
Haudegen has quit [Remote host closed the connection]
Haudegen has joined #ocaml
Denommus has joined #ocaml
Haudegen has quit [Ping timeout: 246 seconds]
<def`>
edwin: you have to target the call node, node the functional (expression to be called)
<def`>
you can navigate the tree with C-up / C-down
<def`>
not the*
<edwin>
thanks, works now
<def`>
np
jbrown has quit [Quit: Client exiting]
<edwin>
same trick works in vim too, <Leader>t and <Leader>n
Denommus has quit [Quit: rebooting]
lobo has joined #ocaml
sbrouf has quit [Ping timeout: 255 seconds]
OnkV has joined #ocaml
pierpa` has joined #ocaml
elkayser has joined #ocaml
pierpa has quit [Ping timeout: 255 seconds]
<elkayser>
hi, where can i found some exercices with solution to train with OCaml
dsheets has quit [Ping timeout: 246 seconds]
ril_ has joined #ocaml
rand_ has joined #ocaml
keep_learning has quit [Quit: This computer has gone to sleep]
mcint has joined #ocaml
Kakadu has quit [Quit: Page closed]
elkayser has quit [Quit: Page closed]
JacobEdelman has joined #ocaml
<Korhonen>
So I have a trivial program that does nothing more than let rec loop () = Thread.delay 1.0; loop ();; let () = loop();; and that takes around 5MiB of memory, is that normal?
<Korhonen>
I'm using the corebuild wrapper and compiled to .native
mcint has quit [Client Quit]
rand_ has quit [Quit: leaving]
<ely-se>
Korhonen: did you turn on optimisations?
ely-se has quit [Quit: leaving]
Major_Biscuit has joined #ocaml
ely-se has joined #ocaml
<edwin>
on a 64-bit system it looks like it is the size of the initial minor and major heaps: ./a.out
<edwin>
### OCaml runtime: debug mode ###
<edwin>
Initial major heap size: 3840k bytes
<edwin>
Initial minor heap size: 2048k bytes
ely-se has quit [Client Quit]
<Korhonen>
edwin, hmm
<Korhonen>
And is that memory shared or reserved exclusively to the process?
<companion_cube>
maybe Core has some statically allocated structures
<edwin>
it is shared among all of your threads
<Korhonen>
Hmm
<Korhonen>
Any way to dynamically link to core then?
_andre has quit [Ping timeout: 260 seconds]
<edwin>
are you looking at VIRT or RES memory usage though?
<edwin>
the initial heap is just allocated, should be mostly empty in the beginning
<Korhonen>
I'm not even sure what the difference is.
<Korhonen>
But I guess my point is that my eventual project is going to have _a lot_ of individual executables.
<Korhonen>
I'm basically as a teaching excercize re-implementing runit in OCaml which consists of a lot of executables running together
keep_learning has joined #ocaml
struk|desk|away is now known as struk|desk
ril_ is now known as ril[away]
ril[away] is now known as ril_
types has joined #ocaml
<edwin>
try with just the usual Unix module instead of linking with Core, is the memory usage better?
<Korhonen>
edwin, yeah, that's a mere 116k
ygrek has joined #ocaml
nullcatxxx_ has joined #ocaml
struk|desk is now known as struk|desk|away
ril_ has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
ygrek has quit [Ping timeout: 272 seconds]
nullcatxxx_ has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
rwmjones is now known as rwmjones|holiday
chambart has quit [Ping timeout: 240 seconds]
yomimono has quit [Ping timeout: 260 seconds]
palomer has joined #ocaml
<Korhonen>
So I now installed the Core library on my system (Gentoo Linux: dev-ml/core), is there any way to compile a .ml file to dynamically link against that? One assumes it's possible or they wouldn't offer those libraries as system-wide dynamically linked libraries in the official repos.
jonludlam has quit [Ping timeout: 246 seconds]
nullcatxxx_ has joined #ocaml
keep_learning has quit [Quit: Leaving]
cody` has joined #ocaml
ollehar has joined #ocaml
ril has joined #ocaml
ril has quit [Client Quit]
ollehar has quit [Quit: ollehar]
jonludlam has joined #ocaml
badon has quit [Ping timeout: 256 seconds]
contempt has quit [Disconnected by services]
contempt has joined #ocaml
malc_ has joined #ocaml
^elyse^ has joined #ocaml
nullcatxxx_ has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
nullcatxxx_ has joined #ocaml
nullcatxxx_ has quit [Client Quit]
types has quit [Ping timeout: 246 seconds]
lobo has quit [Quit: leaving]
badon has joined #ocaml
MercurialAlchemi has quit [Ping timeout: 240 seconds]
<Stalkr_>
What is the difference between "type value = `Int of int | `Float of float" and "type value = [ `Int of int | `Float of float ]"? The brackets []
<Stalkr_>
Korhonen: I have skimmed that section, but I am not sure I understand what are special about them. I can do "`Int of int | `Int of string" but not "Int of int | Int of string"?
Kakadu has joined #ocaml
<Korhonen>
Stalkr_, that's ust a convention
<Korhonen>
THe important part is the subtyping/supertyping relationship, as in, you don't actually have to make it a "type"
MercurialAlchemi has joined #ocaml
<Korhonen>
Basically, say you have a pattern match, like match x with | `Foo x -> whatever | `Bar x -> anything_else
<Stalkr_>
As in I can just use them in a function without doing "type value = Int of int" stuff first?
<Korhonen>
Then "x" can be be any value which can be both `Foo x and `Bar x, but also a value which can ONLY be `Foo x
<Korhonen>
So it can tae a subtype of the full value, basically
<Korhonen>
YEah
<Stalkr_>
but what is `Foo and `Bar? Is that just inferred?
<Korhonen>
Stalkr_, wait ehh, I'll write you a paste up
<Stalkr_>
Sure, thanks :-)
<Stalkr_>
I have been using F# for a year, but I haven't really seen something like `Foo, I can't remember if I have used polymorphism at all (and if it's possible even in F#...)
<Stalkr_>
Korhonen: What is "3" ^ x? Just a string concat?
<Korhonen>
Yeah
<Korhonen>
^ is string concatenation
yomimono has quit [Ping timeout: 260 seconds]
<Stalkr_>
I think I get it, but could it be `Foo x -> int_to_string | `Foo x -> float_to_string as well? Is the type inferred from `Foo or from type_to_string?
<Korhonen>
No, you cannot have two labels with the same type
<Korhonen>
You can have the same type with two labels.
lobo has joined #ocaml
<Korhonen>
I don't now this or a fact by the way, it just makes sense but I never tried it
<octachron>
F# does'nt have polymorphic variant
<Stalkr_>
but in RWO, they have an example with "`Int of int | `Int of string" under the poly variants section
<Stalkr_>
let three = `Int 3;; let five = `Int "five";;
<Korhonen>
Hmm
<Stalkr_>
unless it is different since they are not pattern-matching of course
<Korhonen>
Then I guess you can.
<octachron>
you cannot
<Stalkr_>
I see, it must be because of using the REPL then?
<octachron>
or more precisely, not in the same function/type context
<Korhonen>
Stalkr_, I can't find what you are said with ctrl f in RWOC
<Stalkr_>
but it makes sense to not work in a func context
<Korhonen>
Stalkr_, well, as you can see, the boo says the type checker will complain if you do that
tane has joined #ocaml
yomimono has joined #ocaml
<octachron>
Stalkr_, look at the error message for part 7
<Korhonen>
You can use `Int of int and `Int of float` together within the same code by the way, they just can't unify in the same expression
<Korhonen>
AGain, I don't know this for a fact and never tried it, but it just makes sense
<octachron>
if you have an expression [ `Int 5; `Int "five"], it should have both the type [< `Int of int] list and [< `Int of string] list
<Stalkr_>
octachron: Why is `Not_a_number not mentionen as "was expected of type"? Because of the string "five"? Why is `Float mentioned then if we are saying `Int?
<octachron>
so the compiler deduce the type [< `Int of string & int ] and then realize this type is empty
<Korhonen>
That's an interesting way to see it I guess.
<octachron>
Stalkr_, because the compiler type from left to right
<Korhonen>
Stalkr_, basically, see the labels as tags in dynamically typed language except that the type checker enforces that youa lways check for the tag and correctly handle it before you proceed.
<octachron>
so, with [ `Int 3; `Float 1.; Int "five" ], it first see `Int 3 and deduce the type [< `Int of int ] list
<Stalkr_>
I didn't know OCaml was that different from F#, I have to wrap my head around this, to see how it's useful (and even how to use it)
<octachron>
then it meets `Float 1. and understand that the type should also include Flot of float [< Int of int | Float of float ] list
<octachron>
and the error only appears when it read the Int "five" and try to add Int of string in the polymorphic variant type
<Korhonen>
"One cannot use the same name in another type," this is false isn't it?
yomimono has quit [Ping timeout: 260 seconds]
<Korhonen>
I'm pretty sure I have code runnig right now that uses the constructor "Up" in at least four different tagged unions
<Korhonen>
This is within one module.
<Korhonen>
Ohhh
<Korhonen>
I guess this is allowed because I use "Up" at one point and "Up of <type>" in others hwere they are all different
<Korhonen>
Honestly
<Korhonen>
I'm not sure how any of this works. Looking at the code I just use "Up" within another module while one assumes it should be Module_name.Up but I guess the typechecker accepts that
rpg has joined #ocaml
malc_ has quit [Quit: leaving]
JacobEdelman has quit [Quit: Connection closed for inactivity]
slash^ has quit [Read error: Connection reset by peer]
<octachron>
Korhonen, in old version of Ocaml, constructors and record label needed to be unique.
<Korhonen>
octachron, ahh, they changed that now?
<octachron>
yes, and the manual was simply not updated here
<octachron>
I will try to correct that by next version
<Korhonen>
I mmust say, I find that most convenient, I'm always annoyed how with Haskell you can't re-use them within different types. The accessor functions could automatically be made typeclasses I guess.
^elyse^ has joined #ocaml
rpg_ has joined #ocaml
rpg has quit [Ping timeout: 256 seconds]
orbifx2 has joined #ocaml
Stalkr_ has quit [Read error: Connection reset by peer]
orbifx has quit [Ping timeout: 260 seconds]
darkf has quit [Quit: Leaving]
zpe has quit [Remote host closed the connection]
zpe has joined #ocaml
zpe has quit [Ping timeout: 255 seconds]
<octachron>
Ok, alternative wording for the manual written. Thanks for mentioning the problem Korhonen.
larhat1 has joined #ocaml
larhat1 has quit [Remote host closed the connection]
larhat1 has joined #ocaml
freehck has quit [Remote host closed the connection]
pierpa` is now known as pierpa
cody` has quit [Quit: Connection closed for inactivity]
<Korhonen>
octachron, well, do you happen to know if it's possible to dynamically link to Ocaml system libarries, I'm reading conflicting things about this.
<Korhonen>
Like, I have Jane Street's Core library inside /usr/lib64 and I wonder if it's possible to use that library inside a program and dynamically link to it instead of statically.
contempt has quit [Disconnected by services]
contempt has joined #ocaml
<octachron>
I don't know much on this subject, but as far as I know: not directly
<Korhonen>
Hmm
<Korhonen>
I wonder why my distro allows one to install those things then.
<Korhonen>
One assumes they have to be a dependency of some thing which dynamically links to them.
<Korhonen>
These just come from the pacage manager
<octachron>
well, you need a copy of the library somewhere to link even statistically
<edwin>
also you might need them if you use ocamlc
<Korhonen>
Yeah, but these are runtime dependencies looking at the ebuilds, not build depedendices
<Korhonen>
But I'm going to see if I can take an ebuild apart to see what it does
<edwin>
for ocamlopt the C stubs are linked statically, but for ocamlc they are loaded at runtime
<edwin>
are you refering to files like dllcore_kernel_stubs.so?
<edwin>
there is a way to load ocaml modules at runtime with ocamlopt, with cmxs files
<edwin>
they are probably useful if you want to load plugins
<edwin>
I don't think they are very useful if you want to link to a library, usually libraries are not ABI compatible between releases, you'd need to recompile your application after most changes to a library
<Korhonen>
Well, Core is released under the LGPL which implies dynamic linking to it is possible.
<Korhonen>
And recompiling when an ABI updates is something I do all the time anyway on Gentoo.
<Korhonen>
But my problem is that Core seems to load 5mb into memory immediately even for a trivial program and I'd rather share that between different executables.
<Korhonen>
At the bery least I want to see if it loads that on a per process basis
rpg_ has quit [Remote host closed the connection]
rpg has joined #ocaml
tane has quit [Ping timeout: 260 seconds]
<octachron>
Korhonen, Core is released under the LGPL + ocaml linking exception
<edwin>
that 5mb is memory allocated on startup, I don't think thats sharable
<edwin>
you could try a busybox-like approach: one executable with many subcommands
<edwin>
then you can share the largish executable mapping between multiple processes
<octachron>
correction, Core was released with LGPL + linking exception, the licence is now Apache 2
ncthom91 has joined #ocaml
rpg_ has joined #ocaml
rpg_ has quit [Client Quit]
ollehar has joined #ocaml
<edwin>
core has its own mailing list, you can try to ask there about memory usage and dynamic linking
rpg has quit [Ping timeout: 255 seconds]
<Korhonen>
Yeah, I already made a post there too.
<Korhonen>
That 5MB seems most curious though.
<Korhonen>
But maybe there's a way to turn that off.
tane has joined #ocaml
JacobEdelman has joined #ocaml
sbrouf has quit [Ping timeout: 240 seconds]
orbifx2 has quit [Ping timeout: 272 seconds]
Denommus has quit [Quit: going home]
j0sh has joined #ocaml
ygrek has quit [Ping timeout: 246 seconds]
manizzle has quit [Ping timeout: 240 seconds]
<j0sh>
is it possible to pass command line args to a custom toplevel? seems like the toplevel attempts to read the args as a script file. while i can read and process the args, not sure how to 'truncate' them so the toplevel doesnt attempt to process them further
mac10688 has joined #ocaml
groovy2shoes has quit [Quit: Leaving]
Sorella has joined #ocaml
nullcatxxx_ has joined #ocaml
rpg has joined #ocaml
nicoo has quit [Ping timeout: 272 seconds]
cody` has joined #ocaml
nicoo has joined #ocaml
rpg has quit [Quit: rpg]
octachron has quit [Quit: Leaving]
ygrek has joined #ocaml
MercurialAlchemi has quit [Ping timeout: 240 seconds]
Haudegen has quit [Ping timeout: 240 seconds]
tane has quit [Quit: Verlassend]
nullcatxxx_ has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
^elyse^ has quit [Quit: Leaving]
nullcatxxx_ has joined #ocaml
^elyse^ has joined #ocaml
lobo has quit [Quit: leaving]
BitPuffin has quit [Ping timeout: 256 seconds]
Haudegen has joined #ocaml
Kakadu has quit [Remote host closed the connection]