companion_cube changed the topic of #ocaml to: Discussions about the OCaml programming language | http://www.ocaml.org | OCaml 4.11 release notes: https://caml.inria.fr/pub/distrib/ocaml-4.11/notes/Changes | Try OCaml in your browser: http://try.ocamlpro.com | Public channel logs at http://irclog.whitequark.org/ocaml
Tuplanolla has quit [Quit: Leaving.]
amiloradovsky has quit [Remote host closed the connection]
amiloradovsky has joined #ocaml
wonko7 has quit [Ping timeout: 264 seconds]
Haudegen has quit [Ping timeout: 268 seconds]
mxns has joined #ocaml
mxns has quit [Ping timeout: 240 seconds]
adrianbrink has quit [Read error: Connection reset by peer]
banjiewen_ has quit [Read error: Connection reset by peer]
SrPx has quit [Read error: Connection reset by peer]
cemerick has quit [Ping timeout: 264 seconds]
banjiewen_ has joined #ocaml
SrPx has joined #ocaml
adrianbrink has joined #ocaml
zv has quit [Ping timeout: 260 seconds]
cemerick has joined #ocaml
urek__ has quit [Quit: urek__]
jbrown has quit [*.net *.split]
troydm has quit [*.net *.split]
stux|RC-only has quit [*.net *.split]
delysin has quit [*.net *.split]
rpcope has quit [*.net *.split]
motherfsck has quit [*.net *.split]
TC01 has quit [*.net *.split]
jun has quit [*.net *.split]
companion_cube has quit [*.net *.split]
Armael has quit [*.net *.split]
stux|RC-only has joined #ocaml
zv has joined #ocaml
amiloradovsky has quit [Remote host closed the connection]
amiloradovsky has joined #ocaml
snowpanda has quit [Quit: Leaving...]
jbrown has joined #ocaml
Armael has joined #ocaml
jun has joined #ocaml
troydm has joined #ocaml
rpcope has joined #ocaml
TC01 has joined #ocaml
delysin has joined #ocaml
companion_cube has joined #ocaml
motherfsck has joined #ocaml
garfr has quit [Ping timeout: 246 seconds]
Jeanne-Kamikaze has joined #ocaml
<Jeanne-Kamikaze> When we partially apply a function, can we always expect the expressions of the then-free variables to be evaluated only once?
<Jeanne-Kamikaze> Seems to be the case playing around with tracing in utop, but I wanted to confirm my understanding.
<companion_cube> like if you have `let f x y = x+y`, then do `let g = f 10`?
<companion_cube> or rather, `let g = f (print"foo"; 10)`
<companion_cube> it's only evaluated once
zv has quit [Ping timeout: 240 seconds]
amiloradovsky has quit [Remote host closed the connection]
mfp has quit [Ping timeout: 272 seconds]
patrickp has joined #ocaml
<Jeanne-Kamikaze> Sorry, went afk. Yeah, thanks, I imagine the language being strict, that would be the case. I realized that wasn't the question I wanted to asked, hah.
sagax has joined #ocaml
<Jeanne-Kamikaze> The question is what happens to a subexpression inside the function that only depends on a free variable. For example: let foo a b = let c = something_expensive a in c + b;;
<Jeanne-Kamikaze> c only depends on a; can we expect it to be computed once and memoized when foo is partially applied on 'a'?
<Jeanne-Kamikaze> That doesn't seem to be the case.
<Jeanne-Kamikaze> My guess is the answer is "no" because 'something_expensive' could have side effects, which is unfortunate.
garfr has joined #ocaml
madroach has joined #ocaml
madroach_ has quit [Ping timeout: 256 seconds]
<companion_cube> yes, and also the compiler doesn't do such optimizations
<companion_cube> it'd only be transparent in the absence of side effects, as you remarked
garfr has quit [Ping timeout: 240 seconds]
<Jeanne-Kamikaze> Ok, thanks for confirming that.
<companion_cube> the language's semantics are very straightforward, and the compiler doesn't do crazy optimizations :)
copy has quit [Ping timeout: 265 seconds]
<Jeanne-Kamikaze> The interesting part is that 'foo' can be rewritten as let foo a = let c = something_expensive a in fun b -> c + b, which doesn't affect the client code.
<Jeanne-Kamikaze> So at least we can do the optimization ourselves without changing how 'foo' appears to the rest of the world.
<Jeanne-Kamikaze> At least in concept. I don't know if that makes any difference at the assembly level.
<companion_cube> you can definitely do that yourself
<companion_cube> it makes application slower (2 applications, with a closure) but if it's to be partially applied anyway it makes a lot of sense
GuerrillaMonkey has joined #ocaml
narimiran has joined #ocaml
Jeanne-Kamikaze has quit [Ping timeout: 256 seconds]
<GuerrillaMonkey> That makes sense, thanks. Going to call it a day for today, bye o/
GuerrillaMonkey has quit [Quit: Leaving]
garfr has joined #ocaml
waleee-cl has quit [Quit: Connection closed for inactivity]
vicfred has quit [Quit: Leaving]
mxns has joined #ocaml
_whitelogger has joined #ocaml
garfr has quit [Ping timeout: 268 seconds]
Putonlalla has quit [Ping timeout: 272 seconds]
Putonlalla has joined #ocaml
reynir has quit [Ping timeout: 272 seconds]
mxns has quit [Ping timeout: 256 seconds]
reynir has joined #ocaml
_whitelogger has joined #ocaml
_whitelogger has joined #ocaml
Haudegen has joined #ocaml
shawnw has joined #ocaml
hnOsmium0001 has quit [Quit: Connection closed for inactivity]
bartholin has joined #ocaml
wonko7 has joined #ocaml
Tuplanolla has joined #ocaml
plant_enjoyer has joined #ocaml
mfp has joined #ocaml
Haudegen has quit [Quit: Bin weg.]
borne has joined #ocaml
tryte has quit [Ping timeout: 240 seconds]
tryte has joined #ocaml
Haudegen has joined #ocaml
borne has quit [Ping timeout: 264 seconds]
narimiran has quit [Ping timeout: 260 seconds]
narimiran has joined #ocaml
borne has joined #ocaml
ggole has joined #ocaml
delysin has quit [Quit: WeeChat 3.0]
delysin has joined #ocaml
cantstanya has quit [Remote host closed the connection]
cantstanya has joined #ocaml
tane has joined #ocaml
emias has quit [Ping timeout: 265 seconds]
plant_enjoyer has quit [Quit: Leaving]
dborisog has joined #ocaml
emias has joined #ocaml
dborisog has quit [Remote host closed the connection]
dborisog has joined #ocaml
ulysse has joined #ocaml
shawnw has quit [Ping timeout: 260 seconds]
<mrvn> Does anyone know of a simple example or tutorial for extending the ocaml syntax to add methods to a class?
<companion_cube> "simple" and "extending syntax"? hmmm :)
<companion_cube> you could make a new class that inherits the old one and has new methods
<mrvn> companion_cube: the source would have a method or so9mething tagged with [@whatever] and the extension then needs to generate some code
<mrvn> The goal is to have methods in the class that call external C++ functions.
<companion_cube> oh my
<mrvn> Currently that means declaring an external funtion and then a mathod in the class that calls the external function. I want to automate that redirection.
<companion_cube> read about the ppx then I guess
<mrvn> Yeah. That's hard enough for normal types or expressions. But with classes I get drowned in the complexity.
<companion_cube> the alternative is codegen, like atd does, for example
<mrvn> Like a metalanguage that you compile to ocaml?
<companion_cube> and externals possibly, but yes
<mrvn> I really would like to just write "method [@external] bla : t -> int -> unit
waleee-cl has joined #ocaml
ulysse has quit [Remote host closed the connection]
bjorkint0sh has quit [Quit: Leaving]
noonien has quit [Quit: Ping timeout (120 seconds)]
noonien has joined #ocaml
Anarchos has joined #ocaml
garfr has joined #ocaml
Haudegen has quit [Quit: Bin weg.]
garfr has quit [Read error: Connection reset by peer]
sm2n_ has joined #ocaml
sm2n has quit [Remote host closed the connection]
zv has joined #ocaml
dborisog has quit [Ping timeout: 260 seconds]
stux|RC-- has joined #ocaml
tmhoang8 has joined #ocaml
Geekingfrog_ has joined #ocaml
jnavila has joined #ocaml
vsiles has quit [Ping timeout: 264 seconds]
stux|RC has quit [Ping timeout: 246 seconds]
dmbaturin has quit [Ping timeout: 246 seconds]
tristanC has quit [Ping timeout: 246 seconds]
Geekingfrog has quit [Read error: Connection reset by peer]
vsiles has joined #ocaml
tmhoang has quit [Read error: Connection reset by peer]
tmhoang8 is now known as tmhoang
dmbaturin has joined #ocaml
landonf has quit [Remote host closed the connection]
tristanC has joined #ocaml
landonf has joined #ocaml
vsiles has quit [Ping timeout: 246 seconds]
vsiles has joined #ocaml
nore has quit [Ping timeout: 264 seconds]
dmbaturin has quit [Ping timeout: 264 seconds]
dmbaturin has joined #ocaml
nore has joined #ocaml
Haudegen has joined #ocaml
nullcone has joined #ocaml
Geekingfrog_ is now known as Geekingfrog
ArthurStrong has joined #ocaml
<d_bot> <joris> That should be possible with a structure mapper that adds mangles external before in the structure definition list
<d_bot> <joris> But afaik you can define class inside expressions? I forgot.
<d_bot> <joris> For this in my ppx I have a global state in ppx that injects external in the top-level structure in front
ArthurStrong has left #ocaml [#ocaml]
<d_bot> <joris> I think if you just restrict yourself at first to top-level class definition it is trivial
mxns has joined #ocaml
<d_bot> <joris> Support for objects in expression can add later no?
<d_bot> <joris> That is what I did in similar ppx
stux|RC-- has quit [Quit: Aloha!]
<companion_cube> @joris: use a local module to define the class, worst case
<d_bot> <joris> You don't need to make it perfect for mvp, that is my view on ppx
stux|RC has joined #ocaml
<d_bot> <joris> Let users report missing usecases and fix them in order as it helps focusing priorities
<d_bot> <joris> @companion_cube for that the only issue is to come up with a good mangling scheme but technically if you use top level external injection with mangling then everything is supported
mxns has quit [Client Quit]
<d_bot> <joris> In fact I just use sequential counter
<mrvn> joris: How do you know the class name in the method hook?
<d_bot> <joris> @mrvn you plug in the mapper at class level not method level and pass it when you recurse
<d_bot> <joris> I've not done it for class but I do similar things with values in modules
<mrvn> joris: you mean you add a method mapper bound to the class name when you git a class, right?
<mrvn> s/git/hit/
<d_bot> <joris> Yes
<d_bot> <joris> I mean you call your mapper in the class body manually
ArthurStrong has joined #ocaml
<d_bot> <joris> Idk if it is really clean but this is what I do I don't record a mapper I just call recursive translation function
<mrvn> Anonymous classes will be a problem.
<d_bot> <joris> Fail with 'unsupported'
<mrvn> Or at least it can't support 2 anonymous classes having the same method.
<mrvn> class_method must be unique for the C part.
<d_bot> <joris> Attribute I mean not annotation
<d_bot> <joris> But once again in this kind of ppx I don't think it is require to support all the ocaml syntax if it does not directly serves the ppx purpose
<mrvn> totaly.
copy has joined #ocaml
copy has quit [Client Quit]
copy has joined #ocaml
copy has quit [Client Quit]
copy has joined #ocaml
copy has joined #ocaml
copy has quit [Client Quit]
copy has joined #ocaml
copy has quit [Client Quit]
vicfred has joined #ocaml
zv has quit [Ping timeout: 260 seconds]
patrickp has quit [Quit: Shuting down...]
patrickp has joined #ocaml
zv has joined #ocaml
hnOsmium0001 has joined #ocaml
amiloradovsky has joined #ocaml
mrvn has quit [Quit: Lost terminal]
wonko7 has quit [Ping timeout: 260 seconds]
ggole has quit [Quit: Leaving]
wonko7 has joined #ocaml
<d_bot> <EduardoRFS> someone know if the OCaml core team would be against adding unboxing for GADTs heterogeneous linked lists? I want to have heterogeneous arrays
<d_bot> <EduardoRFS> for this interpreter, this structure is read only
ArthurStrong has left #ocaml [#ocaml]
<zozozo> @EduardoRFS : could you be a bit more precise ? e.g. paste a type defintion for your heterogeneous linked list (or an interface), and (supposing it is doable currently), specify what you'd like to imrpove specifically ?
<d_bot> <EduardoRFS> I did sent a link but, I can copy it
<d_bot> <EduardoRFS> ```ocaml
<d_bot> <EduardoRFS> type (_, _) instr
<d_bot> <EduardoRFS> type (_, _) h_list =
<d_bot> <EduardoRFS> | Nil : ('a, 'a) h_list
<d_bot> <EduardoRFS> | Cons : ('b, 't) instr * ('t, 'a) h_list -> ('b, 'a) h_list
<d_bot> <EduardoRFS> ```
<d_bot> <EduardoRFS> the memory layout is of a linked list, because it is a linked list, but this could be easily encoded as an array, but the OCaml type system doesn't allow it
kitties is now known as catties
<d_bot> <EduardoRFS> the transformation on the Lambda is simple for the compiler, should be similar to how `[@@unboxed]` works, but the performance is way better, it's possible to try it by using `Obj.magic` a lot
narimiran has quit [Ping timeout: 240 seconds]
<cemerick> companion_cube: is the absence of a CCUnit intentional?
<companion_cube> hu :D
<companion_cube> what's to be found in such a module?
<cemerick> presumably just a `pp` impl on top of Stdlib.Unit
<companion_cube> ah there's a Stdlib.Unit now? damn
<cemerick> since 2018 in some form, yup
<zozozo> every type will one day have its own module, its own place it cna call home hopefully
<zozozo> :p
<companion_cube> oh well, I guess we could have CCUnit then…
<companion_cube> cemerick: for the caching thing, it's a good idea, I just don't understand how it works on github actions
<cemerick> it's surely "just" a matter of some yaml wrangling 🙃
<cemerick> I'd pitch you a config PR, but I've only ever done gitlab CI stuffs
<companion_cube> yes, kill me now
<cemerick> it's comforting insofar as yaml wrangling is _always_ better than Dockerfile wrangling lol
chewbranca has quit [Ping timeout: 244 seconds]
mgsk has quit [Ping timeout: 244 seconds]
chewbranca has joined #ocaml
mgsk has joined #ocaml
Yagotzirck has joined #ocaml
borne has quit [Ping timeout: 272 seconds]
neiluj has joined #ocaml
neiluj has quit [Changing host]
neiluj has joined #ocaml
catties is now known as kitties
Jesin has quit [Quit: Leaving]
amiloradovsky has quit [Remote host closed the connection]
<companion_cube> what does it even mean to have a cache
<oni-on-ion> what is this ? /home/runner/work/_temp/ab10200d-f006-4758-af46-2934a1be84e8.sh: line 1: opam: command not found
<oni-on-ion> some kind of docker thing =)
Jesin has joined #ocaml
<companion_cube> it's just that I still need to run enough of the setup step to get opam isntalled I guess
<zozozo> companion_cube: the cache is basically a filesystem cache of the directory you give
<zozozo> so assuming you cache the .opam repo, you still need to install opam in the event of a cache hit
<zozozo> s/repo/dir
<companion_cube> I mean ok, but it's not clear to me where the get/set occur, basically
Jesin has quit [Remote host closed the connection]
Jesin has joined #ocaml
<zozozo> ah, yeah, it's not really clear, but it seems it before and fter everything has been run
<zozozo> ah well actually, the get is where you put the action I think, and the set/update is at the end if the workflow succeeds
Anarchos has quit [Quit: Vision[0.10.3]: i've been blurred!]
jnavila has quit [Ping timeout: 264 seconds]
<d_bot> <octachron> @EduardoRFS , that sounds very ad-hoc. Moreover, wouldn't you end up with invisible array copy when destructuring? And you would also need to unbox unary integers for projections. Directly adding heterogeneous arrays (or emulating them with Obj.magic) sounds simpler and less error-prone. For immutable array, you can even avoid the value restriction awkwardness of heterogeneous lists. But you are still at the frontier of depende
<d_bot> <EduardoRFS> @octachron it is very ad-hoc, but it's because the general case for unboxing seems to be in the RFC hell at this point. But nope you don't need to copy it, if you encode the access as `(int, array)`, to read the next internally you just bump the `int` like a program counter, maybe I can do that with a typed based PPX + Obj.magic
<d_bot> <EduardoRFS>
<d_bot> <EduardoRFS> Adding directly heterogeneous arrays would be really cool, but I don't think they fit well in the OCaml type system
<companion_cube> probably not, how do you type `foo.(i)`?
<d_bot> <EduardoRFS> /\ exactly, this is why as an optimization it makes so much more sense
neiluj has quit [Quit: leaving]
<d_bot> <octachron> With the standard unary encoding of projectors?
<d_bot> <octachron> ```ocaml
<d_bot> <octachron> type ('array,'elt) nat = Z: ('x -> 'rest, 'x) nat | S: ('array, 'x) nat -> ( _ -> 'array, 'x) nat
<d_bot> <octachron> ```
<d_bot> <octachron> Keeping the offset in the memory representation stops to work once you are consing a de-structured array, isn't it?
<companion_cube> but that's not an array, is it?
<octachron> It is the index of the array.
<companion_cube> if the compiler supports that, I guess
<companion_cube> I wonder how you create such an array though
Yagotzirck has quit [Quit: Leaving]
<octachron> Currenty, with Obj.magic. Something like https://github.com/Octachron/oceti/blob/master/src/tuple.ml#L47 for instance, but without all ppxs that have sneaked into the main compiler.
<companion_cube> :/
<Armael> yum
bartholin has quit [Quit: Leaving]
<companion_cube> there are ppxes in the compiler now?
<octachron> No. Just the syntactic sugar that was provided by the ppxs used in this project, aka list literals and indexing operators.
<octachron> This is an old toy project, there is even an _oasis file there.
Madars has quit [Quit: WeeChat 1.9.1]
<d_bot> <EduardoRFS> @octachron it still behaves like a normal, nope keeping the offset in memory still works, remember from the code perspective it's still a single operation
<d_bot> <EduardoRFS>
<d_bot> <EduardoRFS> ```ocaml
<d_bot> <EduardoRFS> let (first, rest) = my_linked_list_as_an_array in
<d_bot> <EduardoRFS> (* to *)
<d_bot> <EduardoRFS> let (first, rest) =
<d_bot> <EduardoRFS> let (i, array) = my_linked_list_as_an_array in
<d_bot> <EduardoRFS> (Array.unsafe_get array i, (i + 1, array)
<d_bot> <EduardoRFS> ```
<d_bot> <octachron> But the algebraic datatype interface exposes `Cons` as a cheap operation.
<d_bot> <EduardoRFS> @octachron sorry to keep pinging you <3, but do you have any material to point me on the projectors thing, I never heard about it
<d_bot> <EduardoRFS> but yeah cons is expensive if you're calling Cons on the array structure
strmpnk has quit [Ping timeout: 244 seconds]
kristjansson has quit [Ping timeout: 258 seconds]
<companion_cube> ok, the cache seems to work, nice
mgsk has quit [Ping timeout: 264 seconds]
ec has quit [Ping timeout: 264 seconds]
l1x has quit [Ping timeout: 264 seconds]
Duns_Scrotus has quit [Ping timeout: 272 seconds]
mrallen1 has quit [Ping timeout: 264 seconds]
jmct has quit [Ping timeout: 260 seconds]
<d_bot> <octachron> It is a good question? It is more or less the type you end up when you try to pick the k-th elements of the list. It is kind of part of the folkloric bag of GADTs trick. I am not aware of an explicit reference?
<d_bot> <EduardoRFS> oh, yeah I think I understood it, but just wanted to get more reference on this idea
borne has joined #ocaml
Haudegen has quit [Ping timeout: 240 seconds]
tane has quit [Quit: Leaving]