[Haskell-cafe] Re: Allowing hyphens in identifiers
Ben Millwood
haskell at benmachine.co.uk
Wed Dec 16 10:45:01 EST 2009
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.
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.
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.
More information about the Haskell-Cafe
mailing list