[Haskell-cafe] Re: Allowing hyphens in identifiers

Daniel Fischer daniel.is.fischer at web.de
Wed Dec 16 11:05:42 EST 2009


Am Mittwoch 16 Dezember 2009 16:45:01 schrieb Ben Millwood:
> On Wed, Dec 16, 2009 at 2:55 PM, Daniel Fischer
>
> <daniel.is.fischer at web.de> wrote:
> > unCamel :: String -> String
> > unCamel ('<':cs) = '<' : inTag cs
> > unCamel (a:b:c:cs)
> >    | isLower a && isUpper b && isLower c = a : '_' : toLower b : c :
> > unCamel cs unCamel (a:bs@(b:cs))
> >    | isLower a && isUpper b    = a : '_' : b : unCamel cs
> >    | otherwise                 = a : unCamel bs
> > unCamel cs = cs
>
> Excuse my pedantry, but: writeToList -> write_toList.

Nothing to excuse, thanks for spotting it so quickly.

>
> I think the third equation needs to be:
> > unCamel (a:b:cs@(c:_))
> >
> >  | isLower a && isUpper b && isLower c = a : '_' : toLower b : unCamel cs
>
> so that the third character is not ignored in subsequent parses.

Yep. That comes from posting code that never saw your editor :(

>
> By the way, I like camelCase because I think that in most cases you
> *don't* want to break identifiers up into their component words - you
> read and understand what the function does once, and then you use it
> as a word in its own right. Any resemblance to actual English is
> really just a mnemonic of sorts.

I'm with you.



More information about the Haskell-Cafe mailing list