Style Guide

Tip: Run hica fmt <file> to automatically format your code according to these rules. Use hica fmt --check <file> to verify formatting in CI without modifying the file.

A Note on Consistency

A style guide is about consistency. Consistency within a project is important. Consistency within a single file is the most important. However, know when to be inconsistent — sometimes a rule just doesn’t fit. When in doubt, look at the surrounding code and match its style. Readability always wins.

1. The Hica Philosophy

2. Naming Conventions (The “Social Contract”)

Entity Style Example
Variables/Params snake_case user_name, retry_count
Functions snake_case calculate_total(), make_adder()
Structs PascalCase UserAccount, Point2D
Constructors PascalCase Some(), Err(), Ok()
Files kebab-case file-utils.hc, main.hc
Constants UPPER_CASE MAX_RETRIES, DEFAULT_PORT

3. Layout and Indentation

4. Whitespace

5. Functions, Arrows, and Pipes

The => arrow separates a function’s signature from its body. Consistent placement of => and |> is key to readable hica code.

6. Pattern Matching (match)

Pattern matching is where Hica code can get “busy.” Formatting is key to keeping it safe.

7. Structs and Tuples

8. Error Propagation

9. Comments and Documentation