Why is the empty string the zero of the String type? The empty string is the unit of the string monoid, so if anything, one(s::String) should give the empty string. Also, how does this solve any of the problems with a default function that John pointed out? Namely that new custom types generally won't have methods for the default/zero function.
On Thu, Feb 27, 2014 at 8:33 PM, Fil Mackay <f...@vertigotechnology.com>wrote: > On Fri, Feb 28, 2014 at 2:22 AM, Stefan Karpinski <ste...@karpinski.org>wrote: > >> Technically the empty string is the 1 of the string monoid. The point >> being that the correct default value depends on what you're doing. If we >> were going to have a default value function, it should be a different >> thing. I'm not convinced that we should encourage default values, however. >> They strike me as slightly sketchy. >> > > What if we just implemented zero(s::String)? This then doesn't get into > what "default" actually means, because we are talking here explicitly about > zeros not 1's. I can't see a down side to that, and then we can work to > have a full coverage of zero on all types? > >