On Tue, Nov 24, 2009 at 09:19:34 -0800, Jason Dagit wrote:
> * Don't be shy about changing to camelCase.

I'm fan of tacking a camelCase patch onto the bundles I submit.

Here is another iteration of the automatic camelCaser to make this go
faster.  The idea is to feed it a list of module exports and just have
it do its thing.

The idea is to work one module at a time, that is to send patches that
camelCase the functions exported by a single module, both within the
module and the modules that import them.

It still needs some manual checking because of whitespace (eg.
inadvertently messing up a do block because a string got shortened)
and also because of the possibility of creating awkward names.

Anyway, my goal in pushing this camelCase drive is to get silly people
like me to to stop talking about camelCase and go do productive things
instead!  Maybe we should put create a "sin jar", where the fine for
talking about camelCase is that you have to send a camelCase patch (thus
making it a little less likely that we have to talk about it in the
future).  So cough up, Jason! ;-) I've already sent patch99 to apologise
in advance for this mail.

-- 
Eric Kow <http://www.nltg.brighton.ac.uk/home/Eric.Kow>
PGP Key ID: 08AC04F9
import Data.Char
import System.Environment
import System.Cmd

main =
 do args <- getArgs
    str <- if null args
              then words `fmap` getContents
              else return []
    mapM_ applyCamel $
      filter hasUnderscore . map dropCommas $ str
 where
   dropCommas = filter (/= ',') 

hasUnderscore = any (== '_')

applyCamel w =
 do system $  unwords [ "grep -rl", w, "src", "|", "xargs darcs replace", w, w2 ]
 where
  w2 = camelCase w

camelCase :: String -> String
camelCase ('_':c:cs) = toUpper c : camelCase cs
camelCase (c:cs) = c : camelCase cs
camelCase [] = []

Attachment: signature.asc
Description: Digital signature

_______________________________________________
darcs-users mailing list
[email protected]
http://lists.osuosl.org/mailman/listinfo/darcs-users

Reply via email to