companion_cube changed the topic of #ocaml to: Discussion about the OCaml programming language | http://www.ocaml.org | OCaml 4.12 released: https://ocaml.org/releases/4.12.0.html | Try OCaml in your browser: https://try.ocamlpro.com | Public channel logs at https://libera.irclog.whitequark.org/ocaml/
<jyc> I know this is #ocaml :) but I figure there might be overlap here–is there a channel where people talk about SMT solvers, e.g. Z3?
favonia has quit [Ping timeout: 265 seconds]
favonia has joined #ocaml
dhil has quit [Ping timeout: 252 seconds]
Tuplanolla has quit [Quit: Leaving.]
<d_bot> <Curzon> opam-cross-windows only works for one version of ocaml, and it didn't work for WSL (it worked on my linux computer though, but I'm not gonna use linux anymore soon)
<d_bot> <Curzon> `esy` is another choice but honestly, it feels like a JavaScript environment and not an OCaml environment. But if I really have to use `esy`, I guess I have to
waleee has quit [Ping timeout: 265 seconds]
adanwan has quit [Remote host closed the connection]
adanwan has joined #ocaml
Stumpfenstiel has quit [Remote host closed the connection]
Haudegen has quit [Quit: Bin weg.]
favonia has quit [Ping timeout: 264 seconds]
favonia has joined #ocaml
<companion_cube> jyc: good question, I don't know of any
<companion_cube> if you find one please let me know
<companion_cube> well ##smt seems to exist…
<jyc> companion_cube: thanks, will do :) I'll follow you to ##smt
favonia has quit [Ping timeout: 265 seconds]
favonia has joined #ocaml
<companion_cube> seems small but well
favonia has quit [Ping timeout: 264 seconds]
favonia has joined #ocaml
aquijoule_ has joined #ocaml
richbridger has quit [Ping timeout: 264 seconds]
mbuf has joined #ocaml
favonia has quit [Ping timeout: 265 seconds]
favonia has joined #ocaml
zebrag has quit [Quit: Konversation terminated!]
favonia has quit [Ping timeout: 244 seconds]
favonia has joined #ocaml
adanwan has quit [Remote host closed the connection]
adanwan has joined #ocaml
unyu has quit [Quit: WeeChat 3.2]
wilfred has quit [Quit: Connection closed for inactivity]
favonia has quit [Ping timeout: 264 seconds]
favonia has joined #ocaml
unyu has joined #ocaml
favonia has quit [Ping timeout: 268 seconds]
favonia has joined #ocaml
favonia has quit [Ping timeout: 265 seconds]
favonia has joined #ocaml
favonia has quit [Ping timeout: 244 seconds]
favonia has joined #ocaml
favonia has quit [Ping timeout: 265 seconds]
favonia has joined #ocaml
Serpent7776 has joined #ocaml
favonia has quit [Ping timeout: 268 seconds]
TheLemonMan has joined #ocaml
yoctocell has joined #ocaml
yoctocell has quit [Quit: C-x C-c, Shutting down OS...]
yoctocell has joined #ocaml
Tuplanolla has joined #ocaml
mikess has quit [Ping timeout: 265 seconds]
Manis has joined #ocaml
<Manis> Hi. I have a (hopefully not too stupid) typing question. What does Ocaml mean by "Error: This expression has type bytes = string but an expression was expected of type bytes option"?
olle has joined #ocaml
<jyc> It means your expression is something like “foo” but should be something like (Some “foo”)
bartholin has joined #ocaml
<Manis> jyc: Oh, it's that simple! I was getting totally confused by "bytes = string".
<Manis> Thanks.
<jyc> no problem, I figured as much. Yea OCaml error messages are often cryptic. Adding explicit types can sometimes help
<Manis> I was of the impression that if I put a value Ocaml would be smart enough to realise that it is not None.
<Manis> Usually the type error messages are more or less understandable (as long as it doesn't get too complex).
<jyc> Ah, is the option type coming from some function you’re attempting to call? Or maybe you have eg a list [“foo”, Some “bar”]
<jyc> type inference can sometimes make it so the “true” source of the error is not where you’d expect. There’s actually been research on accommodating for that in error messages: http://www.cs.cornell.edu/andru/papers/sherrloc/sherrloc.pdf
<Manis> Im afraid I need to get fitter in Ocaml first, before I can follow what you are writing, jyc.
<jyc> Haha, don’t mind me, I just had tea too late and now can’t sleep
<Manis> I'm basically writing a "trivial" script that communicates with a simple Modbus device. The option comes from a record I defined. Some messages I want to send have a value appended, some don't, so the record contains a "value: bytes option" field.
<Manis> jyc: Sometimes this is the source of some truly genius utilities :-)
<jyc> haha. I see, so you wrote “foo” and expected that because the type was string option, OCaml would automatically wrap it in Some?
<Manis> Exactly.
<jyc> I see, that makes sense. I think some languages actually do that
<Manis> Maybe my mind is broken by C-style languages but I was of the impression that None == NULL.
<jyc> in many ways it is, but OCaml doesn’t automatically insert anything for it
<jyc> in Scala you can apparently tell the compiler to do this: https://stackoverflow.com/questions/1746359
<jyc> A bit of nifty trivia is that in languages with None, the machine representation might actually end up just being NULL. Eg for something like a pointer option, instead of having a {x: int, is_some: bool}, if your pointers are never null, you can take advantage of that and just represent the whole thing as one int.
olle has left #ocaml [#ocaml]
<Manis> How could you represent a two-field record as one int?
<jyc> oh in this specific case, if is_some is only ever false when x is 0, then you can just compute is_some based on x
<Manis> Oh, I see.
<jyc> so 0 = None, 1 = Some 1, 2 = Some 2, etc., if you know you’ll never have Some 0 (because maybe you want all null pointers to be None)
<Manis> Is there an advantage to this representation to just having an option int?
<jyc> I think it is useful mostly because it saves space
<jyc> Here is an explanation of how it’s used in Rust, which also has an option type: https://stackoverflow.com/questions/46557608
<Manis> Hmm, okay. Too much magic for my taste.
<jyc> haha yea it is definitely mostly trivia
<Manis> It's kinda hilarious how most software developers don't hesitate to include a 250MB browser in their application, yet on the other hand people are optimizing single bytes.
<jyc> hehe
<Manis> "You're computer is just too slow to display our awesome e-banking webapp which basically just displays tables like in the 90s"
<Manis> *Your computer
Manis has quit [Read error: Connection reset by peer]
Manis has joined #ocaml
adanwan has quit [*.net *.split]
adanwan has joined #ocaml
adanwan has quit [Ping timeout: 244 seconds]
adanwan has joined #ocaml
Guest4189 has quit [Ping timeout: 244 seconds]
<Manis> These options are driving me crazy. I get a "string option" as an argument and want to fill it into a record field of type "bytes option". So I'm doing "field = (match arg with Some s -> Some (Bytes.of_string s) | None -> failwith "no argument");". Ocaml says "This expression has type string but an expression was expected of type string option". What does it mean?
bartholin has quit [Ping timeout: 258 seconds]
adanwan has quit [Ping timeout: 244 seconds]
adanwan has joined #ocaml
dhil has joined #ocaml
vizard has joined #ocaml
bartholin has joined #ocaml
dhil has quit [Ping timeout: 258 seconds]
adanwan has quit [Quit: _]
adanwan has joined #ocaml
Tuplanolla has quit [Ping timeout: 265 seconds]
<octachron> What part of the expression is underlined? Note that you want `Option.map Bytes.of_string arg`
dhil has joined #ocaml
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]
favonia has joined #ocaml
<Manis> octachron: underlined? Nothing is underlined. I'm still on Ocaml 4.05, though. None is actually not valid in this case and should throw an exception. That is not what Option.map is for, or is it?
<octachron> If `None` is not valid, the argument is not a really an option, isn't it?
<dmbaturin> No. Option.map applies a function to a value if that value is (Some v), else it just returns your Nonw back.
<Manis> octachron: It is for some commands, but not for this one.
<dmbaturin> It's the same concept a fmap in Haskell functors.
<dmbaturin> Manis: Could you paste the complete program?
<octachron> Then it first better to extract the option, and then apply `Bytes.of_string`.
<octachron> Or at the very least, give enough context to reproduce the error.
<octachron> for instance the location of the error as given by Merlin.
<octachron> and upgrading the version of OCaml would improve the error messages
<dmbaturin> With the convenience of `opam switch create` and OCaml's compatibility track record, I never found a reason to stick with an old version.
<Manis> dmbaturin: First of all I don't really like having parallel installations to my OS's package manager and Ocaml doesn't seem to compile without patches on FreeBSD/arm *shrug*.
adrien_ is now known as adrien
<Manis> So, I put my little program on GitLab: https://gitlab.com/camerden/abl-wallbox-ocaml/-/blob/main/abl.ml#L276
mbuf has quit [Quit: Leaving]
bartholin has quit [Quit: Leaving]
<octachron> The repo is private
zebrag has joined #ocaml
<Manis> octachron: Oops, fixed it.
<octachron> There is no type errors in the code that you linked.
<Manis> Ehm, now I'm confused. So it seems the error was somewhere else o.O
xenu has quit [Ping timeout: 264 seconds]
xenu has joined #ocaml
berberman has quit [Ping timeout: 244 seconds]
berberman has joined #ocaml
Guest4189 has joined #ocaml
spip has joined #ocaml
waleee has joined #ocaml
spip is now known as Guest6205
Guest4189 has quit [Ping timeout: 265 seconds]
jinsun_ has joined #ocaml
jinsun has quit [Ping timeout: 265 seconds]
waleee has quit [Ping timeout: 265 seconds]
TheLemonMan has joined #ocaml
mikess has joined #ocaml
bartholin has joined #ocaml
favonia has quit [Quit: Leaving]
gareppa has joined #ocaml
gareppa has quit [Remote host closed the connection]
Manis has quit [Ping timeout: 265 seconds]
noddy has quit [Quit: WeeChat 3.2]
noddy has joined #ocaml
bartholin has quit [Ping timeout: 258 seconds]
glassofethanol has joined #ocaml
noddy has quit [Quit: WeeChat 3.2]
noddy has joined #ocaml
gravicappa has joined #ocaml
bartholin has joined #ocaml
glassofethanol has quit [Quit: leaving]
glassofethanol has joined #ocaml
oriba has joined #ocaml
jinsun_ is now known as jinsun
gareppa has joined #ocaml
mikess has quit [Ping timeout: 258 seconds]
Manis has joined #ocaml
<companion_cube> Manis: people who optimize one byte are not the same who embed electron 🤷
<Manis> companion_cube: Fortunately not, but the difference is still crazy given both call themselves "software developers", no?
<companion_cube> a term that encompasses kernel devs, video game devs, and frontend devs, has to be quite broad :)
gareppa has quit [Quit: Leaving]
<d_bot> <Alistair> Are there `min` and `max` functions that take comparators in the stdlib/base?
<d_bot> <Christophe> manis: do your records come from some JSON from a third party? If so that is the case you might want to investigate ATD, that generates converters and take care of wrapping optional values into options. If that is not your problem, feel free to ignore :D
<Manis> Christopha, No the records have been "hand-crafted" by me.
<d_bot> <Christophe> All right! You'll quickly find that once you have gotten your mind around it it's quite logical!
<d_bot> <Christophe> I miss all those types (option, result,...) at work, you get accustomed to them :D
Tuplanolla has joined #ocaml
mikess has joined #ocaml
<glassofethanol> So what's the deal with the community libraries and JaneStreet? reminds me of the whole Scala thing of Typelevel and Lightbend thing
bartholin has quit [Ping timeout: 258 seconds]
vizard has quit [Ping timeout: 258 seconds]
vizard has joined #ocaml
wilfred has joined #ocaml
bartholin has joined #ocaml
<companion_cube> well, it's just different efforts
<companion_cube> there's no wide consensus 🤷
Stumpfenstiel has joined #ocaml
<Manis> Is it correct to say that Jane Street is the biggest user of Ocaml?
<glassofethanol> I presume so, I don't really see any other big companies hyping their use
<glassofethanol> Granted I am new to OCaml so I wouldn't say my opinion matters
<glassofethanol> companion_cube: Any perticular benefit to using Janestreets libs like Async over Lwt for example?
mro has joined #ocaml
mro has quit [Remote host closed the connection]
mro has joined #ocaml
mro has quit [Remote host closed the connection]
mro has joined #ocaml
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]
<companion_cube> I'd rather not offer an opinion :D
<d_bot> <Deadrat> Lwt is more widely supported
<d_bot> <Deadrat> But some people like async design and patterns more
mro has quit [Remote host closed the connection]
mro has joined #ocaml
<companion_cube> Afaik people tend to either go fully into Janestreet stuff, or keep away from it. The exception is Base
<glassofethanol> Ah that makes sense, I'm just curious what to go for, I don't perticullary want to fully lock myself into one ecosystem if you know what I mean, but I guess its all personal preference
<glassofethanol> Don't meant to start a debate/war I personally see values in both so
<oriba> just use Stdlib at the beginning, and if you need more, see what fits your need.
mro has quit [Remote host closed the connection]
mro has joined #ocaml
yoctocell has quit [Ping timeout: 258 seconds]
elf_fortrez has joined #ocaml
<companion_cube> ^
Manis has quit [Quit: WeeChat 2.3]
<glassofethanol> oriba: Good shout cheers
glassofethanol has quit [Quit: leaving]
gravicappa has quit [Ping timeout: 265 seconds]
elf_fortrez has quit [Quit: Client closed]
waleee has joined #ocaml
shawn has quit [Ping timeout: 265 seconds]
bartholin has quit [Ping timeout: 265 seconds]
<d_bot> <Cyclomatic Complexity> The firebug API is dead, does JSOO still use it?
<d_bot> <Cyclomatic Complexity> i am trying to debug why `Firebug.console##log (Js.string "lol") ;` doesn't work
bartholin has joined #ocaml
<d_bot> <leviroth> No need for a comparator, you can just pass a comparison function to `Comparable.max`/`min`.
<d_bot> <Alistair> Thanks
jinsun has quit [Read error: Connection reset by peer]
jinsun has joined #ocaml
mro has quit [Ping timeout: 265 seconds]
shawnw has joined #ocaml
pmetzger has joined #ocaml
shawnw has quit [Ping timeout: 265 seconds]
mikess has quit [Ping timeout: 258 seconds]
<d_bot> <stab> If you plan on doing binary analysis u don’t really have a choice re stdlib requirements. You’re using core kernel wether you like it or not
<d_bot> <stab> I’ve come to appreciate it
bartholin has quit [Ping timeout: 265 seconds]
mikess has joined #ocaml
bartholin has joined #ocaml
wilfred has quit [Quit: Connection closed for inactivity]
pmetzger has quit []
bartholin has quit [Ping timeout: 258 seconds]
vb has quit [Ping timeout: 268 seconds]
vb has joined #ocaml
bartholin has joined #ocaml
shawnw has joined #ocaml
wilfred has joined #ocaml
unyu has quit [Quit: WeeChat 3.2]
bartholin has quit [Quit: Leaving]
vizard has quit [Ping timeout: 265 seconds]
Stumpfenstiel has quit [Ping timeout: 265 seconds]
Tuplanolla has quit [Quit: Leaving.]
dhil has quit [Ping timeout: 265 seconds]
oriba has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
vicfred has quit [Quit: Leaving]