pi3ce has quit [Read error: Connection reset by peer]
Tuplanolla has quit [Quit: Leaving.]
<discocaml>
<qrpnxz> :ocaml_hug:
f[x] has joined #ocaml
f[x] has quit [Remote host closed the connection]
toastal has joined #ocaml
toastal has left #ocaml [Disconnected: Hibernating too long]
neiluj has joined #ocaml
<neiluj>
Hi! does httpaf support multicore in OCaml5? as in multiple requests can be served concurrently
Serpent7776 has joined #ocaml
toastal has joined #ocaml
<discocaml>
<dinosaure> You can take a look on https://github.com/robur-coop/httpcats 🙂 it uses a fork (and well maintained) of http/af and gives you the ability to use multiple domains via the miou scheduler 🙂
<discocaml>
<barconstruction> People say that modules are implemented as records. Does this incur a slight overhead as opposed to a direct function call? Like if I call M.f does this jump to the code for f or the record M and then f
<zozozo>
@barconstruction most of the time, it will jump directly to `f`, because the compiler is made to optimize it that way as much as possible; but there are some cases where it it not possible to know statically exactly which function is called (e.g. with first-class modules), in which case, the code will jump to the underlying record, and then to the function
<discocaml>
<barconstruction> Alright, that's what I expected but I wasn't sure. Sometimes you expect a compiler optimization but then somebody more knowledgeable explains why that would be unsound in general and so you can't expect it. Like as a newcomer I hoped that OCaml would admit Haskell-style list fusion but I can see why that would be unsound in general
<companion_cube>
if you have a module that's statically defined (a file, a `module M = struct … end` inside a file, etc.) then it should directly point to the function inside
<companion_cube>
it's muddier with functors
bartholin has joined #ocaml
jiquiame has quit [Quit: WeeChat 4.2.2]
neiluj has quit [Ping timeout: 260 seconds]
Anarchos has quit [Quit: Vision[]: i've been blurred!]
Tuplanolla has joined #ocaml
Janni has joined #ocaml
<Janni>
Hi.
Janni has quit [Client Quit]
<discocaml>
<jannisan> I have a module that defines physical equality semantics for some type. The equals function is simple : `let equal x y = x == y`.
<discocaml>
<jannisan> However I also need a `compare` function (for maps and the sort) and I'm stumped. `x > y` gives me an `Out_of_memory` exception.
<discocaml>
<yawaramin> did you implement a custom comparison?
<discocaml>
<jannisan> Well, that's what I'm trying to do, but it doesn't make sense to go look at the values of the structure, since ... it's supposed to be about physical equality.
<discocaml>
<jannisan> If I do `let y = {x with f = x.f}` then it should hold that `x <> y`, which is fine, which works.
<discocaml>
<jannisan> BUT what should `compare x y` yield, `-1` or `1` ?
<discocaml>
<jannisan> If I could somehow compare the addresses of `x` and `y`, but I don't find any way to do so.
<discocaml>
<jannisan> So my problem is to find a definition of `compare` that yields some sensible value, which most importantly respects transitivity.
<discocaml>
<jannisan> If only I could somehow compare the addresses of `x` and `y`... but I don't find any way to do so.
<discocaml>
<._null._> If you want to use dangerous stuff, you can compare `(Obj.magic x : int)` and `Obj.magic y : int)`
<discocaml>
<._null._> If you want to use dangerous stuff, you can compare `(Obj.magic x : int)` and `(Obj.magic y : int)`
<discocaml>
<yawaramin> so you want to define 'compare' as 'pointer location on the heap'? but won't this be impacted by doing a GC?
<discocaml>
<._null._> ^
<discocaml>
<._null._> ^ This is the main reason why addresses aren't exposed
<discocaml>
<._null._> ^ This is the main reason why addresses aren't exposed in any way
<discocaml>
<jannisan> Ah, I see.
<discocaml>
<octachron> @._null._ , that's is not a valid implementation at all.
<discocaml>
<octachron> In general, if you don't have a valid order relation, you cannot implement a `compare` function.
<discocaml>
<octachron> One option is to add `id` to your values rather than relying on physical equality. Or resort to using lists.
<discocaml>
<octachron> Hashmap are another option (sampling a finite part of the contents in order to compute the hash).
Anarchos has joined #ocaml
neiluj has joined #ocaml
<discocaml>
<jannisan> I wish there were a pure interface `Hashtbl.Map` of `Hashtbl`, one that is compatible with `Map` so I could simply replace current uses of `Map` by `Hashtbl.Map`.
<discocaml>
<jannisan> (Because all my uses of `Map` are now obsolete, since they rely on a broken implementation of `compare`.)
Anarchos has quit [Quit: Vision[]: i've been blurred!]
Anarchos has joined #ocaml
<discocaml>
<deepspacejohn> `type t = {id: int; foo: bar;} let next = ref (-1 ) let make foo = incr next; {id = !next; foo} let equal a b = Int.equal a.id b.id let compare a b = Int.compare a.id b.id`
toastal has quit [Quit: Gateway shutdown]
neiluj has quit [Ping timeout: 244 seconds]
bartholin has quit [Ping timeout: 244 seconds]
bartholin has joined #ocaml
<discocaml>
<sim642> More data structure libraries would be great for OCaml indeed. Pottier has been doing a lot in that direction, but so many things are still to be done.
<discocaml>
<sim642> For example, Scala has quite an extensive collections library which includes immutable hash maps etc
neuroevolutus has joined #ocaml
<discocaml>
<yawaramin> doesn't containers have a lot of these?