
Sven Panne wrote:
Code is mainly *read*, not written, so the less you need to know to read and understand code, the better it is.
Yes, and this is an argument *for* singleton, not against: 1. singleton is already known to the Haskell reader from the other collection types. 2. singleton is unambiguously invoking the image of creating a singleton collection. In contrast, "pure" invokes the image of creating a effect-free monadic computation. (:[]) invokes the image of a (mechanical) gorilla smiling at you. ;-) All these associations distract from reading the code. In both cases, a mental translation step is needed: a) In the case of "pure", the conscious intervention that here we are not concerned with non-determinism (the list monad), but just creating a singleton collection. b) In the case of "(:[])", the conscious intervention consists of - recognizing the decomposition (: []) - recognizing the operator section - understanding it as "cons something to the empty list" - understanding this as creating a singleton collection. Both interventions hamper the flow of reading. Of course, the procedure b) becomes automatic with use. However, it is still a significant barrier to the newcomer. Cheers, Andreas P.S.: if the gorilla (:[]) is vanishing from the Agda code base, I am mostly to be blamed for this. On 2019-08-14 21:51, Sven Panne wrote:
Am Mi., 14. Aug. 2019 um 21:35 Uhr schrieb Oliver Charles
mailto:ollie@ocharles.org.uk>: I'd also be interested in a kind of "reverse" argument - *if* we had this added, what are the costs? There are arguments of "no, pure/robot ninja is enough" - fine, we're not taking those away so you aren't required to use singleton But what is the *downside* of having singleton? [...]
A similar argument comes up with basically every extension, and it is a very weak one. Code is mainly *read*, not written, so the less you need to know to read and understand code, the better it is. Lots of different ways to do the same thing makes programs harder to understand, and you ultimately end up with Perl. :-} And if we take this argument seriously, we should probably add "doubleton" (synonym for "replicate 2"), "tripleton" (synonym for "replicate 3"), etc., too. Hey, you don't have to use it after all, we're not taking away "replicate"...
_______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries