4 ms·
Nice writeup. Although I really like the fact that lenses (from the `lens` package) can be composed using regular function composition, instead of the more gen
by sfvisser 13y ago
Nice writeup.
Although I really like the fact that lenses (from the `lens` package) can be composed using regular function composition, instead of the more generalized category composition like `fclabels` uses, I still think it's weird that the direction of composition is flipped.
I reads more like OO, but a lot less like idiomatic Haskell.
- dons 13y agoI strongly prefer the regular composition order. But I also use fclabels (FTW!) Changing the direction of composition makes no sense.
- tel 13y agoComposition order is the weirdest thing about Control.Lens.
- dan00 13y ago"Changing the direction of composition makes no sense." I also can't stand all these operators of the lens package. It feels like reading Perl code. The only annoying thing about all the other lens packages is the need for hiding '.' from Prelude.
- boothead 13y agoI thought that function composition (.) arises from the category instance for (->)? Actually on checking it seems that Prelude re-exports (.) from Data.Function. I'm sure I read somewhere that these had been unified, was I wrong?
- tome 13y agoI believe the argument against unifying is that you get very hard to decipher error messages.
- crntaylor 13y agoI also think it's a bit weird to flip direction of composition, but there are a couple of advantages -- 1. It keeps the "imperative" feel, so that you can write person.address.zipCode rather than zipCode.address.person 2. There's an argument that mathematical functions are "back to front" and that it would be more natural to write functions left to right, i.e. (x)f rather than f(x), so that the function composition f.g is "apply f then apply g" rather than "apply g then apply f" which is where we are at the moment.
- tel 13y agoLet's just go ahead and steal (<) and (>) for directional function composition everywhere. I'd rather just write `lt` and `gt`. x & f > g > h === h < g < f $ x
- tome 13y ago> There's an argument that mathematical functions are "back to front" and that it would be more natural to write functions left to right Totally agreed, but until programming languages adopt "x f = ..." for a definition of f then I'd prefer to stick to composing the traditional way round.