Re:Why Concurrency Is Hard
by nyanpasu64 on Wednesday November 11, 2020 @01:10AM
(#25055955)
I've heard about lenses, but never actually worked with them. This syntax seems to construct a "path" of sorts from the root to a field. What language is this? What type does the `set` operator/keyword return?
It's Scala with Monocle (and it's off the top of my head, so apologies for any mistake). `set` usually returns a function for transforming values of the root type, but this simplified syntax will apply it immediately to `config`, so it'll return a copy of config with the modification applied to it.
I don't quite understand? You can certainly write generic functions that work for any lens whose "target" is a given type.