<Fardale>
It seems to be async some Async stuff, so you have te run the promise somehow. I don't really know Async, but if it work like Lwt, then you will need to bind it
<mbuf>
Fardale, yes, I need to run the promise to get the result
<Fardale>
If you know that, what is your question ? How to run a promise ?
malc_ has joined #ocaml
<mbuf>
Fardale, yes, the latter; I am able to run contents() in utop, just need to know how to do it in a let () construct
<mbuf>
I haven't used Lwt or Async yet
<Fardale>
you need to transforme your whole program as a promise. So in pratice that means you will do something like: let main = (* your program *) and you will do Command.run main
<d_bot>
<kanishka> I am still learning this also, but their is a note about starting a scheduler in RWO async chapter
<Fardale>
In your program you will need to use bind, in Async you have the infix operator >>= if your function return a promise or >>| if not
malc_ has left #ocaml ["ERC (IRC client for Emacs 28.0.50)"]
reynir has joined #ocaml
reynir has quit [Remote host closed the connection]
reynir has joined #ocaml
jbrown has quit [Ping timeout: 272 seconds]
<Leonidas>
is the material of any of the ocaml MOOCs publically available?
jbrown has joined #ocaml
<Leonidas>
mbuf: actually I think it is more customary to use ppx_let instead of noisy binds everywhere
<Leonidas>
`(>>=*)` is essentially (>>=) when using Deferred.Or_error.Let_syntax.
<Leonidas>
let%bind I mean
<Leonidas>
Then you also avoid the long names and just use `return`
<Fardale>
In Lwt code, I more often see >>= that let%lwt
<Fardale>
I don't for async
<theblatte>
why use let%bind instead of let*? no ppx needed for the latter
<Leonidas>
In Async it is more convenient because there is Deferred.Result.t and Deferred.Or_error.t etc.
<theblatte>
ok thanks
<Leonidas>
theblatte: there is no match*, which makes this a no-go for me
<Leonidas>
half of my code would be changed into let* don'tcare = … in match don'tcare with …
<mbuf>
Leonidas, I see
<Leonidas>
Also I believe ppx_let allows sth like let%bind.Deferred.Result which is to me somewhat more readable than a let*=>< or however one would name a bind on a Deferred.Result.t
<Leonidas>
but yes, I greatly appreciate that finally some do syntax is being mainlined
<Leonidas>
give me match%bind and deriving and I'm all set :D
bartholin has quit [Quit: Leaving]
<theblatte>
makes sense ^^
<mbuf>
Leonidas, could you pastebin on how run () looks after the above change, and its invocation with an example?
<mbuf>
Leonidas, I am new to Async and Core
<theblatte>
maybe they should be more characters allowed after * too, eg let*deferred_result
andreas303 has quit [Remote host closed the connection]
andreas303 has joined #ocaml
<Leonidas>
mbuf: yeah, will take a while since I need to create a new local switch
FreeBirdLjj has quit [Remote host closed the connection]
FreeBirdLjj has joined #ocaml
<mbuf>
Leonidas, any specific libraries to be included when building as a dune project? I get "Error: dune__exe__C-orig corresponds to an invalid module name"
<mbuf>
Sorry, that was the wrong file
<mbuf>
Now, I get Error: Uninterpreted extension 'bind'.
<mbuf>
. Probably, need to include some ppx_let
<mbuf>
Never mind, added (preprocess (pps ppx_let)) to the dune file.
<mbuf>
Leonidas, It builds fine. Where do I print caml_symbols? Thanks!
<Leonidas>
mbuf: you can print it wherever it is in scope
<Leonidas>
mbuf: I don't quite understand your question tbh
<Leonidas>
(fwiw you might want to use Async.Writer.stdout for writing to avoid issues with ordering)
vicfred has joined #ocaml
<mbuf>
Leonidas, I was referring to return { caml_symbols }. I need to get the output of the same
<Leonidas>
mbuf: I'd do that in `main`
<defolos>
noob question: how can I tell dune to link `Str` into my application/library?
<Leonidas>
that's also cool since you need to convert from an 'a Or_error.Deferred.t to an unit Or_error.Deferred.t
<defolos>
…
<defolos>
I'm an idiot: `(libraries str)` does the trick
<defolos>
far too obvious
<mbuf>
Leonidas, Sorry, where? let%bind _ = Async.Writer.stdout run ~binary ~working_dir () in gives "Error: This expression has type Async.Writer.t lazy_t. This is not a function. It cannot be applied."
<Leonidas>
mbuf: Async.Writer.stdout is not a function, Async.Writer.write is
<Leonidas>
val write : ?pos:int ‑> ?len:int ‑> t ‑> string ‑> unit
<Leonidas>
`let%bind r = run ~binary ~working_dir () in Async.Writer.write (force Async.Writer.stdout) r; return ()` or so
craigfe has joined #ocaml
nkly has joined #ocaml
<mbuf>
Leonidas, I see. I get "Error: This expression has type t but an expression was expected of type string", and it points at 'r' in "r; return()"
<Leonidas>
mbuf: ah, you need to convert your `t` to a string to print it.
<mbuf>
Leonidas, you mean 'r'?
<mbuf>
Leonidas, ohh! you meant the type t, which is a float
<Leonidas>
mbuf: type t is not a float, it is a record that contains a float
<Leonidas>
type t is of type t to be exact :D
<mbuf>
I tried (Printf.sprintf "%.2f" r), and it throws a syntax error: String literal not terminated
<flux1>
it's not probably that line that is causing the issue..
<Leonidas>
mbuf: also `r` is of type `t`, it can't be printed using %f, since that requires floats.
<mbuf>
Leonidas, I see
<Leonidas>
Why are you wrapping caml_symbols in a record even?
<mbuf>
Leonidas, not my code :)
FreeBirdLjj has quit [Ping timeout: 240 seconds]
<mbuf>
Leonidas, works; great! can I give attribution to your changes to this code?
osa1 has quit [Ping timeout: 240 seconds]
<Leonidas>
if you want to…
<Leonidas>
I'd do a whole lot of other changes though :p
<mbuf>
Leonidas, will do; sure, I will ping you after I read a bit more on OCaml and need to do code reviews :)
<mbuf>
Leonidas, thanks again for your time and patience; appreciate it!
<Leonidas>
haha
FreeBirdLjj has joined #ocaml
<dash>
i see the reasonml people have decided to confuse everyone again
<companion_cube>
it's the bucklescripts people it seems
mbuf has quit [Quit: Leaving]
artart78 has joined #ocaml
<flux1>
I guess it's not all bad to provide a coherent site with consistent naming, if you want to compete with TypeScript..
<flux1>
haven't looked at the new syntax, though :)
FreeBirdLjj has quit [Remote host closed the connection]
Haudegen has quit [Ping timeout: 240 seconds]
chripell has quit [Quit: ZNC 1.8.1+deb1 - https://znc.in]
reynir has quit [Ping timeout: 260 seconds]
reynir has joined #ocaml
chripell has joined #ocaml
waleee-cl has joined #ocaml
vicfred has quit [Quit: Leaving]
tane has joined #ocaml
ggole has quit [Quit: Leaving]
gahr_ has joined #ocaml
cqc_ has joined #ocaml
vicfred has joined #ocaml
farn__ has joined #ocaml
khady[m] has quit [*.net *.split]
camlriot42 has quit [*.net *.split]
labor[m] has quit [*.net *.split]
leah2 has quit [*.net *.split]
gahr has quit [*.net *.split]
cqc has quit [*.net *.split]
farn_ has quit [*.net *.split]
cqc_ is now known as cqc
Manis[m] has quit [Remote host closed the connection]
BitPuffin has quit [Read error: Connection reset by peer]
flux1 has quit [Read error: Connection reset by peer]
dash has quit [Read error: Connection reset by peer]
smondet[m] has quit [Remote host closed the connection]
lnxw37d4 has quit [Remote host closed the connection]
aecepoglu[m] has quit [Read error: Connection reset by peer]
aspiwack[m] has quit [Remote host closed the connection]
swapnilraj[m] has quit [Remote host closed the connection]
defolos has quit [Read error: Connection reset by peer]
peddie has quit [Read error: Connection reset by peer]
gaussian[m] has quit [Remote host closed the connection]
jimt[m] has quit [Write error: Connection reset by peer]
rpcope has quit [Ping timeout: 246 seconds]
leah2 has joined #ocaml
smondet[m] has joined #ocaml
reynir has quit [Quit: WeeChat 2.3]
bartholin has joined #ocaml
rpcope has joined #ocaml
reynir has joined #ocaml
khady[m] has joined #ocaml
BitPuffin has joined #ocaml
peddie has joined #ocaml
labor[m] has joined #ocaml
jimt[m] has joined #ocaml
lnxw37d4 has joined #ocaml
dash has joined #ocaml
flux1 has joined #ocaml
camlriot42 has joined #ocaml
aspiwack[m] has joined #ocaml
defolos has joined #ocaml
aecepoglu[m] has joined #ocaml
gaussian[m] has joined #ocaml
Manis[m] has joined #ocaml
swapnilraj[m] has joined #ocaml
osa1 has joined #ocaml
dhil has joined #ocaml
eureton has joined #ocaml
nkly has quit [Ping timeout: 265 seconds]
Jesin has joined #ocaml
eureton has quit [Read error: Connection reset by peer]
eureton has joined #ocaml
eureton has quit [Ping timeout: 260 seconds]
osa1 has quit [Ping timeout: 246 seconds]
nullcone has joined #ocaml
vicfred has quit [Quit: Leaving]
<Leonidas>
companion_cube: but is it?
<Leonidas>
I am thoroughly confused how reasonml is related with bucklescript. it seems: not at all anymore.
<companion_cube>
I don't know if the news was done in concertation, but it does seem to me it's all done by bucklescripts people who decided they also wanted their own, even more JS-y, syntax
<companion_cube>
(so people from bloomberg, not FB)
<d_bot>
<Anurag> the bucklescript devs work at facebook now i believe
<companion_cube>
oh interesting.
<companion_cube>
TIL.
jmorris_ has joined #ocaml
jmorris_ has quit [Remote host closed the connection]