companion_cube changed the topic of #ocaml to: Discussion about the OCaml programming language | http://www.ocaml.org | OCaml 4.14.0 released: https://ocaml.org/releases/4.14.0.html | Try OCaml in your browser: https://try.ocamlpro.com | Public channel logs at https://libera.irclog.whitequark.org/ocaml/
hyphen has quit [Ping timeout: 276 seconds]
hyphen has joined #ocaml
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
vicfred has quit [Quit: Leaving]
wingsorc has quit [Quit: Leaving]
DNH has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
motherfsck has quit [Ping timeout: 260 seconds]
dh` has quit [Remote host closed the connection]
DNH has joined #ocaml
azimut has joined #ocaml
azimut has quit [Remote host closed the connection]
mjs22 has joined #ocaml
azimut has joined #ocaml
DNH has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
mjs22 has quit [Remote host closed the connection]
Sankalp has quit [Ping timeout: 240 seconds]
mjs22 has joined #ocaml
Sankalp has joined #ocaml
mjs22 has quit [Ping timeout: 260 seconds]
<greenbagels> if im defining a binding with an option type
<greenbagels> er if i'm defining a reference to a variable of type "int option" but i want it to initially have value "None", does the compiler just deduce its type from its use later in my code?
<greenbagels> like say "let foo = ref None" and then later i do something like "foo := 2"... how is the type of foo resolved?
rgrinberg has joined #ocaml
waleee has quit [Ping timeout: 248 seconds]
terrorjack has quit [Quit: The Lounge - https://thelounge.chat]
terrorjack has joined #ocaml
bobo has quit [Quit: Konversation terminated!]
spip has joined #ocaml
zebrag has quit [Read error: Connection reset by peer]
<d_bot> <geoff> it would have to be `foo := Some 2`, but yea it'd be inferred
spip has quit [Client Quit]
<companion_cube> inference is done on a whole module level
spip has joined #ocaml
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
mjs22 has joined #ocaml
mjs22 has quit [Ping timeout: 244 seconds]
szkl has joined #ocaml
rgrinberg has joined #ocaml
rgrinberg has quit [Ping timeout: 244 seconds]
spip has quit [Quit: Konversation terminated!]
Haudegen has joined #ocaml
spip has joined #ocaml
mro has joined #ocaml
Serpent7776 has joined #ocaml
mro has quit [Remote host closed the connection]
mro has joined #ocaml
emp_ has quit [Quit: ZNC 1.8.2 - https://znc.in]
szkl has quit [Quit: Connection closed for inactivity]
emp has joined #ocaml
gravicappa has joined #ocaml
<greenbagels> ok cool, thanks for the tips
mro has quit [Remote host closed the connection]
mro has joined #ocaml
<d_bot> <0xSterben> bots are talking like a person?
<d_bot> <0xSterben> wtf is going on
<d_bot> <eiya.ml> theyre from the IRC bridge
<d_bot> <0xSterben> i see
olle has joined #ocaml
mro has quit [Remote host closed the connection]
mro has joined #ocaml
bartholin has joined #ocaml
DNH has joined #ocaml
mjacob has quit [Read error: Connection reset by peer]
DNH has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
mjacob has joined #ocaml
mro has quit [Remote host closed the connection]
mro has joined #ocaml
DNH has joined #ocaml
np has quit [Read error: Connection reset by peer]
xgqt has quit [Ping timeout: 272 seconds]
xgqt has joined #ocaml
nerdypepper has joined #ocaml
mro has quit [Remote host closed the connection]
bobo has joined #ocaml
spip has quit [Read error: Connection reset by peer]
quernd7 has joined #ocaml
quernd has quit [Ping timeout: 240 seconds]
quernd7 is now known as quernd
mima has quit [Ping timeout: 272 seconds]
Haudegen has quit [Quit: Bin weg.]
mro has joined #ocaml
mro has quit [Ping timeout: 246 seconds]
bobo has quit [Quit: Konversation terminated!]
mro has joined #ocaml
Haudegen has joined #ocaml
mro has quit [Remote host closed the connection]
mjs22 has joined #ocaml
mima has joined #ocaml
mjs22 has quit [Ping timeout: 240 seconds]
mro has joined #ocaml
zebrag has joined #ocaml
mro has quit [Ping timeout: 246 seconds]
mro has joined #ocaml
mro has quit [Remote host closed the connection]
mro has joined #ocaml
mro has quit [Ping timeout: 244 seconds]
gereedy has joined #ocaml
waleee has joined #ocaml
Nahra has joined #ocaml
<d_bot> <Patate> i split my menhir .mly file in two files, And it brought some nice
<d_bot> <Patate> "Warning: 75 end-of-stream conflicts were arbitrarily resolved."
<d_bot> <Patate> My first file uses the start rule of the second one, but the second one seems to not know where to stop...
<d_bot> <Patate> If I simply inject the second file into the first, there is no warning...
<d_bot> <Patate> Doesn't menhir just inject files into one big file internally?
Tuplanolla has joined #ocaml
<d_bot> <Patate> It seems that adding ;EOF at the end of the start rule makes warnings disappear...
pfharlock has quit [Remote host closed the connection]
pfharlock has joined #ocaml
hyphen has quit [Ping timeout: 260 seconds]
hyphen has joined #ocaml
mro has joined #ocaml
mro has quit [Remote host closed the connection]
mro has joined #ocaml
rgrinberg has joined #ocaml
mima has quit [Ping timeout: 248 seconds]
motherfsck has joined #ocaml
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
hyphen has quit [Ping timeout: 246 seconds]
gereedy has quit [Quit: gereedy]
waleee has quit [Ping timeout: 240 seconds]
aspe has joined #ocaml
hyphen has joined #ocaml
Everything has joined #ocaml
szkl has joined #ocaml
hyphen has quit [Ping timeout: 272 seconds]
spip has joined #ocaml
hyphen has joined #ocaml
hyphen has quit [Ping timeout: 240 seconds]
Haudegen has quit [Quit: Bin weg.]
hyphen has joined #ocaml
Nahra has quit [Remote host closed the connection]
rgrinberg has joined #ocaml
rgrinberg has quit [Client Quit]
olle has quit [Ping timeout: 244 seconds]
hyphen has quit [Ping timeout: 276 seconds]
hyphen has joined #ocaml
vicfred has joined #ocaml
mima has joined #ocaml
hyphen has quit [Ping timeout: 260 seconds]
hyphen has joined #ocaml
hyphen has quit [Ping timeout: 246 seconds]
<greenbagels> i could join from discord too... and then talk to myself thru the bot...
hyphen has joined #ocaml
mro has quit [Remote host closed the connection]
rgrinberg has joined #ocaml
Haudegen has joined #ocaml
bartholin has quit [Quit: Leaving]
mro has joined #ocaml
mro has quit [Ping timeout: 272 seconds]
dh` has joined #ocaml
azimut has quit [Ping timeout: 240 seconds]
mro has joined #ocaml
tiferrei has quit [Ping timeout: 240 seconds]
tiferrei has joined #ocaml
motherfsck has quit [Ping timeout: 244 seconds]
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
mro has quit [Ping timeout: 272 seconds]
motherfsck has joined #ocaml
adanwan has quit [Remote host closed the connection]
adanwan has joined #ocaml
mjs22 has joined #ocaml
mjs22 has quit [Ping timeout: 260 seconds]
mjs22 has joined #ocaml
zebrag has quit [Read error: Connection reset by peer]
mro has joined #ocaml
rgrinberg has joined #ocaml
mro has quit [Remote host closed the connection]
mro has joined #ocaml
DNH has quit [Ping timeout: 260 seconds]
mro_ has joined #ocaml
emad has joined #ocaml
mro has quit [Ping timeout: 260 seconds]
<d_bot> <cemerick> I'm staring at a situation where it looks like changing the order of mandatory labelled arguments to a function changes whether the code using it compiles successfully or not. That should be impossible, correct?
<d_bot> <NULL> You mean one raises a type error and the other doesn't ?
<d_bot> <cemerick> right
<d_bot> <cemerick> I have a function `let foo ~id ~seq ... = ...`, and am just swapping `~id` and `~seq`
<d_bot> <cemerick> the error is at a call site, and seems to indicate that one of the arguments isn't being applied, yielding a partial function instead of the type of its return
<d_bot> <cemerick> Unfortunately, it's a pretty gnarly signature, a _long_ way from anything I'd consider minimal and worth sharing
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<d_bot> <glennsl> There are some shortcomings with type inference if you're passing the function around as a first-class value, I believe.
<d_bot> <ec> fuhhfhghuf struggling with partial-application of optional arguments over here, too, @cemerick
<d_bot> <ec> also, been a moment, how are you?
<d_bot> <ec> i suspect this is just intractable, but if anyone wants to correct me — https://gist.github.com/ELLIOTTCABLE/8cf51f2af70dca62fcdcf7bc9fef0ea4
<d_bot> <ec> can no longer re-order arguments after `with_z_instead` has been applied to `smth` — if they're non-optional, it works; if they're optional, but in order, it works; but if they're both optional, reordered, and post-partial-application, I get type errors. I guess I'm not that surprised, but …
<d_bot> <octachron> Swapping arguments in a definition does change the type of the function, but that should not affect a function application with explicit labels.
<d_bot> <ec> `This expression has type ?m:int -> ?n:int -> ?o:int -> p:int -> int, but an expression was expected of type ?m:int -> ?n:int -> p:'a -> 'b; Type ?o:int -> p:int -> int is not compatible with type p:'a -> 'b.` In one line for IRC.
<d_bot> <octachron> @ec first `smth` does not really have optional arguments.
<d_bot> <ec> ooo, is that all? lemme try consuming the options directly …
<d_bot> <octachron> `(with_z_instead ~z:4 smth) (* no ~o *) ~p:123` (with the extra parenthesis) works
<d_bot> <ec> that's … fascinating. I would think that would be a purely transparent change, isn't function-application left-associative??
<d_bot> <ec> huh, well, `ocamlformat` retains the parens, so I suppose that'll do
<d_bot> <octachron> Not with labels `f ~x ~y` is not the same as `(f ~x) ~y` (the first one has more context). Here, the issus is that the typechecker is extra-cautious with labels that it has inferred.
<d_bot> <cemerick> that's interesting; I am passing `foo` to another function that's expecting one with those labelled args
<d_bot> <cemerick> do you happen to know where this is specified/discussed?
<d_bot> <cemerick> gah, meant that to be @glennsl , sorry
<d_bot> <cemerick> I'm good, good, should pop into your server for realz someday 🙂
<d_bot> <ec> Can you add the usual `unit` terminator?
<d_bot> <octachron> With `with_z_instead ~z:4 smth ~p:123` it tries to type the whole application and infers that the type of `smth` should be a `~p:int -> _` and that does not match the label order of `smth` . Whereas with `(with_z_instead ~z:4 smth)` the typechecker first applies `with_z` and obtains a function with a known label order and thus consider that it is safe to commute `~p` and `?o`.
<d_bot> <cemerick> Shouldn't be necessary AFAIU, there's no optional labelled args; but no, the function I'm passing _my_ function into has the expectations it has
<d_bot> <octachron> @cemerick , implicit label commutation a convenience at the level of function application, it does not extend to higher-order functions with labelled function arguments.
<d_bot> <cemerick> oh, thanks, I was scanning through ch. 9 😵‍💫
<d_bot> <cemerick> got it, many thanks
<d_bot> <cemerick> it's tough with e.g. ppx-generated functions where the ordering isn't manifestly obvious
mjs22 has quit [Remote host closed the connection]
mjs22 has joined #ocaml
mjs22 has quit [Ping timeout: 260 seconds]
<d_bot> <ec> hm that's … curious. I know you said you can't make a representative example from your actual codebase, but can you throw out an example of how this would bite you with a ppx? Feels like a learning opportunity, lol.
<d_bot> <cemerick> Yeah, that shouldn't be hard; I'll give it a try later tonight
mjs22 has joined #ocaml
Haudegen has quit [Quit: No Ping reply in 180 seconds.]
Haudegen has joined #ocaml
mro_ has quit [Quit: Leaving...]
Everything has quit [Quit: leaving]
pfharlock has quit [Remote host closed the connection]
pfharlock has joined #ocaml
<greenbagels> man ocaml's type system is so surreal to me, coming from more C-like languages
<greenbagels> so... mysterious
gravicappa has quit [Ping timeout: 260 seconds]
aspe has quit [Quit: aspe]
aspe has joined #ocaml
aspe has quit [Read error: Connection reset by peer]
emad has quit [Remote host closed the connection]
aspe has joined #ocaml
aspe has quit [Client Quit]
sparogy has quit [Remote host closed the connection]
szkl has quit [Quit: Connection closed for inactivity]
sparogy has joined #ocaml
zebrag has joined #ocaml
pfharlock has quit [Remote host closed the connection]
pfharlock has joined #ocaml
wingsorc has joined #ocaml
<greenbagels> whats the appropriate way to "detach" a recursive async function call from the main "thread"
<greenbagels> like say function bar is some kind of recursive function that busy-waits using Lwt_unix.sleep, and foo calls bar; but I don't want bar's sleep to block foo from continuing its execution
Serpent7776 has quit [Quit: leaving]
waleee has joined #ocaml
mjs22 has quit [Remote host closed the connection]
mjs22 has joined #ocaml
<d_bot> <Ambika E.> Are you using lwt?
<greenbagels> yeah
mjs22 has quit [Ping timeout: 260 seconds]
<greenbagels> let me share some code so its a bit more clear
<d_bot> <Ambika E.> You can use Lwt.async or you can just do something like
<d_bot> <Ambika E.> ```ocaml
<d_bot> <Ambika E.> let _run_in_bg = bar () in
<d_bot> <Ambika E.> (* Do other things *)
<d_bot> <Ambika E.> ```
<d_bot> <Ambika E.> ^ in this case, the function bar will begin running in the background and nothing that comes after will have to wait for it to "complete"
mjs22 has joined #ocaml
<thizanne> you probably also want Lwt_preemptive.detach if bar isn't already written with Lwt
<greenbagels> let me provide the full context maybe; disclaimer: i am notoriously bad at understanding asynchronous programming (my background is very much a C threading one, heh)
<greenbagels> https://gist.github.com/greenbagels/0ad0ea1db2c2fde829c8f870218403cb which means this probably will look like nonsense
<greenbagels> but its basically just for handling discord heartbeats using their websockets api; im trying to see if i can asynchronously have a function on a timer send keepalives without blocking the overall lwt thread
<greenbagels> i was able to previously get it working using <?> adapted from the ocaml-websockets wscat.ml example, but i didnt really understand why it was working so i tried to rewrite my own from scratch
adanwan has quit [Remote host closed the connection]
adanwan has joined #ocaml
mjs22 has quit [Remote host closed the connection]
mjs22 has joined #ocaml
pfharlock has quit [Remote host closed the connection]
pfharlock has joined #ocaml
mjs22 has quit [Ping timeout: 244 seconds]
mjs22 has joined #ocaml
rgrinberg has joined #ocaml
bobo has joined #ocaml
spip has quit [Ping timeout: 272 seconds]
<greenbagels> oh i am reading https://ocsigen.org/tuto/latest/manual/lwt and i think i may see the issue now
<greenbagels> ah, maybe not
pfharlock has quit [Remote host closed the connection]
pfharlock has joined #ocaml
pfharlock has quit [Remote host closed the connection]
pfharlock has joined #ocaml
<greenbagels> okay yeah i do understand now; by using "let%lwt () = infinite_loop_function" i am waiting for the promise to resolve, which never happens
<greenbagels> so now i understand why Ambika's suggestion would work out
mjs22 has quit [Remote host closed the connection]
mjs22 has joined #ocaml
hyphen has quit [Ping timeout: 240 seconds]
hyphen has joined #ocaml
szkl has joined #ocaml
mjs22 has quit [Ping timeout: 240 seconds]
pfharlock has quit [Remote host closed the connection]
pfharlock has joined #ocaml