Lightweight Claude agent in idiomatic Haskell.
stack build
ANTHROPIC_API_KEY=... stack run| Variable | Required | Description |
|---|---|---|
ANTHROPIC_API_KEY |
one of two | API key auth |
ANTHROPIC_AUTH_TOKEN |
one of two | Bearer token auth |
ANTHROPIC_BASE_URL |
no | Override base URL (default: https://api.anthropic.com) |
app/Main.hs -- Entry point: load env → chatLoop
src/Types.hs -- Core types: Role, Message, ToolCall, LLMResponse, Credentials, Session
src/Tool.hs -- ToolDef, ToolRegistry, built-in tools (read_file, write_file, exec)
src/Provider.hs -- LLMProvider typeclass + AnthropicProvider
src/Agent.hs -- Agent record + runTurn loop
Message.content :: Value— supports both plainString "text"and structured content blocks (required for Anthropic tool_use/tool_result)- HTTP requests use
send(notpost) to attach custom headers (x-api-key,anthropic-version) - Tool schemas use
"input_schema"key (Anthropic format, not"parameters") DuplicateRecordFields+OverloadedRecordDotthroughout — always use dot notation (x.field)
DuplicateRecordFields, OverloadedRecordDot, OverloadedStrings