Leonidas changed the topic of #ocaml to: Discussion about the OCaml programming language | http://www.ocaml.org | OCaml 4.13.0 released: https://ocaml.org/releases/4.13.0.html | Try OCaml in your browser: https://try.ocamlpro.com | Public channel logs at https://libera.irclog.whitequark.org/ocaml/
wyrd has quit [Remote host closed the connection]
adanwan_ has quit [Write error: Connection reset by peer]
azimut has quit [Write error: Connection reset by peer]
adanwan has joined #ocaml
azimut has joined #ocaml
wyrd has joined #ocaml
unyu has joined #ocaml
xd1le has joined #ocaml
<d_bot_> <mbacarella> I assume you're aware of jane's base/core libraries? Also intended to be stdlib replacements.
<d_bot_> <raedr7n> Yes, I'm aware of those as well.
<d_bot_> <nsmmrs> Have you seen OCamlverse? https://ocamlverse.github.io/content/standard_libraries.html
<d_bot_> <nsmmrs> It has a lot of nice breakdowns of "popular libraries for x".
<d_bot_> <nsmmrs> In my personal experience, I've always been aware of Batteries, but I only see people actively discuss Containers and Base/Core. The Containers developer is also very active in this discord, which is cool.
<d_bot_> <raedr7n> Yes; I've read that. I'm not sure what "modern" means in this context though. I guess I'm looking for something a bit more specific. For instance, the batteries decription states "that Containers was created to follow a different design than Batteries". How so?
<d_bot_> <raedr7n> That is cool!
<d_bot_> <nsmmrs> You can ask in the #containers-lib channel. 🙂
<d_bot_> <raedr7n> ah okay, thanks
<d_bot_> <nsmmrs> (I mean you can ask anywhere, but that's probably the best place) XD
<d_bot_> <mbacarella> Ah. How come the Jane ones didn't make your shortlist?
<d_bot_> <raedr7n> I'm lead to believe that they're significantly incompatible with Stdlib, and I already have a somewhat substantial codebase using Stdlib that I'd like to migrate in the future. That, and that I understand the Janestreet style of and approach to writing OCaml to be somewhat specialized.
chrisz has quit [Ping timeout: 256 seconds]
chrisz has joined #ocaml
unyu has quit [Quit: brb]
rgrinberg has joined #ocaml
unyu has joined #ocaml
spip has joined #ocaml
bobo has quit [Ping timeout: 256 seconds]
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
tizoc has quit [Quit: Coyote finally caught me]
rgrinberg has joined #ocaml
tizoc has joined #ocaml
azimut has quit [Remote host closed the connection]
azimut has joined #ocaml
bobo has joined #ocaml
spip has quit [Ping timeout: 250 seconds]
rgrinberg has quit [Ping timeout: 250 seconds]
rgrinberg has joined #ocaml
rgrinberg has quit [Read error: Connection reset by peer]
rgrinberg has joined #ocaml
mbuf has joined #ocaml
<d_bot_> <faderazor> hey guys
waleee has quit [Ping timeout: 240 seconds]
kakadu has quit [Ping timeout: 250 seconds]
<d_bot_> <raedr7n> hey
Haudegen has joined #ocaml
zebrag has quit [Quit: Konversation terminated!]
bobo has quit [Ping timeout: 240 seconds]
bobo has joined #ocaml
azimut has quit [Remote host closed the connection]
azimut has joined #ocaml
Serpent7776 has joined #ocaml
gravicappa has joined #ocaml
szkl has joined #ocaml
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
rgrinberg has joined #ocaml
mro has joined #ocaml
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
namkeleser has joined #ocaml
<d_bot_> <Et7f3 (@me on reply)> Hey
namkeleser has quit [Quit: Client closed]
kakadu has joined #ocaml
jackhill has quit [Remote host closed the connection]
jackhill_ has joined #ocaml
<d_bot_> <mseri> Yes, Containers extends Stdlib, while Base is meant as a replacement (don't know about Batteries)
<d_bot_> <Bluddy> Batteries is also an extension.
<d_bot_> <mseri> I just saw your reply in the other channel, good to knowfanboy
<d_bot_> <mseri> I am a containers fanboy anyway 😄
olle has joined #ocaml
unyu has quit [Quit: WeeChat 3.4]
mro has quit [Remote host closed the connection]
mro has joined #ocaml
bartholin has joined #ocaml
azimut has quit [Remote host closed the connection]
azimut has joined #ocaml
gravicappa has quit [Ping timeout: 256 seconds]
unyu has joined #ocaml
mro has quit [Remote host closed the connection]
bartholin has quit [Ping timeout: 252 seconds]
bartholin has joined #ocaml
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
mro has quit [Remote host closed the connection]
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
<companion_cube> a definite marker of taste!
<companion_cube> definitive*
mro has quit [Remote host closed the connection]
Anarchos has joined #ocaml
Haudegen has quit [Quit: Bin weg.]
<d_bot_> <VPhantom> Here's an odd one: I sometimes end up with constructs like: `if cond then (...things...; true) else false` and it feels "dirty" like I'm missing something cleaner. There's no `Bool.bind` but it's almost a case for it. That `else false` is bugging me with how redundant it looks. 😛 Am I in fact missing something or is this typical?
<vsiles> if cond then (....); cond ?
<d_bot_> <VPhantom> The condition is non-trivial.
<d_bot_> <VPhantom> I suppose I could do `let c = cond in if c then (...); c` 🤔
<d_bot_> <VPhantom> It's one less allocation but not particularly cleaner to the eye I think. Hm.
unyu has quit [Quit: WeeChat 3.4]
<d_bot_> <NULL> If you use this a lot, make it a `do_if_true: bool -> (unit -> unit) -> bool` function ?
<d_bot_> <VPhantom> Yeah I considered that, or making a let binding which would essentially be a `Bool.bind`, but it didn't really turn out to be that "clean" in the end. 😕
<d_bot_> <reynir> write a ppx! `if%cond cond then ...` -> `let c = cond in if c then ...; c` :P
<Anarchos> VPhantom (if cond then things);cond
<d_bot_> <VPhantom> I had `let@ _ = cond in (...things...)` which is cute but felt overkill. 😛
<d_bot_> <octachron> ` cond && (action (); true)`
<d_bot_> <VPhantom> (Hated that '_' in there.)
mro has joined #ocaml
<d_bot_> <VPhantom> Oh hey I hadn't thought of `&&`. I haven't dared rely on execution orders in OCaml yet.
<d_bot_> <VPhantom> (i.e. I haven't experimented with whether `a || b || c` behaved like how I used it for shortcuts in Perl.)
<d_bot_> <octachron> `&&` is short-circuiting (more precisely the compiler primitive used by `&&` is)
<d_bot_> <VPhantom> On the plus side, the PPX or let binding doesn't allocate the result, it just passes it along. Minus side, it adds a function call.
<d_bot_> <VPhantom> I might start using `&&` on occasion then, looks like a good fit. 🤔
<d_bot_> <VPhantom> Alright then. Glad I wasn't missing something obvious. I rarely reach that kind of situation but it happened a few times this week so I thought I should investigate.
unyu has joined #ocaml
Haudegen has joined #ocaml
mro has quit [Remote host closed the connection]
mro has joined #ocaml
mro has quit [Remote host closed the connection]
<d_bot_> <mbacarella> why not `Bool.iter`? 🤣
<d_bot_> <mbacarella>
<d_bot_> <mbacarella> `Bool.iter cond (fun () -> ...); cond`
azimut has quit [Ping timeout: 240 seconds]
servytor has joined #ocaml
waleee has joined #ocaml
gravicappa has joined #ocaml
mbuf has quit [Quit: Leaving]
olle has quit [Quit: Lost terminal]
spip has joined #ocaml
bobo has quit [Ping timeout: 256 seconds]
Haudegen has quit [Quit: Bin weg.]
bartholin has quit [Quit: Leaving]
<companion_cube> not really shorter than `if cond then …;`
gareppa has joined #ocaml
gareppa has quit [Remote host closed the connection]
mro has joined #ocaml
rgrinberg has joined #ocaml
mro has quit [Remote host closed the connection]
<reynir> On the discord side it appeared as `if cond then …;` :D
<d_bot_> <NULL> I've come to understand the character errors as …
mro has joined #ocaml
<companion_cube> ah damn, maybe my phone didn't use utf8?!
<reynir> let me try: `if cond then …;`
<d_bot_> <NULL> It worked this time
<companion_cube> fwiw I see it correctly in my laptop's IRC client
<reynir> me too
<d_bot_> <NULL> I assumed it came from the bridge, but apparently not
mro has quit [Remote host closed the connection]
<d_bot_> <NULL> Are there more than one character/sequence/however Unicode calls them to make … ?
<companion_cube> it's only one codepoint I suppose
<companion_cube> e2 80 a6
<companion_cube> 3 bytes, one codepoint
mro has joined #ocaml
mro has quit [Remote host closed the connection]
rgrinberg has quit [Read error: Connection reset by peer]
rgrinberg has joined #ocaml
Tuplanolla has joined #ocaml
Haudegen has joined #ocaml
zebrag has joined #ocaml
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<d_bot_> <VPhantom> I ended up using pattern: `let c = cond in if allowed then (...); c`. I just really hated to see that `else false`. 😛
<d_bot_> <VPhantom> (s/allowed/c/)
<d_bot_> <NULL> Not satisfied with octachron's proposal ? It looked the most compact (and satisfying to me)
mro has joined #ocaml
<d_bot_> <VPhantom> My condition spreads over two lines, it didn't look obvious what `&&` did, and there's still the `true` on the true side. Might as well share it:
<d_bot_> <VPhantom> <https://pastebin.com/82hL1QEJ>
<d_bot_> <VPhantom> (What I'm _actually_ doing in there probably looks like rookie code though. 😬 )
<d_bot_> <NULL> `e1 && e2` expands to `if e1 then e2 else false` in pretty much all programming languages
<d_bot_> <NULL> Imperative ones use it extensively to have `in_bounds i && condition a.(i)`
<d_bot_> <NULL> This way you don't have an out of bounds exception (or segfault) if i is not good
xd1le has quit [Quit: xd1le]
<d_bot_> <VPhantom> On a single line, I like it. Reminds me of ternary operators in other languages. This one looks awkward. I'm updating my paste to show both.
<d_bot_> <VPhantom> I'll grant you that with my `ocamlformat` settings it's 9 lines instead of 11.
<d_bot_> <VPhantom> I do like how it avoids indentation. I might end up with `&&` on second thought… Thanks the nudge!
<d_bot_> <glennsl> It's good practice to give names to complex conditions anyway, I think, even when only used once.
<d_bot_> <VPhantom> Hm. Fair counterpoint.
<d_bot_> <undu> It's Aldo helpful to name t'hem if they're expensive to calculate
<d_bot_> <undu> Ugh, the autocorrect
<d_bot_> <VPhantom> Yeah I tend to do that, especially if there's a chance it might be needed more than once in the future.
mro has quit [Remote host closed the connection]
mro has joined #ocaml
mro has quit [Remote host closed the connection]
mro has joined #ocaml
Anarchos has quit [Ping timeout: 256 seconds]
mro_ has joined #ocaml
mro has quit [Ping timeout: 272 seconds]
travv0 has left #ocaml [#ocaml]
gravicappa has quit [Ping timeout: 252 seconds]
mro_ has quit [Quit: Leaving...]
Serpent7776 has quit [Quit: leaving]
xgqt has quit [Ping timeout: 256 seconds]
xgqt has joined #ocaml
<d_bot_> <VPhantom> Okay, this is simply cute: `let option_of_bool ?yes ?no c = if c then yes else no` 😎
wyrd has quit [Ping timeout: 240 seconds]
<d_bot_> <undu> `let option_of_either = function | Left x -> Some x | Right _ -> None`
<sleepydog> this is just me, but i would find the use of either of those functions harder to read than the if or match statements they replace
<d_bot_> <undu> I think so as well 😉
kaph has quit [Read error: Connection reset by peer]
wyrd has joined #ocaml
<d_bot_> <VPhantom> Yeah I didn't end up needing it but I just thought it was cute.
kaph has joined #ocaml
wingsorc has joined #ocaml
<d_bot_> <mbacarella> is there any flavor left in this chewing gum?
<d_bot_> <mbacarella> `match cond with true as c -> thing; c | c -> c`
<d_bot_> <mbacarella> 😛
<d_bot_> <VPhantom> Clever!
<d_bot_> <VPhantom> It's similar to the path I was at before I simplified with `&&`.
<d_bot_> <mbacarella> can we exploit let punning somehow? 🤔
<d_bot_> <VPhantom> I explored a let binding (`let- _ = condition in ...`) but it was not particularly interesting.
Tuplanolla has quit [Quit: Leaving.]
<companion_cube> `(c && (thing; true) || (other_thing; false))`
Haudegen has quit [Ping timeout: 256 seconds]