This file provides guidance on coding style and approaches and on building the code.
The project uses fourmolu for Haskell code formatting. Configuration is in fourmolu.yaml.
Key formatting rules:
- 2-space indentation
- Trailing function arrows, commas, and import/export style
- Record brace without space:
{field = value} - Single newline between declarations
- Never use unicode symbols
- Inline
letstyle with right-alignedin
Format code before committing:
# Format a single file
fourmolu -i src/Simplex/Messaging/Protocol.hsSome files that use CPP language extension cannot be formatted as a whole, so individual code fragments need to be formatted.
Follow existing code patterns:
- Match the style of surrounding code
- Use qualified imports with short aliases (e.g.,
import qualified Data.ByteString.Char8 as B) - Use record syntax for types with multiple fields
- Prefer explicit pattern matching over partial functions
Comments policy:
- Avoid redundant comments that restate what the code already says
- Only comment on non-obvious design decisions or tricky implementation details
- Function names and type signatures should be self-documenting
- Do not add comments like "wire format encoding" (Encoding class is always wire format) or "check if X" when the function name already says that
- Assume a competent Haskell reader
StrictDataenabled by default- Use STM for safe concurrency
- Assume concurrency in PostgreSQL queries
- Comprehensive warning flags with strict pattern matching
# Standard build
cabal build
# Fast build
cabal build --ghc-options -O0
# Build specific executables
cabal build exe:smp-server exe:xftp-server exe:ntf-server exe:xftp
# Build with PostgreSQL server support
cabal build -fserver_postgres
# Client-only library build (no server code)
cabal build -fclient_library
# Find binary location
cabal list-bin exe:smp-serverswift: Enable Swift JSON formatclient_library: Build without server codeclient_postgres: Use PostgreSQL instead of SQLite for agent persistenceserver_postgres: PostgreSQL support for server queue/notification store
Custom forks specified in cabal.project:
aeson,hs-socks(SimpleX forks)direct-sqlcipher,sqlcipher-simple(encrypted SQLite)warp,warp-tls(HTTP server)