Profpatsch/.claude/CLAUDE-PROJECT-my-prelude.md

my-prelude Library

Battle-tested Haskell utility library providing "left-to-right Haskell" programming style. Complements standard Prelude with forward-chaining operators, consistent aToB naming, and explicit over clever patterns.

Core Modules

MyPrelude.hs

Foundation module with text conversions (textToString, bytesToTextUtf8), forward-chaining operators (&, <&>), and development utilities (todo).

Key pattern: traverseValidate accumulates all validation errors rather than short-circuiting.

Pretty.hs

Colorful error display with Err type, showPretty/printPretty functions, and JSON formatting. Integrates with Test.hs for colorful diffs.

Pattern: prettyErrsNoColor for production logs, colored output for development.

Parse.hs

Generic applicative parser (Parse from to) with error accumulation in ErrorTree. Supports parallel validation and integrates with FieldParser.

Uses DerivingVia for automatic instances and builds hierarchical error context for complex structures.

Postgres/

Type-safe PostgreSQL operations with MonadPostgres class, connection pooling, structured error types, and transactional support.

All database operations wrapped in Transaction m a for explicit transaction boundaries. Includes connection pooling and cardinality assertions (ensureSingleRow).

Json/Enc.hs

Efficient JSON encoding with Enc newtype wrapper, builder patterns, and performance-optimized operations.

Enables literal syntax ("hello", 42) while eliminating Value construction overhead. Sum types encoded as {"tag": "variant", "value": ...}.

FieldParser.hs

Type-safe field validation with FieldParser from to, composition via Semigroupoid, and built-in parsers for common types.

Uses >>> for validation pipelines and collects all errors with positional context rather than failing on first error.

ValidationParseT.hs

Environment-based validation parser with NonEmpty Error collection and sophisticated DerivingVia composition.

Combines Reader monad with applicative validation. Used as DerivingVia target for form processing.

Test.hs

Colorful testing framework with structured error output and Hedgehog property testing integration.

Tool.hs

Declarative external tool management with applicative parsing and type-safe labeled access via JSON configuration.

Arg.hs

Compile-time argument documentation: Arg "description" Type appears in IDE hints, compiled away at runtime.

Design Philosophy

Progression: Either Error aValidation (NonEmpty Error) aParse from to with hierarchical context.