companion_cube changed the topic of #ocaml to: Discussions about the OCaml programming language | http://www.ocaml.org | OCaml 4.05.0 release notes: https://caml.inria.fr/pub/distrib/ocaml-4.05/notes/Changes | Try OCaml in your browser: http://try.ocamlpro.com | Public channel logs at http://irclog.whitequark.org/ocaml
yawaramin has quit [Ping timeout: 258 seconds]
aaronwint2 has quit [Ping timeout: 260 seconds]
pmetzger has joined #ocaml
nicklaf has quit [Ping timeout: 240 seconds]
nicklaf has joined #ocaml
enterprisey has joined #ocaml
pierpa has joined #ocaml
ohama has quit [Ping timeout: 240 seconds]
ohama has joined #ocaml
pmetzger has quit []
shinnya has quit [Ping timeout: 248 seconds]
mfp__ has quit [Ping timeout: 240 seconds]
Denommus has quit [Ping timeout: 264 seconds]
pyx has joined #ocaml
pyx has quit [Client Quit]
jyc has quit [Ping timeout: 255 seconds]
flx_ has joined #ocaml
chelfi has quit [Ping timeout: 255 seconds]
ggherdov has quit [Ping timeout: 255 seconds]
jmct has quit [Ping timeout: 255 seconds]
rossberg has quit [Ping timeout: 255 seconds]
flux has quit [Ping timeout: 255 seconds]
flx_ is now known as flux
rixed has quit [Ping timeout: 255 seconds]
rixed has joined #ocaml
jmct has joined #ocaml
chelfi has joined #ocaml
ELLIOTTCABLE has quit [Ping timeout: 255 seconds]
breitenj has quit [Ping timeout: 255 seconds]
littleli_ has joined #ocaml
bigs_ has joined #ocaml
dejanr has quit [Ping timeout: 260 seconds]
ELLIOTTCABLE has joined #ocaml
MightyJoe has joined #ocaml
nahra` has joined #ocaml
dejanr has joined #ocaml
nicklaf has quit [Quit: leaving]
breitenj has joined #ocaml
littleli has quit [Ping timeout: 255 seconds]
bigs has quit [Read error: Connection reset by peer]
cyraxjoe has quit [Quit: No Ping reply in 180 seconds.]
andrewalker has quit [Ping timeout: 255 seconds]
nahra has quit [Remote host closed the connection]
clog has quit [Ping timeout: 255 seconds]
copy[m] has quit [Ping timeout: 255 seconds]
srenatus has quit [Ping timeout: 255 seconds]
maufred has quit [Ping timeout: 255 seconds]
freusque has quit [Ping timeout: 255 seconds]
terrorjack has quit [Ping timeout: 255 seconds]
caw__ has quit [Ping timeout: 255 seconds]
bigs_ is now known as bigs
littleli_ is now known as littleli
freusque has joined #ocaml
rossberg has joined #ocaml
andrewalker has joined #ocaml
AlexRussia has quit [Ping timeout: 240 seconds]
lobo has quit [Ping timeout: 255 seconds]
jyc has joined #ocaml
caw__ has joined #ocaml
terrorjack has joined #ocaml
maufred has joined #ocaml
srenatus has joined #ocaml
copy[m] has joined #ocaml
AlexRussia has joined #ocaml
kerrhau has joined #ocaml
copy[m] has quit [Ping timeout: 255 seconds]
copy[m] has joined #ocaml
lobo has joined #ocaml
kerrhau_ has joined #ocaml
diginet has quit [Excess Flood]
diginet has joined #ocaml
yawaramin has joined #ocaml
mnemem_ has joined #ocaml
mnemem_ has quit [Ping timeout: 255 seconds]
ziyourenxiang has quit [Quit: Leaving]
ristos has quit [Quit: Connection closed for inactivity]
mbuf has joined #ocaml
pierpa has quit [Quit: Page closed]
cbot_ has joined #ocaml
kerrhau_ has quit [Ping timeout: 240 seconds]
cbot has quit [Ping timeout: 240 seconds]
kerrhau has quit [Remote host closed the connection]
kerrhau has joined #ocaml
kerrhau_ has joined #ocaml
kerrhau_ has quit [Remote host closed the connection]
ggherdov has joined #ocaml
clog has joined #ocaml
kerrhau has quit [Ping timeout: 260 seconds]
kerrhau has joined #ocaml
jbrown has quit [Ping timeout: 258 seconds]
lopex has quit [Quit: Connection closed for inactivity]
mnemem_ has joined #ocaml
mnemem_ has quit [Ping timeout: 255 seconds]
govg has joined #ocaml
al-damiri has quit [Quit: Connection closed for inactivity]
yawaramin has quit [Ping timeout: 255 seconds]
cbot_ has quit [Quit: Leaving]
kerrhau has quit [Ping timeout: 260 seconds]
MercurialAlchemi has joined #ocaml
infinity0_ has joined #ocaml
infinity0_ has quit [Changing host]
infinity0_ has joined #ocaml
infinity0 is now known as Guest43658
infinity0_ is now known as infinity0
Guest43658 has quit [Ping timeout: 248 seconds]
jlam has quit [Ping timeout: 240 seconds]
jlam has joined #ocaml
mnemem_ has joined #ocaml
freusque has quit [Ping timeout: 258 seconds]
freusque has joined #ocaml
sz0 has joined #ocaml
<Khady> Hi. I have some issues with utop at work. When It's using the network and lwt, it tends to be stuck and nothing happen anymore. I don't have this behavior with the default repl. Anyone experienced the same thing?
def` has joined #ocaml
inr has quit [Remote host closed the connection]
inr has joined #ocaml
Fistine has quit [Ping timeout: 255 seconds]
Fistine has joined #ocaml
andreas__ has quit [Quit: Connection closed for inactivity]
Simn has joined #ocaml
demonimin has quit [Remote host closed the connection]
demonimin has joined #ocaml
silenc3r has joined #ocaml
argent_smith has joined #ocaml
ziyourenxiang has joined #ocaml
ziyourenxiang has quit [Changing host]
ziyourenxiang has joined #ocaml
<Armael> (super annoying indeed
<Armael> )
mengu has joined #ocaml
ziyourenxiang has quit [Quit: Leaving]
<Khady> hmm
ziyourenxiang has joined #ocaml
<Khady> And I suppose that a bounty won't be a real motivation for diml :D
silenc3r has quit [Quit: Leaving]
andreas__ has joined #ocaml
mfp__ has joined #ocaml
kakadu has joined #ocaml
enterprisey has quit [Read error: Connection reset by peer]
<orbifx[m]> Denommus`: still here?
<rubberduckreynir> orbifx[m]: Nah :/
<orbifx[m]> Would have liked to discuss FRP with him
<orbifx[m]> Also the author of this article here?: A new way of blogging about Ocaml
<rubberduckreynir> Oh, my hakyll setup broke, and I'd like to switch to something OCaml-based
rubberduckreynir is now known as reynir
nicoo has quit [Read error: Connection reset by peer]
hepek has joined #ocaml
hepek has left #ocaml [#ocaml]
aaronwint3 has joined #ocaml
<aaronwint3> Hi again! Thanks so much for your help yesterday, I learnt a ton
copy_ has joined #ocaml
nicoo has joined #ocaml
<aaronwint3> If you remember, I was representing my bitmap as a string and my iterators had a "weird" signature e.g foldr : (t -> 'a -> 'a) -> t -> 'a -> 'a
<aaronwint3> Drup: so, you told me it was wrong and it should have finer granularity (i.e bitmaps are made of bits, so really the first argument to my lambda should be a bool) if I recall correctly
<aaronwint3> I forgot to ask you "why?". I still lack an intuition for that kind of stuff and so it would be great to understand the reason behind that
<aaronwint3> the "why?" = "I'd like to actually understand the big picture and functional patterns" not "I think you're wrong" just to be clear :p
<Khady> orbifx[m]: the author is on the discord of reasonml
<kakadu> aaronwint3: It is usually better to take an abstraction most suitable for the task. Yes, you can always represent an array as a `list of arrays of size 8` but it will be weird chioce.
<kakadu> There you have something like that: an array of byte-sized numbers
<kakadu> you need either use a collection of bools to represent your bitmap (because it is simple and not overcomplicated) or use a collection of integers where every integer will represent about 63 (depends on your CPU architecture) bits (it will be more dense representation and not too overcomplicated)
<kakadu> And now my questions
<kakadu> Can I explain ocamlfind that I need to use ocamlc and not ocamlc.opt?
<reynir> kakadu: Skimming the man page for ocamlfind I found you can set an environment variable OCAMLFIND_COMMANDS='ocamlc=ocamlc-3.00 [...]', so I guess you can use OCAMLFIND_COMMANDS='ocamlc=ocamlc'
<reynir> kakadu: Ah, check out findlib.conf
<reynir> $(opam config var lib)/findlib.conf if you're using opam
<aaronwint3> kakadu: out-of-curiosity, what would be the most memory efficient way to store a bitmap
<aaronwint3> naively*
<kakadu> aaronwint3: I think that in C array
<aaronwint3> using OCaml bindings to C basically?
<kakadu> reynir: thanks, environment variable looks great
<kakadu> aaronwint3: yep
<aaronwint3> got it, thank you
<kakadu> but you probably don't need most effective way for studying purposes
<aaronwint3> it's good to know + I might do it at some point just to learn about bindings to C
<aaronwint3> :p
<def`> aaronwint3: using a string is fine too
<def`> The memory overhead is the same.
<def`> And bitwise ops are reasonably efficient directly in OCaml.
<def`> (but some things will be harder to achieve, e.g. popcount)
<aaronwint3> wait, how's the memory overhead the same? if I have a bitmap with 10bits as a string then I need 10*8bits to store it? if it's an array of int32 then it is 32 bits + array overhead
<aaronwint3> couple questions btw: how much is the array overhead? and am I way off def` ?
<def`> 2*8bits
<def`> You use the string as a bitmap :P
<aaronwint3> oh ok my bad
<aaronwint3> right now what I'm doing is to have a 1b -> 1B correspondence since I tried it to make it human readabe
<aaronwint3> readable*
<def`> Memory overhead of most an OCaml object is one word for GC header.
<def`> Then it depends on the kind of objects you are manipulating.
<aaronwint3> and if I recall correctly, a word is a machine dependent size (32b or 64b)
<aaronwint3> correct?
<def`> A string of length n consumes ceil((n+1)/word_size)
<def`> + the header
<aaronwint3> how much is the header?
<def`> One word.
<aaronwint3> oh
<companion_cube> there are tons of bitvectors/bitsets on opam
<def`> On ocaml array has no more extra information than the header (the header contains the size).
<companion_cube> with low overhead
<companion_cube> some are based on strings, others on arrays of ints
<def`> An ocaml string also has to have a terminal zero (for direct compatibility with C-strings)
<def`> (actually this has no overhead in the OCaml representation since this terminal byte serves another purpose)
<aaronwint3> for future ref, found a useful email by Xavier Leroy: http://caml.inria.fr/pub/ml-archives/caml-list/2002/08/e109df224ff0150b302033e2002dbf87.en.html
<aaronwint3> I'm trying to make sense of "size_string = number_of_words_in_block * sizeof(word) + last_byte_of_block - 1"
<aaronwint3> what does last_byte_of_block refers to?
<def`> The header stores the size of an object has a number of word.
<def`> as*
<def`> However we want the size of a string as a number of bytes.
<def`> So for a string n, OCaml allocates (n+1)/word_size words, and use the last byte of the last word to store how many bytes are unused in this word.
<def`> If all bytes are used, then since byte is 0 and the string ends with 0. If some bytes are unused, then last byte is non-zero but the first unused byte is used to store the 0.
<def`> This way: representation is directly compatible with OCaml GC and C strings
<def`> Size can be computed in constant time. The two drawbacks are: 1) computing the size can requiring touching two memory pages/cache line/...
<def`> (so a small loss of locality) 2) if the size you allocate is already a multiple of word_size and you don't care about C strings, then one word is wasted.
<aaronwint3> glorious, thanks for your patience
<aaronwint3> for future ref: great posts on ocaml internals https://rwmj.wordpress.com/2009/08/04/ocaml-internals/
shinnya has joined #ocaml
<orbifx[m]> Khady: thanks. Not keen to attend DIscord :P
cymen has joined #ocaml
_andre has joined #ocaml
<cymen> hm... i am trying to install ocaml-tls from git ... i cloned, installed opam, ran opam init, ran eval `opam config env`, ran opam pin add --no-action stuff ., ran opam install --deps-only stuff and that all seemed to work
<cymen> but then I tried to run opam install stuff and it fails with an error
<cymen> is there anything stupid that I missed? :)
<cymen> or can somebody point me to some good instruction on how to install stuff that comes with an opam file?
<reynir> Do you mean the dependencies?
<hannes> cymen: what I do is to "pin" the package... the command "opam pin add -k git tls `pwd`#HEAD" will compile and install `pwd` as tls package
<cymen> hannes: so what exactly is the difference to my pin command?
<hannes> cymen: you specified "no action" and pin the directory -- this means that also potentially dirty (not in git repo) things are used. the "-k git" uses the git HEAD of pwd.
<cymen> hm ok
mbuf has quit [Quit: Leaving]
<cymen> hannes: it says it will install tls 0.8.0
<hannes> to further analyse what went wrong in your commands, you'll need to provide mroe details in "fails with an error"
<cymen> is that correct for the git version?
<hannes> cymen: yes, the version number is taken from (a) the opam file, and (b) opam-repository. since (a) does not contain any version information, it just takes the latest from opam repository. this is slightly misleading, sorry about that.
Trou has left #ocaml [#ocaml]
<cymen> alright, so it still fails because...
<cymen> # pkg.ml: [ERROR] cmd ['ocamlbuild' ... exited with 10
<hannes> you can find stdout and stderr in ~/.opam/XXX/build/tls/XXX.out/err. could you look there for a bit more context of the failing command?
<reynir> !paste
<cymen> ah it cant find ppx_cstruct
<cymen> might have the dep missing
<cymen> after pinning can I now run opam install tls and it will take the local version? am I understanding this correctly?
<hannes> cymen: yes!
<cymen> okay, seems to have worked
<hannes> cymen: in the opam file, there is "ppx_cstruct" listed as dependency, you can check with "opam info ppx_cstruct" whether it is installed
<cymen> hannes: wasn't installed, I installed it manually
<hannes> the "--deps-only" above may only have installed the run time dependencies, not the build time dependencies (for some obscure reason)
<hannes> cymen: great that it worked. now you can do local changes, commit them locally and run "opam reinstall tls" to get them installed (I recommend to run "ocaml pkg/pkg.ml build && ocaml pkg/pkg.ml test" before that to check whether your local changes compile :)
<cymen> can I list all files that opam installed for a package?
<cymen> okay, build fails because ounit...let s install that too...needs cstruct-unix install that too...i think it built
<hannes> cymen: unfortunately not AFAIK, but ~/.opam/XXX/lib/<package>/ is where the library files end up (obviously a package may as well install stuff into bin/)
<cymen> and the tests run
<cymen> yay
<cymen> does this come with any binaries I can use for testing stuff?
<hannes> cymen: if you have lwt installed, and run ocaml pkg/pkg.ml build --with-lwt true, you'll get _build/lwt/examples/
<hannes> see pkg/pkg.ml for details which binaries are built, these include an echo server and echo client
<companion_cube> is there somewhere a blogpost on how to replace oasis with jbuilder+topkg? to get an idea of how hard it is
<cymen> hannes: thx!
<hannes> cymen: there's also https://github.com/hannesm/tlsclient in case you're looking for a similar tool as "openssl s_client"
<cymen> :o
<cymen> mymy
<hannes> (for the server side, there's tlstunnel, which is similar to stunnel / stud)
<cymen> this stuff should really be in the readme :)
<hannes> cymen: it is linked from the project page https://nqsb.io :D
<hannes> but maybe the README doesn't link to that page atm... feel free to submit a PR
<cymen> I mean the instructions on how to build...
<cymen> well, maybe this is obvious for ocaml versed people
<hannes> you're likely correct
<hannes> (and I'm likely blind to that by knowing too much OCaml and just looking into the "opam" files themselves to figure out how to build / what is going on)
<kakadu> Folks, do you have any ideas how to compile ppx_deriving plugin right? https://discuss.ocaml.org/t/about-plugins-and-ppx-deriving/914 I'm struggling about linking ppx_tools_versioned
mengu has quit [Remote host closed the connection]
mengu has joined #ocaml
ShalokShalom_ has joined #ocaml
profan has quit [Remote host closed the connection]
ShalokShalom has quit [Ping timeout: 240 seconds]
mbuf has joined #ocaml
jbrown has joined #ocaml
mengu has quit [Remote host closed the connection]
peterbb has quit [Quit: Lost terminal]
<aaronwint3> def`: I'm testing that I understand: so consider a string s = "france"; on a 32b machine it takes 2 words (since len(s) = 6 ; 6*8 = 48b) w1 is full (32/32) and w2 is partially filled (16/32) with the string
<aaronwint3> w1:[B1: 'f', B2: 'r', B3: 'a', B4: 'n'] w2:[B1: 'c', B2: 'e', B3: '\0', B4: 16]
tane has joined #ocaml
<aaronwint3> apply the first formula: 2 * size(words) - last_byte_value - 1 = 64 - 16 - 1 = ceil(47/8) = 6B
lopex has joined #ocaml
<aaronwint3> applying the other formula: ceil((6*8+1)/32) words = ceil(49/32) words = 2 words
<aaronwint3> anyway, we can determine the full length taken by a string by computing:
<aaronwint3> (header + num_words) * size_word = (1+2)*32 = 3*32= 96b = 12B
<aaronwint3> (full length in memory)
<aaronwint3> sorry but for the length of the string itself, we said : num_words*size_word - last_byte_value - 1
<aaronwint3> what does the -1 stands for
yawaramin has joined #ocaml
<aaronwint3> yawaramin: hey!
<yawaramin> hi :-)
<aaronwint3> sorry to spam the channel guys, I just can't wrap my head around the memory representation of strings
dejanr has quit [Ping timeout: 248 seconds]
<aaronwint3> is the -1 for the header?
<aaronwint3> that would make sense
dejanr has joined #ocaml
mengu has joined #ocaml
mengu has quit [Ping timeout: 260 seconds]
sh0t has joined #ocaml
<kakadu> I think so
<kakadu> header seems to be a 64bit value on amd64 machine
mengu has joined #ocaml
yawaramin has quit [Ping timeout: 240 seconds]
<aaronwint3> kakadu: header is 1word so either 64b or 32b depending on the machine indeed
<Drup> aaronwint3: you might be interested by the "inspect" package
<companion_cube> or objsize
MercurialAlchemi has quit [Ping timeout: 260 seconds]
Denommus has joined #ocaml
<aaronwint3> will look into that thanks
Fistine has quit [Ping timeout: 264 seconds]
Fardale_ has quit [Ping timeout: 258 seconds]
tobiasBora has quit [Ping timeout: 248 seconds]
igmp has quit [Ping timeout: 248 seconds]
sepp2k has joined #ocaml
Denommus has quit [Quit: ERC Version 5.3 (IRC client for Emacs)]
tormen has quit [Ping timeout: 240 seconds]
mbuf has quit [Quit: Leaving]
tormen has joined #ocaml
Fistine has joined #ocaml
sz0 has quit [Quit: Connection closed for inactivity]
Fardale_ has joined #ocaml
igmp has joined #ocaml
tobiasBora has joined #ocaml
mengu has quit [Remote host closed the connection]
jbrown has quit [Ping timeout: 260 seconds]
govg has quit [Ping timeout: 255 seconds]
tormen has quit [Ping timeout: 258 seconds]
tormen has joined #ocaml
jmiven has quit [Quit: co'o]
jmiven has joined #ocaml
<aaronwint3> ok I finally get it, take a string "france" its representation in memory is: header: [b0...b21:num_blocks;b22..b23:color;b23..b31:tag] w1: [B1: 'f', B2: 'r', B3: 'a', B4: 'n'] w2: [B1: 'c', B2: 'e', B3:0, B4:1]
<aaronwint3> on a 32b machine
<aaronwint3> feels good haha
<aaronwint3> it's pretty straightforward in hindsight
oschwald has joined #ocaml
oschwald has quit [Client Quit]
al-damiri has joined #ocaml
oschwald has joined #ocaml
mnemem_ has quit [Ping timeout: 248 seconds]
<ELLIOTTCABLE> I suppose this is as good a place to ask as any — does anybody know of a good IRC channel for newbie compiler-developers (and/or other PLT topics?)
<ELLIOTTCABLE> I'd like to be able to ask questions of people experienced in the field, easily, as opposed to resorting to Stack Overflow, or Twitter, or my weird PLT friend-group
<companion_cube> well here might not be too bad a place for this kind of questions
<companion_cube> but I don't know any dedicated chan
tormen has quit [Ping timeout: 248 seconds]
tormen has joined #ocaml
mbuf has joined #ocaml
nicoo has quit [Read error: Connection reset by peer]
nicoo has joined #ocaml
<cymen> hannes: what made you think ppx_cstruct is in the opam file? it doesn't seem to be in the one from git
<ELLIOTTCABLE> companion_cube: *nods*
<cymen> hannes: it has cstruct and ppx_tools but not ppx_cstruct
<companion_cube> (although there might be a stackexchange for non trivial questions)
ziyourenxiang has quit [Ping timeout: 255 seconds]
<hannes> cymen: ah, I looked in my local branch which is part of a PR..
<ELLIOTTCABLE> so, my compilers question arose from this:
<ELLIOTTCABLE> or rather, that arose from my current project, working through the IACC, in OCaml. (maybe I bit off a bit much.)
<ELLIOTTCABLE> but: in dynamic languages with an interpreter or JIT, the “runtime” is a module of code included with / compiled into the compiler itself; if you have “the language”, you have the runtime …
<ELLIOTTCABLE> … correspondingly, with C or C++, the compiler *gets* the runtime (am I correct?) from some place on the user's system — it's shipped alongside the compiler itself, as something the user-of-the-compiler has to keep around, in /usr/share/lib or whatever. (clib?)
shinnya has quit [Ping timeout: 260 seconds]
<ELLIOTTCABLE> so my Q: is this what *all* modern AOT compilers do? I have “a runtime” (lol at the moment it's literally one line of C code — hopefully, soon, to be OCaml code instead, see https://stackoverflow.com/questions/46566761/is-it-possible-to-call-into-c-functions-from-ocaml-without-wrapped-types) in my “compiler” project …
<ELLIOTTCABLE> … but after emitting some assembler, I need to invoke the linker against that runtime. which means I need to get that runtime to the end-user of the compiler.
<ELLIOTTCABLE> the only other option I can see is to *inline* the C for the runtime into my OCaml compiler, have my compiler emit it to a temporary file, and then invoke gcc to link (well compile and then link) that temporary runtime.c against my compiler's object-code output
aaronwint3 has quit [Ping timeout: 260 seconds]
yawaramin has joined #ocaml
oschwald has quit [Quit: Leaving.]
mengu has joined #ocaml
mengu has quit [Ping timeout: 240 seconds]
jbrown has joined #ocaml
mengu has joined #ocaml
mnemem_ has joined #ocaml
jnavila has joined #ocaml
<companion_cube> remind me, why do you need C?
<companion_cube> if it's just for a toy project for learning, you can do it all (runtime included) in OCaml
<ELLIOTTCABLE> companion_cube: definitely want to do that. didn't know how to, until that StackOverflow response
mengu has quit [Remote host closed the connection]
slash^ has joined #ocaml
ygrek has joined #ocaml
peterbb has joined #ocaml
mbuf has quit [Quit: Leaving]
mengu has joined #ocaml
andreas__ has quit [Quit: Connection closed for inactivity]
sh0t has quit [Ping timeout: 240 seconds]
<ELLIOTTCABLE> I'm v. confused by the relationship between jbuilder (which I'm using to build) and opam
<ELLIOTTCABLE> jbuilder requires a .opam file "for every library"; but doesn't seem to specify what, precisely, needs to be in those opam files …
<ELLIOTTCABLE> … whereas the results I can find by googling creating packages with opam seems to duplicate a *bunch* of stuff that's already in my jbuilder files; not to mention some irrelevant stuff — at least, I think. Like I said, real confused.
<ELLIOTTCABLE> most directly: jbuilder generates "an install file" from the .opam file; and it uses that to do the special, package-oriented @install? which is supposed to build every jbuild-file anywhere in a sub-directory, as I understand it?
<companion_cube> hum, dependencies are a bit duplicated, yeah
mengu has quit [Remote host closed the connection]
<companion_cube> otherwise, opam is the package manager (to install 3rd party libs); jbuilder is a build system (for compiling your own code)
<ELLIOTTCABLE> but I've got a jbuild in a sub-directory (see above — trying to build a ‘runtime’ object to be included, and later linked at my compiler's runtime), and it's not getting built
<ELLIOTTCABLE> `(executable ((name runtime) (libraries ())))`
<companion_cube> your runtime should probably be a library?
<ELLIOTTCABLE> but `jbuilder build runtime.exe` in the root of the project says “Don't know how to build runtime.exe”
<ELLIOTTCABLE> hm
<companion_cube> jbuilder build src/runtime.exe or sth like that?
<companion_cube> I think you need the path
<companion_cube> I'm not very proficient with jbuilder yet
<ELLIOTTCABLE> “Don't know how to build src/runtime.exe”
<ELLIOTTCABLE> yeah same ugh; the documentation is surprisingly pretty and verbose (based on my experience so far with other OCaml community things), but somehow still not penetrating my thick skull rrofl
<companion_cube> hmmm :/
<companion_cube> you can try and find projects on github that use jbuilder
<companion_cube> and see how they do
<ELLIOTTCABLE> digging!
<companion_cube> that's how I learnt oasis a while ago ^^
kakadu has quit [Quit: Konversation terminated!]
yawaramin has quit [Ping timeout: 255 seconds]
ShalokShalom_ is now known as ShalokShalom
gasche has joined #ocaml
mnemem_ has quit [Read error: Connection reset by peer]
mnemem_ has joined #ocaml
jnavila has quit [Ping timeout: 240 seconds]
<ELLIOTTCABLE> hm.
<ELLIOTTCABLE> any idea how to get jbuilder to show all the commands it's invoking?
<ELLIOTTCABLE> I've gotten really close — an unlinked object-file from `runtime.ml` out to `_build/default/src/runtime.o`, and an object-file from my "compiler" out to `./omg.o`
<ELLIOTTCABLE> unfortunately, `ld ./omg.o _build/default/src/runtime.o` explodes
<companion_cube> have you tried --verbose?
<ELLIOTTCABLE> “Undefined symbols for architecture x86_64: "_camlPervasives", referenced from: _camlRuntime__entry in runtime.o” and such
<ELLIOTTCABLE> unsurprisingly, as *my* runtime, being in ocaml, needs the *ocaml* runtime …
<def`> ocaml links libasmrun which contains the runtime :P
<def`> (you can pass -verbose to the normal compiler to get the command list invoked by ocamlc/ocamlopt, it's not jbuilder's job to call the system toolchain)
<def`> (of course you first need to know how jbuilder calls ocamlc/opt :P)
<ELLIOTTCABLE> yeah, I wanted to see the `ocamlopt` invocation, so I could then dig down and verbose *that*
<ELLIOTTCABLE> and i'm halfway there
<ELLIOTTCABLE> def`: libasmrun?
jbrown has quit [Ping timeout: 258 seconds]
<def`> ls ~/.opam/*/lib/ocaml/lib*
<ELLIOTTCABLE> looken!
<def`> camlrun is the bytecode runtime, asmrun the native runtime
<ELLIOTTCABLE> .opam/system/lib/ocaml-compiler-libs or .opam/system/lib/ocamlbuild/lib* maybe
<def`> the you have the variants, I don't remember all the details but I think d is debug runtime, p is profilable runtime, _pic the position-independent-code runtime
* ELLIOTTCABLE nods
profan has joined #ocaml
<def`> no it really is /ocaml/
<def`> however as you are using the system switch (it is not advised: it is quite fragile as your system package manager can change files opam is relying on)
<def`> try `ocamlopt -config` to find these informations
<ELLIOTTCABLE> mmmmm k
<ELLIOTTCABLE> what's the best-practice there? I don't even know what a “system switch” is yet — new to OCaml as of about a week ago. Is this something like an nodenv/rvm/etc install, or
<ELLIOTTCABLE> presumably `opam switch <something>`, but I don't know what the idiomatic improvement over the default configuration is, yet?
jnavila has joined #ocaml
<ELLIOTTCABLE> oh lawdie `standard_runtime`, beautiful
<ELLIOTTCABLE> def`: thanks!
<def`> ELLIOTTCABLE: with the system switch, opam try to use an OS managed installation of OCaml (so homebrew I guess in your case)
<ELLIOTTCABLE> yeah, homebrew
<def`> with opam switch <some version> it manages the version itself.
<ELLIOTTCABLE> `/usr/local/Cellar/ocaml/4.05.0/bin/ocamlrun` is looking like half of what I want
<ELLIOTTCABLE> actually, no, that's the bytecode interpreter? hm
<ELLIOTTCABLE> oh, so literally just `opam switch <the version I already have>`
<ELLIOTTCABLE> to duplicate it in an opam-managed manner. got it!
<def`> the pros are 1) easy to switch between different versions 2) no risk that files get overwritten by homebrew (an update would break opam install)
<def`> the cons is a little more space used :)
jbrown has joined #ocaml
<def`> yes, ocamlrun / camlrun is the bytecode
<def`> asmrun is the native runtime (essentially a GC + the few C primitives)
<ELLIOTTCABLE> gotcha.
<def`> btw you said that merlin couldn't be built with clang in OSX 10.13
<ELLIOTTCABLE> hm. There's `bin/ocaml`, `bin/ocamlc`, `bin/ocamlc`, `bin/ocamlrun`, but nothing beginning with “asm”, or indeed with it anywhere in the name
<def`> do you remember the error? (I have OSX somewhere but I am a bit lazy to test :P)
<ELLIOTTCABLE> hmmmm
<def`> it is not in bin, it is in the standard library path
<ELLIOTTCABLE> I can try and replicate!
<ELLIOTTCABLE> but it'll be a couple weeks, midterms next week
<def`> you can try linking a simple binary
<def`> np
<ELLIOTTCABLE> ah k
<def`> try:
<def`> echo 'print_endline "hello world"' > hello.ml
<def`> ocamlopt -verbose -o hello hello.ml
<ELLIOTTCABLE> good call.
<def`> you should find what happens under the hood to link an ocaml file
sh0t has joined #ocaml
ygrek has quit [Remote host closed the connection]
<ELLIOTTCABLE> man, I'm almost certainly going about all of this extremely wrong, anyway. rrofl
<ELLIOTTCABLE> all this actually hasn't really *gotten* me anywhere, now that I think about it — all I've done is graduate from requiring that the “user” of my compiler have a `runtime.c` file, and gcc to compile it; to requiring that they have a functioning ocaml installation, with ocaml's runtime available …
<ELLIOTTCABLE> bit of a chicken-and-the-egg problem.
<def`> I have no idea what you are trying to achieve
<ELLIOTTCABLE> Oh, sorry — up in the scrollback
ygrek has joined #ocaml
<ELLIOTTCABLE> 16:56 <companion_cube> remind me, why do you need C?
<ELLIOTTCABLE> 16:56 <companion_cube> if it's just for a toy project for learning, you can do it all (runtime included) in OCaml
gasche has left #ocaml ["ERC (IRC client for Emacs 24.5.1)"]
<ELLIOTTCABLE> (which was my previous thought, and what I'm currently trying to do: replace a C-function that simply calls my generated-x86-assembler-function, with an OCaml initialization file that simply calls my generated-x86-assembler-function.)
<def`> you produce an object file that you want to link ?!
<def`> do your runtime need OCaml ?
sh0t has quit [Remote host closed the connection]
jnavila has quit [Ping timeout: 264 seconds]
<def`> if your compiler is in OCaml but your runtime independant from OCaml, there is no reason to do what you are trying to :P (I think)
<ELLIOTTCABLE> that's exactly the question I'm currently trying to answer: which is easier, a tiny runtime in C, or a tiny runtime in OCaml. Apparently I'm hugely unequipped to answer it. O_O
yawaramin has joined #ocaml
<def`> Well, if you don't need a system linker, you can just mmap the object code in your process and jump to that address.
<companion_cube> ah, if you compile to asm…
<ELLIOTTCABLE> def`: not gonna make you walk me through this anymore — I think `ocamlopt -verbose` gives me what I need, right this second. Lemme go bang my head against it (and Google) a bit more, before I take up the channel's time!
<def`> Np.
<def`> It is a totally sensible use case to link against the OCaml runtime. But it seems a bit advanced at your point. A minimal runtime in C is fine.
<ELLIOTTCABLE> well, for greater context —
<def`> (Actually the OCaml runtime itself links to a C runtime to achieve more portability)
<ELLIOTTCABLE> I'm not trying to create the Newest Greatest Scheme Evar, lol, I'm intentionally trying to learn here
<ELLIOTTCABLE> so if “getting a GC'd runtime written in a HLL linked into the eventual product-binary” is the Right Thing To Do, I'm happy to bang my head against it and get it Right
<def`> if you need a GC in your language yes.
<ELLIOTTCABLE> well, I doubt I'll *reuse* the OCaml GC
<ELLIOTTCABLE> although I hadn't even thought of that
<def`> to answer the question, what really matters is "which services do your language need from the runtime ?"
<ELLIOTTCABLE> I think “add a GC” is one of the 24 steps I'm supposed to be doing, here, though.
<ELLIOTTCABLE> at this stage — if I include the OCaml runtime, it's *only* to service my own runtime code, whatever that ends up being? I think?
<def`> And your runtime code is implemented in OCaml ?
<ELLIOTTCABLE> lol my “runtime code” is literally:
<ELLIOTTCABLE> external scheme_entry : unit -> nativeint = "scheme_entry" [@@noalloc]
<ELLIOTTCABLE> let () = let result = scheme_entry () in Printf.printf "%d" (Nativeint.to_int result)
<ELLIOTTCABLE> but eventually, yes, I'm assuming it'd be nice to only be writing three languages in my learning-compilers-project (scheme, OCaml, and x86 assembler), as opposed to four (scheme, OCaml, x86-assembler, *and* a C “runtime”)
<def`> if the end user has a working ocamlopt on his/her machine, then you can just use it has a linker
* ELLIOTTCABLE nods
<def`> -h
<ELLIOTTCABLE> okay, thanks for all this — gonna bang my head against it a bit
<def`> good luck :)
kakadu has joined #ocaml
kakadu has quit [Client Quit]
jbrown has quit [Ping timeout: 248 seconds]
<ELLIOTTCABLE> well. nope. that seems to skip … quite a few steps
<ELLIOTTCABLE> + clang -arch x86_64 -c -o 'runtime.o' '/var/folders/3b/mxfmd44s6zn50_1wmkrxs19w0000gn/T/camlasm283a58.s'
<ELLIOTTCABLE> + clang -arch x86_64 -c -o '/var/folders/3b/mxfmd44s6zn50_1wmkrxs19w0000gn/T/camlstartup3b3b1a.o' '/var/folders/3b/mxfmd44s6zn50_1wmkrxs19w0000gn/T/camlstartup0452a5.s'
<ELLIOTTCABLE> it's not printing the steps that compile those intermediate products.
<ELLIOTTCABLE> I'm guessing def` was right, and this is too much of an effort for a beginner.
mengu has joined #ocaml
<ELLIOTTCABLE> $ opam switch 4.05.0 (*=> [ERROR] "/Users/ec/.opam/4.05.0" already exists, please choose a different name *)
<ELLIOTTCABLE> er, I know it exists, that's why I want to switch to it.
<yawaramin> perhaps you're already on it?
<ELLIOTTCABLE> `opam switch list` emboldens the last line, “system C system System compiler”
<yawaramin> so 4.05.0 might be your system compiler?
<ELLIOTTCABLE> it is
<ELLIOTTCABLE> I'm quite confused — above, I *think* it was implied that I should install the current version *again*, under opam, and then switch to it? to stop using the system (Homebrew) install?
<ELLIOTTCABLE> can I not do that?
<yawaramin> `system` is just an alias for 4.05.0, therefore you're already on 4.05.0
<yawaramin> aliases are like git branches
<yawaramin> they're 'cheap switches'
<ELLIOTTCABLE> How can I opam-manage the same version as my system has installed, then?
<ELLIOTTCABLE> oh lord it *is* using it
<ELLIOTTCABLE> you're totally right, ignore me. strange.
<yawaramin> np
mnemem has joined #ocaml
trevorriles has quit [Ping timeout: 248 seconds]
mnemem_ has quit [Ping timeout: 255 seconds]
malina has joined #ocaml
fraggle_ has joined #ocaml
pierpa has joined #ocaml
<ousado> is there a way to put first-class modules into records?
malina has quit [Quit: Throwing apples of Montserrat]
stux|RC-only has quit [Ping timeout: 248 seconds]
cbot has joined #ocaml
<yawaramin> interesting question. what happens when you try?
<ousado> so, I got this type, which seems fine to ocaml: type t = { three : (module X_int); }
<ousado> but I haven't managed to get an instance in there yet
<yawaramin> what happens when you try to create an instance?
<ousado> using the example types from RWO, btw
copy_ has quit [Quit: Connection closed for inactivity]
<ousado> when I do this: { three = New_three } (New_three is an instance of that module type) I get Error: Unbound constructor New_three
mengu has quit [Remote host closed the connection]
<yawaramin> can you tr: { three = (module New_three : X_int) }
mengu has joined #ocaml
KV_ has joined #ocaml
<ousado> hm, that works.. but it's still a "packed" module, apparently
<yawaramin> yeah, first-class modules are packed (AFAIK)
<yawaramin> basically since modules can't exist at the value level OCaml lets you take the 'pointer' to a module and store that at the value level instead
<ousado> hm.. what I'm after is an unpacked module in that position..
<ousado> I guess I should use a module instead of a record
mengu has quit [Ping timeout: 240 seconds]
<ousado> to simplify things
<yawaramin> yeah you might want to move this into the module level, with modules and functors
sepp2k has quit [Quit: Leaving.]
enterprisey has joined #ocaml
tane has quit [Quit: Leaving]
donryudragoni has joined #ocaml
donryudragoni has quit [Client Quit]
donryudragoni has joined #ocaml
fraggle_ has quit [Remote host closed the connection]
slash^ has quit [Read error: Connection reset by peer]
donryudragoni has quit [Quit: WeeChat 1.9.1]
donryudragoni has joined #ocaml
oilshell1 has joined #ocaml
oilshell1 has left #ocaml [#ocaml]
kakadu has joined #ocaml
erwantin has joined #ocaml
jbrown has joined #ocaml
donryudragoni has quit [Quit: WeeChat 1.9.1]
fraggle_ has joined #ocaml
_andre has quit [Quit: leaving]
philtor has quit [Ping timeout: 264 seconds]
dejanr has left #ocaml [#ocaml]
yawaramin has quit [Ping timeout: 258 seconds]
yawaramin has joined #ocaml
mengu has joined #ocaml
enterprisey has quit [Remote host closed the connection]
raphaelss has joined #ocaml
mengu has quit [Ping timeout: 255 seconds]
KV_ has quit [Quit: leaving]
ahf has quit [Quit: Bye.]
jlouis has quit [Remote host closed the connection]
yawaramin has quit [Ping timeout: 246 seconds]
raphaelss has quit [Remote host closed the connection]
ahf has joined #ocaml
shinnya has joined #ocaml
argent_smith has quit [Quit: Leaving.]
hoy has joined #ocaml
<hoy> Are the icfp videos going to be uploaded?
<zozozo> hoy: the videos of the ocaml workshop should be uploaded soon (see https://discuss.ocaml.org/t/ocaml-2017-videos/842/4 )
Simn has quit [Read error: Connection reset by peer]
yawaramin has joined #ocaml
kakadu has quit [Remote host closed the connection]
hoy has quit [Ping timeout: 260 seconds]
hoy has joined #ocaml
<hoy> zozozo: Cool, looking forward to them
mengu has joined #ocaml
mengu has quit [Ping timeout: 240 seconds]
mengu has joined #ocaml
mengu has quit [Ping timeout: 248 seconds]
ziyourenxiang has joined #ocaml