restyle-0.1.0: Convert between camel case and separated words style.

Portabilityportable
Stabilityexperimental
MaintainerDaniel Fischer <daniel.is.fischer@web.de>

Data.Transform.UnCamel

Contents

Description

Transform camelCased identifiers to separated_words.

Synopsis

Transformation Functions

unCamelHTML :: Char -> String -> StringSource

Transform identifiers in (haddock-produced) HTML files from camelCase to separated_words.

The separation character is freely choosable, but it is recommended to take one of those in Transform.Separators. Since underscore-separated identifiers are used in some libraries, choosing lowLine may lead to confusion.

The separation character is inserted between a lowercase character and an uppercase character immediately following. If that uppercase character is followed by a lowercase letter, it is also transformed to lower case.

String literals appearing in haddock comments are also transformed. Deal with it or yell.

unCamelSource :: Char -> String -> StringSource

Transform identifiers in (non-literate) source files from camelCase to separated_words.

The separation character is freely choosable, but it is recommended to take one of those in Transform.Separators. Since underscore-separated identifiers are used in some libraries, choosing lowLine may lead to confusion. On the other hand, it is the only one which has a fighting chance of producing valid Haskell code.

The separation character is inserted between a lowercase character and an uppercase character immediately following. If that uppercase charcter is followed by a lowercase letter, it is also transformed to lower case.

Operators including two or more consecutive dashes are handled correctly, i.e. |-- or --: are not treated as the start of a line-comment.

Single quotes in identifiers, as in foldl' or f'2''d, are not considered to begin a character literal. An unfortunate consequence of that and the simple algorithm is that in an expression like

              replicate 5'\\'

(with no space between number and character literal), the closing quote is considered to begin a character literal.

Comments are not transformed, which may lead to inconsistencies between code and comments. That may change in the future.