
Hi, Am Donnerstag, den 18.09.2014, 19:26 -0400 schrieb David Feuer:
sum, product—may be cached internally in tree nodes for fast update,
I’m a bit doubtful about the real-world impact of having product there, and probably also sum, besides educational code. Are these so much more common than other aggregations? I think if you want to cache something in treenodes for performance, you should use a suitable data structure there that supports this directly, instead of hoping that your operation happens to be one of the two special cases provided by the type class. Slightly off topic: Wouldn’t it be nice if we would not have to have to add these methods to provide optimized behavior, but rather have the user write "sum . toList" or some other idiomatic code (maybe suggested in the docs), and RULES provided by the container implementer would reliable replace this with the optimized version. Wouldn’t help in polymorphic code, but I doubt that much performance critical code is polymorphic in the container. But then he could simply provide a sumTree or sumSet or something else... I should stop mumbling in circles. Greetings, Joachim -- Joachim “nomeata” Breitner mail@joachim-breitner.de • http://www.joachim-breitner.de/ Jabber: nomeata@joachim-breitner.de • GPG-Key: 0xF0FBF51F Debian Developer: nomeata@debian.org