NSA_Spy has quit [Remote host closed the connection]
NSA_Spy has joined #ocaml
delucks has left #ocaml [#ocaml]
jaar has quit [Ping timeout: 272 seconds]
mfp has quit [Ping timeout: 246 seconds]
vicfred_ has joined #ocaml
vicfred has quit [Ping timeout: 264 seconds]
RalfJ has quit [Ping timeout: 264 seconds]
RalfJ has joined #ocaml
dhil_ has quit [Ping timeout: 240 seconds]
sagax has quit [Excess Flood]
remexre has quit [Ping timeout: 246 seconds]
remexre has joined #ocaml
vicfred_ has quit [Quit: Leaving]
zmt00 has joined #ocaml
mbuf has joined #ocaml
narimiran has joined #ocaml
vicfred has joined #ocaml
vicfred has quit [Quit: Leaving]
zmt00 has quit [Ping timeout: 264 seconds]
zmt00 has joined #ocaml
zmt00 has quit [Remote host closed the connection]
zmt00 has joined #ocaml
NSA_Spy has quit [Ping timeout: 260 seconds]
sagax has joined #ocaml
coetry has joined #ocaml
<coetry>
In Emacs, I invoked `M-x merlin-use` and provided my module name (Core) and after doing so, my Unbound module errors went away, but the return immediately after saving my file. Has anyone else ran into a similar issue?
zmt00 has quit [Read error: Connection reset by peer]
osa1 has joined #ocaml
amiloradovsky has joined #ocaml
snowpand_ has joined #ocaml
snowpanda has quit [Ping timeout: 260 seconds]
snowpand_ has quit [Quit: Leaving...]
nkly_ has joined #ocaml
coetry has quit [Ping timeout: 246 seconds]
<def>
coetry: if you do merlin-error-check after merlin-use (without saving) are the errors still there?
coetry has joined #ocaml
ggole has joined #ocaml
coetry has quit [Quit: Lost terminal]
sagax has quit [Remote host closed the connection]
nicoo has quit [Remote host closed the connection]
nicoo has joined #ocaml
amiloradovsky has quit [Ping timeout: 256 seconds]
Guest86335 has quit [Ping timeout: 260 seconds]
jaar has joined #ocaml
Guest86335 has joined #ocaml
malc_ has joined #ocaml
nkly_ has quit [Ping timeout: 244 seconds]
mfp has joined #ocaml
TC01_ has joined #ocaml
TC01 has quit [Ping timeout: 256 seconds]
Guest86335 has quit [Ping timeout: 260 seconds]
nkly_ has joined #ocaml
sagax has joined #ocaml
Guest86335 has joined #ocaml
dhil_ has joined #ocaml
jbrown has joined #ocaml
FreeBirdLjj has joined #ocaml
FreeBirdLjj has quit [Ping timeout: 246 seconds]
nkly_ has quit [Ping timeout: 272 seconds]
nkly_ has joined #ocaml
nicoo has quit [Read error: Connection reset by peer]
<jco>
we have a string Lwt.t variable that we'd like to evaluate
<jco>
to get a string
<Fardale>
jco: you can evaluate a promise in Lwt only once in the whole program using Lwt_main.run. If you want to pass the string to the next function you need to use Lwt.bind
vicfred has joined #ocaml
<flux1>
in other words, you probably need to structure your code so that it also is an Lwt promise
<jco>
ah ok, i see :)
malc_ has quit [Ping timeout: 256 seconds]
<jco>
so no way to force the evaluation of a promise at a given moment
<jco>
thanks!
muskan has joined #ocaml
<Fardale>
jco: Lwt.bind wait for the evaluation of the promise before passing the result to the next function. It forces the evaluation of the promise
nkly_ has quit [Ping timeout: 260 seconds]
<jco>
yeah, i wasn't thinking right, i wanted to evaluate to an actual value in order to avoid chaining promises
nkly_ has joined #ocaml
<Fardale>
Oh I see, you cannot do that, but you can use the infix operator (>|=) which takes a function that does not return a promise
<Leonidas>
but eventually you'll have to chain promises
<jco>
this is map (>|=)?
<Leonidas>
since promises can't really be "deleted"
<Leonidas>
yes, that's the Lwt name for it
<jco>
okay :)
<Leonidas>
Async calls it >>|
<jco>
Leonidas: they can't be deleted, but maybe return an exception if the promises couldn't be evaluated?
<jco>
or maybe misunderstood something
<Fardale>
"val (>|=) : 'a t -> ('a -> 'b) -> 'b t" where bind is "val bind : 'a t -> ('a -> 'b t) -> 'b t"
<Leonidas>
No, I mean, a correct program has to be a chain of promises.
<Leonidas>
If you don't do it, your program is incorrect or might just work accidentally
<jco>
ok that's by design then!
<Leonidas>
yes, that's pretty much how the IO monad works
<Fardale>
Deleting a promise is kind of an undefine behavior, it can work but it can break in the futur
nkly_ has quit [Ping timeout: 256 seconds]
<jco>
good, thanks for clarifying! By calling asynchronous functions in functions I have to change a bit the api hence the question
<Leonidas>
in the case of Lwt deleting (or rather ignoring) a promise sometimes works since they are evaluated eagerly, so sometimes programs appear to work, but then something is refactored and it stops working at a different place
<companion_cube>
the solution is to not have `await` at all if you can live without the system's stack
<olle>
cool, I have his book :)
<companion_cube>
which one?
<olle>
game programming patterns
<companion_cube>
ah
<companion_cube>
I read parts of "crafting interpreters" and liked it
<olle>
alright
<olle>
yeah, i liked the one I read, although obviously i'm not writing games
<olle>
better people than me has tried to push async/await concepts using PHP's yield and generators (also in JS)
<companion_cube>
well in JS they had to add async/await
<companion_cube>
but it's just not as nice as having fibers baked in
<olle>
hm
malc_ has left #ocaml ["ERC (IRC client for Emacs 28.0.50)"]
<olle>
my theory was that MOST side-effects do actually not use any result
<olle>
like, if 50+% of all side-effects in a program does not care about the result, they might as well be async/non-blocking
<olle>
update db, zip down a file, spit out some message.
<companion_cube>
that's assuming they can work concurrently
<companion_cube>
imho that should always be explicit
<olle>
sure
<companion_cube>
otherwise race conditions will eat you
<olle>
oh right
<companion_cube>
that's the one thing Go did right, imho
<olle>
FIFO is not enough if one task is slower than another
<olle>
ok
<companion_cube>
you want concurrency, you got to spawn a fiber
<companion_cube>
(but that's it)
<companion_cube>
(no need to do `await` on each syscall)
Guest86335 has quit [Ping timeout: 246 seconds]
<olle>
companion_cube: isn't that already what ocaml can do?
<companion_cube>
not currently, no
<companion_cube>
hopefully with multicore+effects it will
<olle>
are we mixing up concurrency with parallelism?
<companion_cube>
(effects can be used to yield to the scheduler before any IO)
<companion_cube>
no
<companion_cube>
but effects are on the multicore branch
<olle>
I thought OCaml could to non-blocking IO with threads?
<companion_cube>
no, threads use blocking IOs
<companion_cube>
but, per thread, of course
<olle>
yeah :)
<olle>
so one IO per thread and you have non-blocking, kind of?
<companion_cube>
hmmmm, not sure what you mean
<companion_cube>
OCaml IOs are blocking (by default)
<companion_cube>
threads just allow you to block only one thread on some IO, while other threads do their thing
<olle>
companion_cube: I mean, 10 SQL queries in 10 threads, then they run in parallel?
<companion_cube>
sure
<olle>
right
<companion_cube>
that's what threads do
<companion_cube>
the only problem is that threads are heavier than fibers, so it's hard to spawn tens (or hundreds) of thousands of then
<companion_cube>
them
<olle>
A benefit not talked about in your linked article is that `yield` can also remove all side-effects from your logic, if you also use a side-effect factory class.
<olle>
system threads? yes.
rak has quit [Ping timeout: 258 seconds]
<olle>
ironically, the readability of go code is nil
Guest86335 has joined #ocaml
<companion_cube>
heh, could be worse
<olle>
yeah, i was looking at some weird code piece
<olle>
it's weird for me that "command pattern side effects" doesn't show more search results :d
<olle>
I want everyone to use this forever
<olle>
ok, so if go has "go (do_whatever)", I'd like to have `yield async($io->db->query('UPDATE bla bla...'))`
<olle>
the PHP lib I'm looking at always seem to wait at `yield`, but you can do `yield [list of commands]` to run stuff concurrently (but it still waits until all are done).
raver has quit [Quit: Gateway shutdown]
raver has joined #ocaml
Haudegen has joined #ocaml
olle has quit [Ping timeout: 256 seconds]
olle has joined #ocaml
<def>
isn't non-blocking io what lwt offers by default ?
<companion_cube>
sure
<companion_cube>
lwt is not OCaml's default though :)
<olle>
right
<olle>
leight-weight threads, after all :D
amiloradovsky has joined #ocaml
narimiran has quit [Ping timeout: 264 seconds]
dhil_ has quit [Ping timeout: 256 seconds]
ggole has quit [Quit: Leaving]
Jesin has quit [Quit: Leaving]
Jesin has joined #ocaml
dhil_ has joined #ocaml
Tekk_ has quit [Remote host closed the connection]
Tekk_ has joined #ocaml
NSA_Spy has joined #ocaml
olle_ has joined #ocaml
nullcone has quit [Quit: Connection closed for inactivity]
olle has quit [Remote host closed the connection]
olle_ has quit [Remote host closed the connection]
Haudegen has quit [Ping timeout: 264 seconds]
<Leonidas>
lol, benchpress
<companion_cube>
yes? 🙃
amiloradovsky has quit [Ping timeout: 260 seconds]
jbrown has quit [Ping timeout: 244 seconds]
Tekk_ has quit [Remote host closed the connection]