<discocaml>
<deepspacejohn> You can also store type information into GADTs. Although it’s likely that is not the solution to whatever you’re trying to do.
azimut has quit [Ping timeout: 255 seconds]
<discocaml>
<shawnfrostx> Which library is preferred if I need fixed width integers? ocaml-stdint or ocaml-integers or are there others? I'm leaning towards ocaml-integers since it seems like it's one of the dependencies of ctypes and luv.
xgqt has quit [Quit: WeeChat 3.7.1]
xgqt has joined #ocaml
<discocaml>
<idontwantausernamefeckoff> eios cancellation is so awkward
<discocaml>
<idontwantausernamefeckoff> i know it’s not a standard thing for green thread systems to do, but i’d like it if i could externally cancel a switch or fiber cleanly without promises or exceptions
<discocaml>
<idontwantausernamefeckoff> just a single that says
<discocaml>
<idontwantausernamefeckoff> cancel this switch from outside
rgrinberg has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<dh`>
cancelling a thread is a nasty, nasty thing to do unless it shares no state with anything else (and often even then)
<dh`>
don't do it.
dh` has quit [Quit: bbiab]
jutty has quit [Quit: jutty]
waleee has quit [Ping timeout: 264 seconds]
famubu has left #ocaml [#ocaml]
dh` has joined #ocaml
rgrinberg has joined #ocaml
raskol has quit [Ping timeout: 260 seconds]
<dh`>
oh also, for sized integers the Int64 and Int32 in the stdlib are adequate, but you'll want to wrap them in your own module because they can't make up their mind if they're signed or unsigned
<dh`>
(some of the operations have two versions, others don't, and some where the signedess matters leave it unspecified)
raskol has joined #ocaml
Square3 has joined #ocaml
<discocaml>
<darrenldl> would `Eio.Fiber.first` satisfy that?
jtza8 has joined #ocaml
jtza8 has joined #ocaml
jtza8 has quit [Changing host]
rgrinberg has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
mbuf has joined #ocaml
bartholin has joined #ocaml
zanetti has quit [Quit: zanetti]
dnh has joined #ocaml
dnh has quit [Ping timeout: 255 seconds]
dh` has quit [Quit: brb]
dh` has joined #ocaml
Serpent7776 has joined #ocaml
<discocaml>
<lukstafi> Hi scheduler writing enthusiasts, you probably know but I didn't: there's a package `domain-local-await`.
rgrinberg has joined #ocaml
bartholin has quit [Quit: Leaving]
olle has joined #ocaml
azimut has joined #ocaml
masterbuilder_ has joined #ocaml
masterbuilder has quit [Ping timeout: 268 seconds]
neiluj has joined #ocaml
raskol has quit [Ping timeout: 264 seconds]
dnh has joined #ocaml
dnh has quit [Ping timeout: 255 seconds]
dnh has joined #ocaml
azimut has quit [Remote host closed the connection]
azimut has joined #ocaml
torretto has quit [Remote host closed the connection]
torretto has joined #ocaml
<discocaml>
<bluddy5> So Owl is ending its support. Can we get it moved to ocaml-community please?
<discocaml>
<idontwantausernamefeckoff> dh: cancelling a switch or fiber doesn’t kill it though, from what i can tell it’s closer to a global flag telling you not to start or continue any work in that switch and finish as soon as possible
<discocaml>
<idontwantausernamefeckoff> which is a nice way to do cancellation if you didn’t have to implement that by moving the switch out of use and throwing an arbitrary exception on it, or just writing your own promise and adding even more values to carry around
torretto has quit [Remote host closed the connection]
torretto has joined #ocaml
torretto has quit [Remote host closed the connection]
rgrinberg has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
torretto has joined #ocaml
masterbuilder_ has quit [Changing host]
masterbuilder_ has joined #ocaml
<discocaml>
<dalpy> Is it just me or does the OCaml Platform extension just not work in .ocamlinits? I can't get type information or autocomplete, everything is underlined red
jutty has joined #ocaml
<discocaml>
<dalpy> (**by everything I mean module and definitions from my dune project libraries)
jabuxas has joined #ocaml
mro has joined #ocaml
jabuxas_ has joined #ocaml
azimut has quit [Remote host closed the connection]
azimut has joined #ocaml
azimut has quit [Remote host closed the connection]
azimut has joined #ocaml
mro has quit [Remote host closed the connection]
mro has joined #ocaml
jabuxas_ has quit [Ping timeout: 256 seconds]
azimut has quit [Remote host closed the connection]
azimut has joined #ocaml
alexherbo2 has joined #ocaml
jutty has quit [Ping timeout: 272 seconds]
jutty has joined #ocaml
azimut has quit [Ping timeout: 255 seconds]
azimut has joined #ocaml
mro has quit [Quit: Leaving]
omegatron has joined #ocaml
jabuxas has quit [Ping timeout: 256 seconds]
Square3 has quit [Ping timeout: 240 seconds]
jutty has quit [Ping timeout: 255 seconds]
jutty has joined #ocaml
neiluj has quit [Quit: neiluj]
neiluj has joined #ocaml
dh` has quit [Ping timeout: 268 seconds]
dh` has joined #ocaml
cr1901_ has joined #ocaml
oisota has quit [Read error: Connection reset by peer]
cr1901 has quit [Ping timeout: 264 seconds]
oisota has joined #ocaml
ocabot has quit [Ping timeout: 268 seconds]
cr1901 has joined #ocaml
cr1901_ has quit [Ping timeout: 268 seconds]
szkl has quit [Ping timeout: 264 seconds]
buoy49_ has quit [Ping timeout: 246 seconds]
waleee has joined #ocaml
cr1901 has quit [Read error: Connection reset by peer]
abbe__ has quit [Ping timeout: 246 seconds]
jabuxas has joined #ocaml
bibi_ has quit [Quit: Konversation terminated!]
cr1901 has joined #ocaml
buoy49_ has joined #ocaml
cr1901 has quit [Read error: Connection reset by peer]
cr1901 has joined #ocaml
cr1901_ has joined #ocaml
landonf has quit [Ping timeout: 260 seconds]
cr1901 has quit [Read error: Connection reset by peer]
jabuxas has quit [Quit: oops :p]
buoy49_ has quit [Ping timeout: 268 seconds]
neiluj_ has joined #ocaml
abbe__ has joined #ocaml
bibi_ has joined #ocaml
pgiarrusso has quit [Ping timeout: 268 seconds]
cr1901_ has quit [Read error: Connection reset by peer]
neiluj has quit [Ping timeout: 256 seconds]
neiluj_ is now known as neiluj
ocabot has joined #ocaml
<discocaml>
<_ggole> I'm playing with the thing where you use object types as a GADT argument to select which constructors are possible, and have run into an interesting situation.
<discocaml>
<_ggole> ```ocaml
<discocaml>
<_ggole> type y = YInj
<discocaml>
<_ggole> type n = NInj
<discocaml>
<_ggole>
<discocaml>
<_ggole> type _ t =
<discocaml>
<_ggole> | A : <a : y; ..> t
<discocaml>
<_ggole> | B : <b : y; ..> t
<discocaml>
<_ggole> | C : <c : y; ..> t
<discocaml>
<_ggole> | Null : <null : y; ..> t
<discocaml>
<_ggole>
<discocaml>
<_ggole> type ab = <a : y; b : y; c : n; null : n> t
<discocaml>
<_ggole> type ab_option = <a : y; b : y; c : n; null : y> t
<discocaml>
<_ggole>
landonf has joined #ocaml
<discocaml>
<_ggole> (* Ok so far. *)
<discocaml>
<_ggole> let foo : ab = if true then A else B
<discocaml>
<_ggole>
<discocaml>
<_ggole> (* We need to be able inject values of ab into ab_option. We can do
<discocaml>
<_ggole> this with a 'some' written over exactly those pair of types... *)
<discocaml>
<_ggole> let some : ab -> ab_option = function
<discocaml>
<_ggole> | A | B as ab -> ab
<discocaml>
<_ggole>
<discocaml>
<_ggole> let foo_opt : ab_option = if Random.bool () then some foo else Null
<discocaml>
<_ggole>
<discocaml>
<_ggole> (* The question: can 'some' be given a type that injects arbitrary
<discocaml>
<_ggole> non-null ts into null ts? Something like this, where the two .. can
<discocaml>
<_ggole> be equal. *)
<discocaml>
<_ggole> let poly_some : <null : n; ..> t -> <null : y; ..> t = function
<discocaml>
<_ggole> | A | B | C as abc -> abc
<discocaml>
<_ggole> ```
<discocaml>
<_ggole> Is it possible to write `poly_some` or something like it?
<discocaml>
<_ggole> (To be clear, this version of `poly_some` is not polymorphic in the desired way.)
<olle>
urgh
<discocaml>
<bluddy5> Please don't write a lot of code in this channel
<discocaml>
<bluddy5> Please don't post a lot of code in this channel
<discocaml>
<_ggole> Oh yeah, the irc bridge. Sorry!
<olle>
<3
Boarders___ has quit [Ping timeout: 268 seconds]
pgiarrusso has joined #ocaml
Boarders___ has joined #ocaml
jtza8 has quit [Quit: ERC 5.4 (IRC client for GNU Emacs 28.2)]
trillion_exabyte has quit [Ping timeout: 255 seconds]
<octachron>
The reliable solution is to expand every fields: "type a b c. <null : n; a:a; b:b; c:c > t ->
<octachron>
<null : y; a:a; b:b; c:c > t"
jabuxas has joined #ocaml
pgiarrusso has quit [Ping timeout: 264 seconds]
trillion_exabyte has joined #ocaml
<discocaml>
<_ggole> OK, I can try that
jabuxas_ has joined #ocaml
Boarders___ has quit [Ping timeout: 264 seconds]
<discocaml>
<_ggole> That works, although or-patterns no longer type check. I guess this is livable.
<discocaml>
<_ggole> Thanks!
buoy49_ has joined #ocaml
Square3 has joined #ocaml
jabuxas_ has quit [Ping timeout: 264 seconds]
GreaseMonkey has quit [Ping timeout: 264 seconds]
jutty has quit [Ping timeout: 246 seconds]
jutty has joined #ocaml
Boarders___ has joined #ocaml
szkl has joined #ocaml
pgiarrusso has joined #ocaml
Square3 has quit [Ping timeout: 260 seconds]
greaser|q has joined #ocaml
jutty has quit [Quit: jutty]
cr1901 has joined #ocaml
jutty has joined #ocaml
<discocaml>
<barconstruction> One good justification for this is that the owl book is recommended on the OCaml website for beginners.
<discocaml>
<bluddy5> Owl is terrific and needs to be preserved and updated for the ecosystem.
jabuxas_ has joined #ocaml
jabuxas has quit [Ping timeout: 268 seconds]
jabuxas_ has quit [Ping timeout: 256 seconds]
jutty has quit [Quit: jutty]
cr1901 has quit [Read error: Connection reset by peer]
cr1901_ has joined #ocaml
duncan has quit [Remote host closed the connection]
duncan has joined #ocaml
greaser|q has quit [Ping timeout: 256 seconds]
greaser|q has joined #ocaml
olle has quit [Ping timeout: 264 seconds]
<discocaml>
<regularspatula> Yeah it would be cool to see owl getting some funding again
jutty has joined #ocaml
waleee has quit [Ping timeout: 264 seconds]
szkl has quit [Ping timeout: 268 seconds]
mbuf has quit [Quit: Leaving]
alexherbo2 has quit [Remote host closed the connection]
szkl has joined #ocaml
neiluj has quit [Quit: neiluj]
theblatte has quit [Ping timeout: 240 seconds]
rgrinberg has joined #ocaml
average has joined #ocaml
theblatte has joined #ocaml
pie_ has quit [Ping timeout: 255 seconds]
<discocaml>
<idontwantausernamefeckoff> in eio, how could i check if a socket is open?
<discocaml>
<idontwantausernamefeckoff> e.g. if the client has reset or disconnected
pie_ has joined #ocaml
bartholin has joined #ocaml
fweht has joined #ocaml
rgrinberg has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
Tuplanolla has joined #ocaml
dh` has quit [Changing host]
dh` has joined #ocaml
<dh`>
idontwantausername: what it still boils down to is that cancelling threads is a mess
zanetti has joined #ocaml
<companion_cube>
Always
<companion_cube>
It's also hard to know if a socket is disconnected, except by trying to write in it
<dh`>
in unix a socket that disconnects should select for reading and give you a read of 0 bytes to indicate eof
<dh`>
if that doesn't show through properly to the library you're using, consider a different library :-|
<discocaml>
<idontwantausernamefeckoff> dh`: yeah, i worked out eventually how to get an eof reading from the socket raw in eio
<discocaml>
<idontwantausernamefeckoff> cohttp doesn't seem to expose that
<discocaml>
<idontwantausernamefeckoff> the context is that i have a chunked-transfer request which might take a long time and should finish processing if the user disconnects
<discocaml>
<idontwantausernamefeckoff> the context is that i have a chunked-transfer request which might take a long time and should finish processing if the user disconnects (even before the body has started sending)
<discocaml>
<idontwantausernamefeckoff> cohttp has a conn_closed which only seems to call when the request has fully completed
<discocaml>
<idontwantausernamefeckoff> i used cohttp because httpaf looks confusing, but i guess all roads lead to confusing
<discocaml>
<idontwantausernamefeckoff> theres an issue related to this that has been open since 2015
greaser|q has quit [Changing host]
greaser|q has joined #ocaml
greaser|q is now known as GreaseMonkey
waleee has joined #ocaml
pippijn has quit [Ping timeout: 252 seconds]
pippijn has joined #ocaml
rgrinberg has joined #ocaml
<companion_cube>
dh`: only if your end of the socket is aware of that, though?
<companion_cube>
If the other side didn't shut it down properly you won't know
<discocaml>
<idontwantausernamefeckoff> netcat can tell when i ctrl+c curl 😉
<companion_cube>
I'm sure curl does close the socket properly, yes
<companion_cube>
But also, I'm pretty sure netcat is trying to read and that's what fails, not a "socket closed" event
<discocaml>
<idontwantausernamefeckoff> true
<discocaml>
<idontwantausernamefeckoff> i mean, i've been able to reliably get end of file in eio
<discocaml>
<idontwantausernamefeckoff> cohttp seems to have trouble even handling writing a chunk to a closed socket without stopping the worl
<companion_cube>
Hmm
<companion_cube>
Got to get Wireshark or strace out
<discocaml>
<idontwantausernamefeckoff> i've just been using handwritten responses and sleep to simulate what i want writing to the socket manually
<discocaml>
<idontwantausernamefeckoff> i can poll the connection and react to any end of file while i'm doing work (or simulated work) in another fiber, then use a promise or cancellation to stop that work early
<discocaml>
<idontwantausernamefeckoff> just cant hook that up to a http server
<companion_cube>
I'm debugging an issue with that in my own httpd, so... Yeah :/
<companion_cube>
Tricky
<discocaml>
<idontwantausernamefeckoff> i reckon httpaf (anmonteiro's fork) is probably the way to go for me. design seems like it allows me enough control over connection lifecycles to do what i want
<discocaml>
<functionalprogramming> If i'm on macOS M1 (aarch64), how can I cross-compile for x86-64?
rgrinberg has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
omegatron has quit [Quit: Power is a curious thing. It can be contained, hidden, locked away, and yet it always breaks free.]
rgrinberg has joined #ocaml
<dh`>
companion_cube: to some extent yes, if it's an AF_INET socket and the other end just evaporates it will eventually time out but tha takes hours
<dh`>
and it doesn't prevent getting write errors because the close condition can always occur just as you call write
<dh`>
(so any nontrivial network application should in general ignore SIGPIPE)
<dh`>
also, having tangled with lwt some I would say: rather than try to use any of these libraries that try to pretend to have threads, you're better off using ocaml 5 and real threads
<dh`>
there are many ways to shoot yourself in the foot with real threads, but on the other hand the semantics of everything is well defined and well understood
<discocaml>
<idontwantausernamefeckoff> i still very much like having green threads and concurrency primitives, but i’m slowly getting less sure about all your io being wrapped into those same primitives
<companion_cube>
dh`: what are you advocating? Directly use epoll?
jabuxas has joined #ocaml
Anarchos has joined #ocaml
<discocaml>
<idontwantausernamefeckoff> new thread for every connection
<discocaml>
<idontwantausernamefeckoff> reinvent performance issues solved two decades ago
<companion_cube>
It's less of a performance issue now
<discocaml>
<idontwantausernamefeckoff> how so?
<discocaml>
<idontwantausernamefeckoff> if you start using epoll and the like eventually you’ve just written your own event loop
<discocaml>
<idontwantausernamefeckoff> or it’s just not that easy to overwhelm a server anymore
jabuxas has quit [Ping timeout: 255 seconds]
<companion_cube>
well threads are fairly fast these days
<companion_cube>
I mean, if you really want high perf, you probably want epoll-per-core (or io_uring per core)
<companion_cube>
but you can go reasonably far with threads
Anarchos has quit [Ping timeout: 264 seconds]
jabuxas has joined #ocaml
zanetti has quit [Quit: zanetti]
zanetti has joined #ocaml
Anarchos has joined #ocaml
rgrinberg has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
masterbuilder_ has quit [Ping timeout: 240 seconds]
mange has joined #ocaml
Anarchos has quit [Quit: Vision[]: i've been blurred!]
Serpent7776 has quit [Ping timeout: 260 seconds]
bartholin has quit [Quit: Leaving]
a51 has joined #ocaml
jabuxas has quit [Ping timeout: 255 seconds]
dnh has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]