companion_cube changed the topic of #ocaml to: Discussion about the OCaml programming language | http://www.ocaml.org | OCaml 4.12 released: https://ocaml.org/releases/4.12.0.html | Try OCaml in your browser: https://try.ocamlpro.com | Public channel logs at https://libera.irclog.whitequark.org/ocaml/
<d_bot> <Shon F> I think a more relevant approach to your needs might be normalization by evaluation? https://en.wikipedia.org/wiki/Normalisation_by_evaluation
<d_bot> <Shon F> (But I don't have a great grasp on the tradeoffs here vs. HOAS tho.)
<companion_cube> (hi, what's ABT? :P)
<d_bot> <Shon F> Sorry, ABT is "Abstract Binding Tree": it's an AST but with the notion of variable binding baked in.
<d_bot> <Shon F> Neel Krishnaswami has a nice exposition here: https://semantic-domain.blogspot.com/2015/03/abstract-binding-trees.html
<companion_cube> hmmmmmmmm
<companion_cube> is the `join` operation used to merge variables from subterms in a generic way?
<d_bot> <Shon F> The idea is that you can reuse your ABT library or data structure to take care of all the variable binding logic for your different languages, rather than have to re implement your binding/substitution logic for each language.
<companion_cube> ah yes, set of free variables.
<companion_cube> sure, but then you may have different efficiency tradeoffs :)
waleee has quit [Quit: WeeChat 3.2]
<d_bot> <Shon F> Yes, I don't think ABTs address the efficiency concern of substitution at all. I only thought that was worth mentioning because of the mention of using pointers.
waleee has joined #ocaml
<companion_cube> ah, yes
<d_bot> <Shon F> I'm more hopeful about NbE's re: the efficiency angle.
<companion_cube> @Cyclomatic Complexity: I've long wondered about using https://github.com/c-cube/ocaml-containers/blob/master/src/data/CCRAL.mli for O(ln n) de Bruijn environments
<companion_cube> gives you a O(1) cons, and O(ln(n)) indexing, which I think is just what's needed
<d_bot> <Shon F> Do you know offhand what would be the cost for replacing a cell?
<d_bot> <Shon F> Would you just do a `mapi` for the substitution? (Or perhaps I misunderstand entirely 😐 ).
<companion_cube> ouch, yeah, that's harder
<companion_cube> with DB indices you typically don't need to _replace_ stuff, I think? you just prepend when entering a scope
<d_bot> <Shon F> Ah! I'd assumed you'd needed some sort of replacement when it comes time to substitute values for the variables. But tbh, it's been a long time since I implemented something using DB indices, and I didn't like it or internalize it at all at the time any how 🙂
waleee has quit [Ping timeout: 255 seconds]
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<d_bot> <darrenldl> wasn't there a shift operation required? (im very rusty) granted it's simpler than alpha conversion
<d_bot> <darrenldl>
<d_bot> <darrenldl> though still proportional to size of expression
<companion_cube> you need to shift the substituted term
<companion_cube> if it's closed, no shifting required :)
<companion_cube> in CBV I think it's possible that all substituted terms are closed
<companion_cube> (values should be closed terms after all)
vicfred_ has joined #ocaml
vicfred has quit [Ping timeout: 268 seconds]
rgrinberg has joined #ocaml
favonia has quit [Ping timeout: 255 seconds]
favonia has joined #ocaml
zebrag has quit [Quit: Konversation terminated!]
favonia has quit [Ping timeout: 255 seconds]
favonia has joined #ocaml
vicfred_ has quit [Quit: Leaving]
vicfred has joined #ocaml
<d_bot> <darrenldl> ah right
rgrinberg has quit [Read error: Connection reset by peer]
favonia has quit [Ping timeout: 255 seconds]
favonia has joined #ocaml
favonia has quit [Ping timeout: 255 seconds]
favonia has joined #ocaml
favonia has quit [Ping timeout: 255 seconds]
favonia has joined #ocaml
favonia has quit [Ping timeout: 255 seconds]
favonia has joined #ocaml
gravicappa has joined #ocaml
favonia has quit [Remote host closed the connection]
favonia has joined #ocaml
gravicappa has quit [Ping timeout: 255 seconds]
PinealGlandOptic has joined #ocaml
Serpent7776 has joined #ocaml
Tuplanolla has joined #ocaml
gravicappa has joined #ocaml
dh` has quit [Remote host closed the connection]
<d_bot> <Cyclomatic Complexity> companion_cube: two problems with this approach given what i want to do:
<d_bot> <Cyclomatic Complexity> 1. i need semantics where i can do some substitutions in a term, without reducing it to a normal-form (tl;dr, no `val eval : expression -> value`), and then assemble it with some other AST on which some substitutions were done too. the problem with environments is that they usually assume a "top-level" environment because you never reduce under lambdas. (obviously, because I have a very limited idea of SOTA, there i
<d_bot> <Cyclomatic Complexity> 2. because i don't only have cbv semantics, I need shifts
cedric has joined #ocaml
<d_bot> <Cyclomatic Complexity> @Shon F This looks very relevant, and I am currently looking at it, thank you!
bartholin has joined #ocaml
dh` has joined #ocaml
mro has joined #ocaml
mro has quit [Remote host closed the connection]
mro has joined #ocaml
bartholin has quit [Ping timeout: 268 seconds]
Haudegen has joined #ocaml
bartholin has joined #ocaml
mro has quit [Remote host closed the connection]
mro has joined #ocaml
mro has quit [Ping timeout: 268 seconds]
mro has joined #ocaml
mro has quit [Remote host closed the connection]
mro has joined #ocaml
mro has quit [Remote host closed the connection]
mro has joined #ocaml
bartholin has quit [Ping timeout: 265 seconds]
mro has quit [Ping timeout: 252 seconds]
bartholin has joined #ocaml
mro has joined #ocaml
bartholin has quit [Ping timeout: 265 seconds]
<companion_cube> right
<companion_cube> I think Coq uses DB indices and yet does strong normalization
mro has quit [Ping timeout: 246 seconds]
mro has joined #ocaml
bartholin has joined #ocaml
mro has quit [Remote host closed the connection]
bartholin has quit [Ping timeout: 265 seconds]
mro has joined #ocaml
mro has quit [Ping timeout: 265 seconds]
mro has joined #ocaml
adanwan has quit [Remote host closed the connection]
adanwan has joined #ocaml
mro has quit [Ping timeout: 255 seconds]
gravicappa has quit [Ping timeout: 252 seconds]
Stumpfenstiel has joined #ocaml
mbuf has joined #ocaml
mbuf has quit [Client Quit]
mbuf has joined #ocaml
mro has joined #ocaml
mbuf has quit [Client Quit]
mro has quit [Ping timeout: 250 seconds]
<d_bot> <Drup> @Shon F mmmmh, this is interesting, maybe I should see if I can provide something like that in https://github.com/Drup/peahell
<d_bot> <Drup> It's definitely missing name handling utilities right now
<d_bot> <Drup> (and efficiency barely matters for what it's intended, i.e. prototypes)
<companion_cube> I'm curious indeed about the tradeoffs wrt HOAS
<companion_cube> like bindlib
mro has joined #ocaml
bartholin has joined #ocaml
mro has quit [Remote host closed the connection]
neiluj has joined #ocaml
mro has joined #ocaml
gravicappa has joined #ocaml
mro has quit [Ping timeout: 268 seconds]
zebrag has joined #ocaml
mro has joined #ocaml
<neiluj> Hello! Is there a way to write the last function in point free style? https://bpa.st/QMZA
<companion_cube> maybe, but that sounds like a bad idea
<neiluj> okay, thanks :)
<companion_cube> also this is going to be slow ;)
<neiluj> oh yeah this solution is pretty inefficient, in C you can xor on 64 bit integers (thus reducing to 2 xors in this case) for instance
<neiluj> couldn't find a way to do so with the Base api
<companion_cube> ahahah no I mean, the lists
<companion_cube> xors are incredibly cheap in comparison
<neiluj> oh yeah
<companion_cube> something like https://paste.isomorphis.me/MIV should be faster
<companion_cube> (once tweaked so it compiles)
<companion_cube> much, much faster
<neiluj> maybe using Bytes.set?
<companion_cube> iirc `a.[i] <- x` is just `Bytes.set a i x`
<companion_cube> but maybe it's `a.(i)`
<neiluj> oh many thanks!!
zebrag has quit [Quit: Konversation terminated!]
<d_bot> <darrenldl> if you really need fast xor, look into c ffi
<d_bot> <darrenldl> though using unsafe_get/set might already provide enough savings
<neiluj> thanks for the suggestion, it's fast enough as it is
isekaijin has joined #ocaml
<d_bot> <darrenldl> what is this for if you dont mind me asking?
<neiluj> a Kademlia DHT :)
<d_bot> <darrenldl> interesting
<companion_cube> should be short strings then
<companion_cube> no need for C calls
<neiluj> yeah, 128 bit hashes
bartholin has quit [Ping timeout: 268 seconds]
bartholin has joined #ocaml
mro has quit [Remote host closed the connection]
waleee has joined #ocaml
mro has joined #ocaml
mro has quit [Remote host closed the connection]
mro has joined #ocaml
mro has quit [Remote host closed the connection]
Haudegen has quit [Quit: No Ping reply in 180 seconds.]
Haudegen has joined #ocaml
bartholin has quit [Ping timeout: 268 seconds]
<hannes_> [where Cstruct.t is a record {length, offset, bigarray} backed by a bigarray https://ocaml.org/api/Bigarray.html -- should be similar if you use bytes/string
<neiluj> Nice! Thank you very much, this reduces to a one liner
bartholin has joined #ocaml
<haesbaert> hannes_: anything missing to merge the dhcp changes ?
<neiluj> hannes_, it's 10% faster in average with your suggestion :)
hannes_ is now known as hannes
<neiluj> huh, more like 15%
<hannes> neiluj: which suggestion?
<hannes> haesbaert: not sure, I have only been 1 hour in front of my computer since thursday
<haesbaert> ack
<neiluj> hannes, to use the xor from Mirage
mro has joined #ocaml
mro has quit [Client Quit]
<hannes> haesbaert: I pushed a commit to bump the lower bound of OCaml, now CI should be green, and that could be merged :) thanks for working on it!
<haesbaert> hooray, thanks for review
<haesbaert> and good times were had by all
<companion_cube> neiluj: but then you need Cstruct.t which is bigger and doesn't play as nicely with the GC :p
<companion_cube> if you allocate a lot of such small strings I'm not sure the benchmarks are accurate
bartholin has quit [Ping timeout: 255 seconds]
<hannes> (please note the links above are for inspiration, you could very well use 99% the same code for bytes/string)
neiluj has quit [Remote host closed the connection]
neiluj has joined #ocaml
<neiluj> good to know
bartholin has joined #ocaml
<copy> Aren't all of those instructions sse2 and could therefore be used on all x86_64 machines? (talking about xor_into)
<companion_cube> neiluj: if you implement a DHT, xoring might be a blip on the radar anyway
<neiluj> yeah, I've made some tests and there's not that much of a difference between the two ways
<neiluj> RAM and time-wise
<neiluj> and in unrealistic conditions: 200 nodes running locally :p
bartholin has quit [Ping timeout: 268 seconds]
gravicappa has quit [Ping timeout: 255 seconds]
neiluj has quit [Quit: Leaving]
Haudegen has quit [Quit: No Ping reply in 180 seconds.]
Tuplanolla has quit [Quit: Leaving.]
Haudegen has joined #ocaml
waleee has quit [Ping timeout: 246 seconds]
waleee has joined #ocaml
Stumpfenstiel has quit [Ping timeout: 255 seconds]
Haudegen has quit [Ping timeout: 268 seconds]
cedric has quit [Quit: Konversation terminated!]