[Haskell-cafe] Re: Allowing hyphens in identifiers

Colin Paul Adams colin at colina.demon.co.uk
Wed Dec 16 09:12:31 EST 2009

>>>>> "Daniel" == Daniel Fischer <daniel.is.fischer at web.de> writes:

    Daniel> As a pre-alpha version:

    Daniel> ------------------------------------------------------------
    Daniel> module Main (main) where

    Daniel> import Data.Char (isUpper, isLower, toLower)

    Daniel> main :: IO () main = interact unCamel

    Daniel> unCamel :: String -> String unCamel ('<':cs) = '<' : inTag
    Daniel> cs unCamel (a:bs@(b:cs)) | isLower a && isUpper b = a :
    Daniel> '_' : toLower b : unCamel cs | otherwise = a : unCamel bs
    Daniel> unCamel cs = cs

    Daniel> inTag :: String -> String inTag ('>':cs) = '>' : unCamel
    Daniel> cs inTag (a:cs) = a : inTag cs inTag [] =
    Daniel> [] ------------------------------------------------------------

    Daniel> Compile, run with

    Daniel> ./unCamel < /path/to/HaddockOutput.html >
    Daniel> /path/to/Haddock_output.html

    Daniel> (or whatever Windows uses to redirect stdin and stdout)
    Daniel> This makes a few not-well-founded assumptions about
    Daniel> haddock's output. Try it on a couple of files, report
    Daniel> bugs.

I tried it.
I'm not all that happy with the resulting uncameling.

For instance,


goes to


which is uglier than before.

I.m not sure how I would write this going the other way, using
Richard's hspp pre-processor.

I'd want to write Database.Haskell_DB.Sql.Postgresql, but I'd guess
I'd have to write it as Database.Haskell_DB.Sql.Postgre_s_q_l or just
Database.Haskell_DB.Sql.PostgreSQL :-(

Anyway, I'm having trouble with using Richard hspp. It changes ok_url
to okUrl, but in fact the function concerned is named ok_url in
Network.URL, so the pre-processor would have to be applied as part of
cabal install for all packages. 

I don't think it's practical to edit all the .cabal packages as they
come in to say:

    ghc-options: -F -pgmF hspp

and cabal install does not recognize this line if I add to to my
~/.cabal/config file.

Duncan, is there a way this can be done?
Colin Adams
Preston Lancashire

More information about the Haskell-Cafe mailing list