This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is mobility-core, a shared Haskell library (not a standalone service) for the Namma Yatri mobility platform. It provides database abstractions, external service integrations, core types, and utilities consumed by multiple backend services.
Licensed under AGPL. Uses NoImplicitPrelude — all modules import Kernel.Prelude (or EulerHS.Prelude) instead of the standard Prelude.
nix develop # Enter Nix dev shell (required first time)
direnv allow # Alternative: auto-load via direnv
cabal build # Build the library
cabal test # Run all tests (Tasty + HUnit)
cabal repl all # Load REPL
nix build # Full Nix buildFormat and lint:
./dev/format-all-files.sh # Format with ormolu
hlint . # Lint (config: .hlint.yaml)The codebase uses a ReaderT pattern over EulerHS flows:
FlowR r a=ReaderT r L.Flow a— the primary monad for effectful code- Key constraints:
MonadFlow,HasFlowEnv,EsqDBFlow - Dependency injection via the Reader environment
Prelude.hs— Custom prelude re-exporting common types/functions. UsesUniversumandsafe-exceptions. Hides standardshow,error,undefined,id.Beam/— Type-safe PostgreSQL ORM layer using BeamStorage/— Storage backends: Beam ORM, Esqueleto SQL, Hedis (Redis), Clickhouse (V1/V2)External/— 40+ external service provider integrations organized asExternal/[ServiceType]/[Provider]/(e.g.,External/Payment/Juspay/,External/SMS/GupShup/). Each provider hasTypes.hs,Config.hs, and API client modules. Abstract interfaces live inExternal/[ServiceType]/Interface/.Types/— Core domain types including a large error hierarchy (Types/Error.hs)Utils/— Utility modules (40+)Tools/— Infrastructure concerns: logging, metrics (Prometheus), Slack notificationsInternalAPI/— Shared API type definitions (Servant-based)Streaming/— Kafka producer/consumer wrappers
- Provider pattern: External services define an
Interface/with abstract types; concrete implementations live in provider-specific subdirectories RecordDotPreprocessor: Enabled as a GHC plugin for dot-syntax record access- Heavy type-level programming:
TypeApplications,TypeFamilies,GADTs,RankNTypes,DataKindsare all default extensions DuplicateRecordFieldsis enabled — use type annotations orTypeApplicationsto disambiguate
package.yaml(Hpack) is the source of truth — it generatesmobility-core.cabal- Edit
package.yaml, not the.cabalfile directly - GHC flags include
-Wall -Werror— all warnings are errors
Tests are in lib/mobility-core/test/ using Tasty + HUnit. Test modules: ComputeIntersectionTests, Centesimal, DistanceCalculation, SignatureAuth, SlidingWindowLimiter, SnippetsCheck, Version, APIExceptions.
- Database types →
src/Kernel/Beam/Types/ - External service integrations →
src/Kernel/External/[ServiceType]/[Provider]/ - Utility functions →
src/Kernel/Utils/ - Common types →
src/Kernel/Types/