tibbe / haskell-style-guide

A style guide for Haskell code.
957 stars 75 forks source link

mixed-case vs camel case #9

Closed alanz closed 11 years ago

alanz commented 11 years ago

Please clarify "Use mixed-case when naming functions and camel-case when naming data types"

What is mixed-case?

sjoness commented 11 years ago

@alanz In regards to this issue, I believe that mixed case is as follows; "This Is Mixed Case" and CamelCase is "ThisIsCamelCase" or "thisIsAlsoCamelCase".

However, using mixed case for function naming is incorrect @tibbe. Functions can start with a lowercase or capital letter, but they cannot have spaces. This means that camel case must but used when naming a function.

The example code below shows the use of CamelCase. The first letter of an identifier is lowercase and the first letter of each subsequent concatenated word is capitalised.

minAndMax :: Int -> Int -> (Int, Int)
minAndMax x y
    | x >= y    = (y,x)
    | otherwise = (x,y)
alanz commented 11 years ago

I suspect that the intent is to say something like "do not use underscores in names, but use camel case instead". It is not clear what is intended because to me mixed case and camel case, in terms of names which cannot have spaces in them, mean the same thing.

sjoness commented 11 years ago

@alanz Mixed case (also known as initial case) has spaces, that is the difference. CamelCase can start with the initial letter being capitalised, but doesn't have spaces.