EL

Elixir Defaults

Core Elixir coding conventions

Details

Language / Topic
elixirElixir
Category
Style Guide

Rules

balanced
- Use pattern matching for control flow. Match on function arguments, not inside function bodies.
- Use pipe operator (`|>`) for data transformation pipelines. Keep each step on its own line.
- Use pattern matching in function heads instead of `if`/`case` — define multiple function clauses for different input shapes.
- Use the pipe operator `|>` to chain transformations — read data flow left-to-right: `data |> transform() |> format()`.
- Use `with` for complex pattern matching with multiple steps that may fail.
- Use `@spec` and `@type` attributes for all public functions — Dialyzer catches bugs at compile time.
- Prefer small, focused modules. Group related functions together.
- Use guard clauses in function heads for conditional dispatch over `if`/`cond` in bodies.
- Use structs (`%MyStruct{}`) for domain data with defined fields, maps for dynamic data.