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/
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<d_bot> <inkbottle> No, I'm using `emacs` with `eglot`.
<d_bot> <inkbottle> It works right out of the box, save for the ocamlformat bit that times out.
rgrinberg has joined #ocaml
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<d_bot> <rgrinberg> I think eglot posts the output from stderr for the server. Is there anything there?
<d_bot> <inkbottle> There's an eglot buffer and I think it's empty on the subject, `message` buffer says `jsonrpc-error: "request id=8 failed:", (jsonrpc-error-message . "Timed out")`
<d_bot> <inkbottle> If I hadn't `ocamlformat` installed (opam), I'd get an eglot message about it, coming from ocamllsp.
<d_bot> <inkbottle> when doing `eglot-format` what it does (I believe), is:
<d_bot> <inkbottle> ```
<d_bot> <inkbottle> (jsonrpc-request
<d_bot> <inkbottle> (eglot--current-server-or-lose)
<d_bot> <inkbottle> :textDocument/formatting
<d_bot> <inkbottle> (cl-list*
<d_bot> <inkbottle> :textDocument (eglot--TextDocumentIdentifier)
<d_bot> <inkbottle> :options (list :tabSize tab-width
<d_bot> <inkbottle> :insertSpaces t
<d_bot> <inkbottle> :insertFinalNewline t
<d_bot> <inkbottle> :trimFinalNewlines t)
<d_bot> <inkbottle> nil)
<d_bot> <inkbottle> :deferred :textDocument/formatting)
<d_bot> <inkbottle> ```
<d_bot> <inkbottle> and it times out, so it doesn't actually error.
<d_bot> <inkbottle> If I do `ocamlformat bin/main.ml` in a terminal, it's fine.
slothby has quit [Ping timeout: 260 seconds]
slothby has joined #ocaml
<d_bot> <inkbottle> Just to check it it was otherwise working, I've done `eglot-rename`, and it worked, and `eglot-code-actions` / `type anotate`, and it worked too.
chiastre has quit [Ping timeout: 240 seconds]
chiastre has joined #ocaml
terrorjack has quit [Quit: The Lounge - https://thelounge.chat]
terrorjack has joined #ocaml
waleee has quit [Ping timeout: 252 seconds]
rawley has joined #ocaml
zebrag has quit [Quit: Konversation terminated!]
mbuf has joined #ocaml
saltrocklamp[m] has joined #ocaml
rawley has quit [Remote host closed the connection]
<saltrocklamp[m]> if i want to change where opam stores things to something other than `~/.opam`, do i set `OPAMROOT`? the `opam --help` output has circular references between `--root` and `OPAMROOT`, and neither one actually explains what the "root" is
gravicappa has joined #ocaml
<saltrocklamp[m]> huh, why does `opam init` think that opam.ocaml.org has an expired cert? looks fine in my browser
<saltrocklamp[m]> but when i check it with openssl it seems expired there too
<sleepydog> saltrocklamp[m]: i don't get that. here it says it expires May 14
<saltrocklamp[m]> weird
<sleepydog> opam init seems happy, too
<saltrocklamp[m]> ah wait, i read May -> March
<saltrocklamp[m]> so it's not verifying, but for some other reason
<saltrocklamp[m]> https://bpa.st/2PSQ
<saltrocklamp[m]> maybe something with the certs on my system? i'm on macos big sur
salkin has joined #ocaml
azimut_ has quit [Remote host closed the connection]
azimut has joined #ocaml
mro has joined #ocaml
salkin has quit [Quit: salkin]
mro has quit [Remote host closed the connection]
mro has joined #ocaml
olle has joined #ocaml
bobo has quit [Ping timeout: 240 seconds]
bobo has joined #ocaml
olle has quit [Quit: leaving]
olle has joined #ocaml
kaph has quit [Read error: Connection reset by peer]
mro has quit [Quit: Leaving...]
wingsorc has quit [Quit: Leaving]
Anarchos has joined #ocaml
<d_bot> <Bluddy> Is there a Lens library outside of Jane Street's Accessors?
azimut has quit [Ping timeout: 240 seconds]
azimut has joined #ocaml
bartholin has joined #ocaml
<d_bot> <Bluddy> thanks!
chrisz has quit [Ping timeout: 256 seconds]
chrisz has joined #ocaml
perrierjouet has quit [Quit: WeeChat 3.4.1]
perrierjouet has joined #ocaml
chrisz has quit [Ping timeout: 256 seconds]
chrisz has joined #ocaml
bartholin has quit [Ping timeout: 260 seconds]
bartholin has joined #ocaml
vicfred has quit [Quit: Leaving]
kaph has joined #ocaml
omegatron has joined #ocaml
zebrag has joined #ocaml
bartholin has quit [Ping timeout: 256 seconds]
olle has quit [Ping timeout: 272 seconds]
neilthereildeil has joined #ocaml
<neilthereildeil> hey guys
<neilthereildeil> im trynna deobfuscate some ocaml code:
<neilthereildeil> Hashtbl.add h fd e; e in
<neilthereildeil> whats does the semicolon do here?
<d_bot> <NULL> Separate expressions, similarly to how it separates instructions in imperative languages
<d_bot> <NULL> It's nearly the same as `let () = Hashtbl.add h fd e in e`
bartholin has joined #ocaml
<neilthereildeil> what would that have done?
<neilthereildeil> the "in e" part?
<d_bot> <NULL> It returns e after running the first part
neilthereildeil has quit [Client Quit]
neilthereildeil has joined #ocaml
<neilthereildeil> so this code is inside is nested 4 levels deep in let statements
<neilthereildeil> it doesnt actually run the first part until any of the outer functions are called, does it?
<d_bot> <NULL> It will be run if add_event is called and Hashtbl.find h fd raises Not_found
<neilthereildeil> right
<neilthereildeil> so "; e" basically causes that whole let statement to evaluate to e, which effectively returns e?
<neilthereildeil> please correct me if im wrong?
<neilthereildeil> also, what does "event_set e in" do after the ';'? does that cause the add_event function to return those 2 values?
bartholin has quit [Ping timeout: 256 seconds]
bartholin has joined #ocaml
<d_bot> <NULL> The returned e is going to be the value for the outer `let e = ...` definition
<neilthereildeil> i just realized there are 2 let e= statements
<neilthereildeil> does it just use the e with the more tightly bound scope?
<d_bot> <NULL> In `let e = expr1 in expr2`, every definition in `expr1` is out-of-scope for `expr2`
<d_bot> <NULL> So which e is "taken" is unambiguous here
<neilthereildeil> aren't the variables defined in expr1 are usable in expr2?
<d_bot> <NULL> No they're not
<d_bot> <NULL> Ususally, you do `let v1 = ... in let v2 = ... in ...`
<neilthereildeil> so in the code i pasted, how is 'h' accessible inside of the most nested statements?
<d_bot> <NULL> This way, v1 is bound in v2's definition and after it
<d_bot> <NULL> It seems you're confusing `let v2 = let v1 = ... in ... in ...` and `let v1 = ... in let v2 = ... in ...`
<neilthereildeil> ahh ok so "let" statement extends the current scope into whatever follows?
<d_bot> <NULL> The former confines `v1` to the definition of `v2`, the latter does not
<neilthereildeil> ok understood thx
<neilthereildeil> so "; e" basically causes that whole let statement to evaluate to e, which effectively returns e?
<d_bot> <glennsl> OCaml does not have statements, it has expressions. `let x = <e1> in <e2>` is an expression with two sub-expressions, `e1` and `e2`
<neilthereildeil> so "; e" basically causes that whole let EXPRESSION* to evaluate to e, which effectively returns e?
<d_bot> <glennsl> `<e1>; <e2>` is an expressiont hat evaluates to `e2`, yes
<neilthereildeil> ok gotit
<d_bot> <glennsl> (and you'll get a warning if `e1` does not evaluate to `unit`, because that would usually be a mistake)
<neilthereildeil> also, what does "event_set e in" do after the ';'? does that cause the add_event function to return those 2 values?
<neilthereildeil> or is that a function call?
<d_bot> <NULL> `f x` is a function call
dextaa_ has joined #ocaml
<octachron> Another important point is that `in` is not meaningful by itself. You should always read it as a part of a local let binding: `let <pattern> = <expr1> in <expr2>`
<d_bot> <NULL> (Just like `let <p> = <e>` is only meaningful on its own when it is a toplevel definition)
<neilthereildeil> yea, im noticing let, in and = dont always have to go togehter. trynna ready about that now...
<d_bot> <NULL> There are 3 things : toplevel definition `let <p> = <e>`, local definition `let <p> = <e> in <e>` and boolean equality (or any function you define it as) `<e> = <e>`
<d_bot> <inkbottle> I'm struggling with https://github.com/ocaml/ocaml-lsp in conjunction with https://github.com/joaotavora/eglot:
<d_bot> <inkbottle> everything is working fine and straight out of the box, with no `emacs/eglot` configuration and only `opam install ocaml-lsp-server ocamlformat` and `dune init proj my_project`, `cd my_project`, `touch .ocamlformat`. Then just emacs-open `bin/main.ml`, and `M-x eglot`, and everything is working fine. Save that `M-x eglot-format`, which is a staple, says: `jsonrpc-error: "request id=35 failed:", (jsonrpc-error-message . "Timed o
<d_bot> <NULL> Those are the only 3 constructs where `let`, `in` and `=` can appear as tokens
<octachron> Not exactly `=` is used for all definitions `type t = ...` `module M = ...` `module type MT = ...`
<d_bot> <NULL> Oops, forgot those
<octachron> At the same time, they are toplevel definitions
<neilthereildeil> so in the code i pasted, theres:
<neilthereildeil> let h = Hashtbl.create 57 in
<neilthereildeil>  let add_event event_set fd =
<neilthereildeil> one expression has "in" withile the other doesnt
<neilthereildeil> does this mean that add_event is global?
<neilthereildeil> err. toplevel
<d_bot> <NULL> No, it's in another definition so it isn't
<octachron> In this case, this means that you have not finished to read the definition of add_event
<d_bot> <NULL> This just means your code is truncated
waleee has joined #ocaml
<octachron> and that there is an `in` later that is paired wit the `let` in `let add_event = ... `
<neilthereildeil> ok, so the context matters when deciding if something is toplevel. not just the absence of "in"
<d_bot> <NULL> If the code is well-formed, the absence of `in` is enough; if it isn't, you could say so
<d_bot> <NULL> Toplevel definitions are usually those which start unindented
<neilthereildeil> does whitespace matter in ocaml?
<neilthereildeil> like in py
<neilthereildeil> ?
<companion_cube> nope
<d_bot> <NULL> Not more than C or JS: it matters for the reader, not the compiler
epony has quit [Read error: Connection reset by peer]
<d_bot> <NULL> to* the reader
epony has joined #ocaml
<neilthereildeil> can we think of let={ and in=}?
<d_bot> <NULL> There's a definition in there also
<neilthereildeil> no i mean mentally, can we think of let as similat to '{' and in as similar to '}' in C?
<octachron> No
<d_bot> <NULL> I understood, but you're forgetting that let in is a definition more than a scoping mechanism
<d_bot> <NULL> The scope is similar
<neilthereildeil> ur saying as far as scoping goes, we can think of let as similat to '{' and in as similar to '}' in C?
<octachron> You could say that there are `{` `}` around `expr1` in `let p = <expr1> in`
<neilthereildeil> how would i represent nested C {{}} in ocaml?
<neilthereildeil> in terms of scope?
<companion_cube> nested begin/end
<d_bot> <NULL> Or nested parentheses, those are equivalent
<octachron> `let <p> = <expr1> in <expr2>` will be most similar to `{var <p>= {<expr1>}; <expr2>}` in C. But C is a bad mental model for any expression-bases language like OCaml
rgrinberg has joined #ocaml
kor1 has joined #ocaml
kor1 has quit [Client Quit]
kor1 has joined #ocaml
<neilthereildeil> is there any requirements for balancing of let and in?
<octachron> It doesn't make sense to have an `in` without a `let`.
<octachron> However, toplevel definitions use a `let` without an `in`.
kor1 has quit [Client Quit]
kor1 has joined #ocaml
<d_bot> <NULL> (But besides those, `let` don't make sense without an `in`)
<neilthereildeil> which 'e' does "event_set e in" refer to?
<d_bot> <NULL> The only one in context
<neilthereildeil> i see 2 'e's
<neilthereildeil> which one is in context here?
<d_bot> <NULL> The inner one is not in context at call site
<d_bot> <NULL> because it's in a definition
<neilthereildeil> <NULL> It seems you're confusing `let v2 = let v1 = ... in ... in ...` and `let v1 = ... in let v2 = ... in ...`
<neilthereildeil> <NULL> The former confines `v1` to the definition of `v2`, the latter does not
<d_bot> <NULL> Rather, it is defined in the definition of another variable
kor1 has quit [Ping timeout: 240 seconds]
<neilthereildeil> i see let let in in pattern here
kor1 has joined #ocaml
<neilthereildeil> this means that "e = init_event ()" is confined to the contact of:
<neilthereildeil> try Hashtbl.find h fd
<neilthereildeil>    with Not_found ->
<neilthereildeil> right?
<neilthereildeil> context*
<d_bot> <NULL> No, even smaller
<d_bot> <NULL> `let e = init_event () in Hashtbl.add h fd e; e` is a complete expression, what follows is the `in` of a bigger expression containing this one
<d_bot> <NULL> This means that what's after the definition is the only place where this `e` is in context
<neilthereildeil> but itsnt this parsed the same as yiour example?
<neilthereildeil> let let in in
<d_bot> <NULL> Pretty much
<d_bot> <NULL> (There's a try with construct between the two lets, but this doesn't change much)
kor1 has quit [Client Quit]
<d_bot> <NULL> So `v1` is confined to inside the definition of `v2`
<neilthereildeil> according to what you said, this means that "e = init_event ()" is confined to the context of:
<neilthereildeil> try Hashtbl.find h fd
<neilthereildeil> with Not_found ->
<neilthereildeil> what is v1 and v2 here?
<d_bot> <NULL> As soon as you pass the second `in`, `v1` is out of scope
kor1 has joined #ocaml
<d_bot> <NULL> `let v2 = <v1,v2 not defined> let v1 = <v1,v2 not defined> ... in <v1 defined, v2 not> ... in <v1 out-of-scope, v2 defined> ...`
<neilthereildeil> so "e = init_event ()" is out of scope for "event_set e"?
<d_bot> <NULL> If you mean "the e that is defined by init_event", yes
<neilthereildeil> ok
kor1 has quit [Ping timeout: 245 seconds]
<neilthereildeil> and "event_set e" is referring to the 'e' 5 lines prior
<neilthereildeil> right?
<octachron> yes
<neilthereildeil> and the e 5 lines prior ended up being the 'e' that was returned by "; e"?
mbuf has quit [Quit: Leaving]
<d_bot> <NULL> the whose definition starts 5 lines above, yes
kor1 has joined #ocaml
<d_bot> <NULL> The try with construct splits the flow, in one case this e is what is returned
<neilthereildeil> ok gotit thanks
<octachron> only if `Hashtbl.find` at line 5 raised a Not_found exception
<neilthereildeil> ok guys, thats enough for today LOL
<neilthereildeil> thanks so much for your help
neilthereildeil has quit [Quit: Client closed]
kor1 has quit [Ping timeout: 246 seconds]
bartholin has quit [Quit: Leaving]
olle has joined #ocaml
Tuplanolla has joined #ocaml
Anarchos has quit [Ping timeout: 272 seconds]
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
vicfred has joined #ocaml
spip has joined #ocaml
bobo has quit [Ping timeout: 272 seconds]
gravicappa has quit [Ping timeout: 256 seconds]
rgrinberg has joined #ocaml
motherfsck has quit [Quit: quit]
Serpent7776 has quit [Quit: leaving]
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
rgrinberg has joined #ocaml
motherfsck has joined #ocaml
wyrd has quit [Ping timeout: 240 seconds]
wyrd has joined #ocaml
olle has quit [Ping timeout: 260 seconds]
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Tuplanolla has quit [Quit: Leaving.]
rawley has joined #ocaml
vicfred has quit [Quit: Leaving]