Coding Standards
Frost is developed using Haskell, leveraging its powerful type system and functional programming paradigms. Adhering to these coding standards ensures consistency, readability, and maintainability across the codebase.
General Principles
Write idiomatic Haskell code
Prioritize readability and maintainability
Leverage the type system for safety and expressiveness
Avoid code duplication
Prefer pure functions and immutable data structures
Specific Guidelines
Naming Conventions
Use camelCase for function and variable names
Use PascalCase for type and constructor names
Prefix type class instances with the type name
Function Definitions
Provide type signatures for all top-level functions
Use pattern matching when appropriate
Prefer point-free style when it enhances readability
Error Handling
Use
Either
for recoverable errorsUse
Maybe
for optional valuesAvoid partial functions; use total functions with
Maybe
orEither
instead
Imports
Use qualified imports for modules with name clashes
Group and organize imports logically
Code Organization
Keep functions small and focused
Use meaningful module names that reflect their contents
Organize related functions into modules
Comments and Documentation
Write Haddock comments for all public functions
Use inline comments sparingly, preferring self-documenting code
Document complex algorithms or non-obvious implementations
Performance Considerations
Use appropriate data structures (e.g.,
Map
for associative arrays)Be mindful of lazy evaluation and space leaks
Profile and optimize only when necessary
Testing
Write unit tests for all public functions
Use property-based testing with QuickCheck where applicable
Aim for high test coverage, but prioritize meaningful tests over coverage percentage
By following these coding standards, we ensure that the Frost codebase remains clean, efficient, and maintainable. Remember, these guidelines are not exhaustive, and good judgment should always be applied when writing code.
Last updated