Learn the basics of Eta
In Eta the source file names should be the same as the module name with a .eta extension appended. And the module name always starts with a capital letter.
It is good practice to name the file after the description of what the file does.
In Eta types start with a capital letter.
1 2 | add :: Int -> Int -> Int
add x y = x + y
|
In the above example, Int is a type defined in Eta's standard library and starts with a capital letter.
1 | data Pair = Pair Int Int
|
In the above example, Pair is a user-defined type and starts with a capital letter.
In Eta, functions start with a lowercase letter.
Function names with multiple words are written using camelCase convention.
1 2 | add :: Int -> Int -> Int
add x y = x +y
|
In the above example, add is a function.
1 2 3 4 | data Pair = Pair Int Int
myPair :: Pair
myPair = Pair 1 2
|
In the above example, myPair is a function written using the camelCase convention.
It good practice to use descriptive names. The names should make the purpose of the entity clear. One should avoid using meaningless words like Wrapper etc. in names.
When using an acronym as part of a declaration name, capitalize it when it consists of two letters (IOStream); capitalize only the first letter if it is longer (HttpInputStream).
In most cases, Eta follows Haskell and Java conventions.
Use 4 or 8 spaces for indentation. Do not use tabs.
It's good practice to format your code to fit into 80 columns.
Operators
Put spaces around operator ( x + y + z ). Don't put space around range operator (1..n).
Functions
1 2 3 | reverse :: [Int] -> [Int]
reverse [] = []
reverse (x:xs) = reverse xs ++ [x]
|
Never put a space after (, [, or before ], ).