companion_cube changed the topic of #ocaml to: Discussion about the OCaml programming language | http://www.ocaml.org | OCaml 5.2.0 released: https://ocaml.org/releases/5.2.0 | Try OCaml in your browser: https://try.ocamlpro.com | Public channel logs at https://libera.irclog.whitequark.org/ocaml/
torretto_ has quit [Remote host closed the connection]
torretto has joined #ocaml
f[x] has joined #ocaml
myrkraverk_ has joined #ocaml
myrkraverk has quit [Read error: Connection reset by peer]
twobitsp1ite has quit [Ping timeout: 265 seconds]
f[x] has quit [Remote host closed the connection]
walee_ has quit [Ping timeout: 252 seconds]
mbuf has joined #ocaml
Serpent7776 has joined #ocaml
terrorjack4 has quit [Remote host closed the connection]
bartholin has joined #ocaml
olle has joined #ocaml
<discocaml> <alfuin> i find that the streams are excellent
<discocaml> <alfuin> @CCBot @ilo_kali @yawaramin
<discocaml> <alfuin> streams do more than just pipe from one map to another. They also optimise the run so that if you have a filter and then a map, you can traverse the list only once and do both in one go. it seems that with the new Gatherers, they can now do one-to-many and many-to-one operations as well, meaning 'inserting-in-place' in a sequence.
<discocaml> <alfuin>
<discocaml> <alfuin> is there a way for sequence mapping to do the same?
<discocaml> <alfuin> @CCBot @ilo_kali @yawaramin
<discocaml> <alfuin> streams do more than just pipe from one map to another. They also optimise the run so that if you have a filter and then a map (if i remember correctly...), you can traverse the list only once and do both in one go. it seems that with the new Gatherers, they can now do one-to-many and many-to-one operations as well, meaning 'inserting-in-place' in a sequence.
<discocaml> <alfuin>
<discocaml> <alfuin> is there a way for sequence mapping to do the same?
olle has left #ocaml [#ocaml]
Anarchos has joined #ocaml
bartholin has quit [Quit: Leaving]
<Anarchos> ocaml 5.2 is really fast !
Anarchos has quit [Quit: Vision[]: i've been blurred!]
Anarchos has joined #ocaml
<discocaml> <otini_> 🙂 what are you running?
chrisz has quit [Ping timeout: 265 seconds]
chrisz has joined #ocaml
terrorjack4 has joined #ocaml
terrorjack4 has quit [Ping timeout: 246 seconds]
<discocaml> <Kali> alfuin: the Iter library on opam may fit your desire here
terrorjack4 has joined #ocaml
<discocaml> <deepspacejohn> I haven’t used gatherers, but that description definitely seems like something you can do with Seq in OCaml. And one of the advantages of Seq is similar in how it processes the entire list at once, which makes it optimal for piping transformations.
<discocaml> <darrenldl> one to many would just be flatmap, many to one would be fold
<discocaml> <darrenldl> generally have not seen any imperative stream interfaces that dont read like a derivative of FP sequences
<discocaml> <darrenldl> though i work with c# more than java
alexherbo2 has joined #ocaml
palainp has quit [Ping timeout: 255 seconds]
disruptek has joined #ocaml
f[x] has joined #ocaml
alexherbo2 has quit [Remote host closed the connection]
alexherbo2 has joined #ocaml
alexherbo2 has quit [Remote host closed the connection]
alexherbo2 has joined #ocaml
alexherbo2 has quit [Remote host closed the connection]
<discocaml> <astreamingcomesacrossthesky> A lot of the development of Java streams is inspired by Clojure afaik. I believe Java streams and Clojure's lazy sequences do not have the same logical representation, but the ideas behind Collectors and Gatherers are basically alike to transducers in Clojure.
twobitsprite has joined #ocaml
alexherbo2 has joined #ocaml
<Anarchos> astreamingcomesacrossthesky it can come from lisp or clojure or assembly, functional programming and streams are still a big mess in java :)
waleee has joined #ocaml
<discocaml> <cathalogrady> why isn't something like this builtin (or is it) to ocaml:
<discocaml> <cathalogrady>
<discocaml> <cathalogrady> ```ocaml
<discocaml> <cathalogrady> let ( $ ) f g x = g (f x)
<discocaml> <cathalogrady> ```
<discocaml> <cathalogrady> for inverse composition (sequencing)
<discocaml> <cathalogrady> I know we have `|>` but that doesnt let you have a partially applied starting point
<discocaml> <cathalogrady> why isn't something like this builtin (or is it?) to ocaml:
<discocaml> <cathalogrady>
<discocaml> <cathalogrady> ```ocaml
<Anarchos> cathalogrady because it is easy to define ?
<discocaml> <cathalogrady> let ( $ ) f g x = g (f x)
<discocaml> <cathalogrady> ```
<discocaml> <otini_> because there are many different opinions about having such operators as default in the ocaml stdlib, and where there is no consensus, the status quo wins
<discocaml> <otini_> the main argument against such default operators is that they encourage hard-to-read code
<discocaml> <cathalogrady> it can't really be much harder to read than using `|>` ?
<discocaml> <cathalogrady> yes I know I was using compose however that isn't very concise
<discocaml> <yawaramin> `let ( $ ) = Fun.compose`
<discocaml> <otini_> well the same people argue that `@@` leads to bad code whereas `|>` is ok, for instance
<discocaml> <otini_> not sure exactly why
<discocaml> <yawaramin> not everything needs to be an operator provided by the std lib
<discocaml> <cathalogrady> to be sequencing ig:
<discocaml> <cathalogrady> ```
<discocaml> <cathalogrady> let ( $ ) = Fun.flip @@ Fun.compose
<discocaml> <cathalogrady> ```
<discocaml> <otini_> if you want to have a nice, long read https://github.com/ocaml/ocaml/pull/2097
<discocaml> <cathalogrady> to be sequencing ig:
<discocaml> <cathalogrady> ```
<discocaml> <cathalogrady> let ( $ ) = Fun.flip Fun.compose
<discocaml> <cathalogrady> ```
<discocaml> <otini_> but yeah in any case it’s easy to define yours
<discocaml> <cathalogrady> ig my point is that with these kind of things you have to use a "utils" or alike area to place them.
<discocaml> <cathalogrady> you essentially creating a small extension to the stdlib
<discocaml> <yawaramin> yeah you can do that. alternatively, you can just not use point-free style 🤷‍♂️
<discocaml> <yawaramin> i've never seen the point of using point-free in OCaml, we can compose perfectly well with `|>` and `@@`
<discocaml> <cathalogrady> yes but point free can be concise when not abused
<discocaml> <cathalogrady> and can make it read even better, if you understand point free ofc
<discocaml> <yawaramin> yeah sure, i'm just saying that 99% of the time there's no big loss to not using it
<discocaml> <cathalogrady> yeah and I just want to be clear I am not really saying my opinion is the only one here, just thought id discuss this as I was always wondering where the line was here in the minds of other "camls"
alexherbo2 has quit [Remote host closed the connection]
<dh`> IME point-free notation is almost always pointless :-)
<dh`> and it also is almost always harder to read
<discocaml> <yawaramin> the ocaml/ocaml pull requests are full of discussions about this stuff. i've found they are _extremely_ reluctant to add operators in general. even let-operators. i guess because everyone has their pet operator that they want to include and there wouldn't be an end to it
<discocaml> <ada2k> i think chained @@ is unpleasant
<discocaml> <yawaramin> see eg https://github.com/ocaml/ocaml/pull/9887
<dh`> write what you're doing explicitly, it'll be a bit more verbose but you'll thank yourself when you come back to the code a year later
<discocaml> <cathalogrady> i really think it depends though, if you are doing things that heavily map from mathematical formula using combintory logic can feel quite nature
<discocaml> <cathalogrady> i really think it depends though, if you are doing things that heavily map from mathematical formula using combintory logic can feel quite natural
<discocaml> <yawaramin> sounds like a niche use case though
<dh`> sometimes
<dh`> but I've also seen code written by people who thought they were doing that :-)
mbuf has quit [Quit: Leaving]
<discocaml> <cathalogrady> yeah and I do admit I have written some point-free madness in college to annoy my peers 🙂
<discocaml> <pantagruel74> Hello! May you help me plz install ocaml on https://idx.google.com/
<discocaml> <pantagruel74> is you have working nix config for it?
<discocaml> <pantagruel74> I using this pakages ```
<discocaml> <pantagruel74> packages = [
<discocaml> <pantagruel74> pkgs.linux
<discocaml> <pantagruel74> pkgs.git
<discocaml> <pantagruel74> pkgs.gnupatch
<discocaml> <pantagruel74> pkgs.gnumake
<discocaml> <pantagruel74> pkgs.gcc
<discocaml> <pantagruel74> pkgs.opam
<discocaml> <pantagruel74> ];
<discocaml> <pantagruel74> ```
<discocaml> <pantagruel74> but it throws error what some global variables had not found
<discocaml> <pantagruel74> on opam init
Opus has quit [K-Lined]
bartholin has joined #ocaml
<discocaml> <pantagruel74> Resolved! If someone will need this config is:
<discocaml> <pantagruel74> ```
<discocaml> <pantagruel74> packages = [
<discocaml> <pantagruel74> pkgs.linux
<discocaml> <pantagruel74> pkgs.git
<discocaml> <pantagruel74> pkgs.gnupatch
<discocaml> <pantagruel74> pkgs.gnumake
<discocaml> <pantagruel74> pkgs.gcc
<discocaml> <pantagruel74> pkgs.opam
<discocaml> <pantagruel74> pkgs.ocamlPackages.findlib
<discocaml> <pantagruel74> pkgs.ocamlPackages.batteries
<discocaml> <pantagruel74> pkgs.ocamlPackages.dune_3
<discocaml> <pantagruel74> pkgs.ocamlPackages.ocaml
<discocaml> <pantagruel74> pkgs.ocamlPackages.utop
<discocaml> <pantagruel74> pkgs.ocamlPackages.odoc
<discocaml> <pantagruel74> pkgs.ocamlPackages.ocaml-lsp
<discocaml> <pantagruel74> pkgs.ocamlformat
<discocaml> <pantagruel74> pkgs.bash
<discocaml> <pantagruel74> ];
<discocaml> <pantagruel74> ```
Opus has joined #ocaml
Anarchos has quit [Read error: Connection reset by peer]
Anarchos has joined #ocaml
Anarchos has quit [Quit: Vision[]: i've been blurred!]
Anarchos has joined #ocaml
Serpent7776 has quit [Quit: leaving]
bartholin has quit [Quit: Leaving]
random-jellyfish has joined #ocaml
Anarchos has quit [Quit: Vision[]: i've been blurred!]
Tuplanolla has joined #ocaml
troydm has joined #ocaml
malte has quit [Remote host closed the connection]
malte has joined #ocaml