langchain-hs-core: Core typeclasses and pure AST primitives for langchain-hs

[ ai, control, library, mit, web ] [ Propose Tags ] [ Report a vulnerability ]

Zero HTTP dependency core package containing ChatModel, RunnableTree, ContentBlock, Tool, and StreamEvent primitives.


[Skip to Readme]

Modules

[Index] [Quick Jump]

Downloads

Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.0.5.0, 0.0.6.0
Change log CHANGELOG.md
Dependencies aeson (>=2.0 && <3), async (>=2.2 && <2.3), base (>=4.17 && <5), base64-bytestring (>=1.2 && <1.3), bytestring (>=0.10 && <0.13), conduit (>=1.3 && <1.4), containers (>=0.6 && <0.9), directory (>=1.3 && <1.4), filepath (>=1.4 && <2), format-heavy (>=0.1 && <0.2), mtl (>=2.2 && <2.4), process (>=1.6 && <1.7), random (>=1.2 && <1.4), resourcet (>=1.2 && <1.4), scientific (>=0.3 && <0.4), sqlite-simple (>=0.4.18 && <0.5), stm (>=2.5 && <2.6), text (>=1.2 && <3), time (>=1.9 && <1.16) [details]
Tested with ghc ==9.12.4, ghc ==9.10.3, ghc ==9.8.4
License MIT
Copyright 2025-2026 Tushar Adhatrao
Author Tushar Adhatrao
Maintainer tusharadhatrao@gmail.com
Uploaded by tusharad at 2026-10-14T21:33:30Z
Revised Revision 2 made by tusharad at 2026-10-29T14:26:27Z
Category Web, AI, Control
Home page https://github.com/tusharad/langchain-hs#readme
Bug tracker https://github.com/tusharad/langchain-hs/issues
Source repo head: git clone https://github.com/tusharad/langchain-hs
Distributions Stackage:0.0.6.0
Reverse Dependencies 6 direct, 0 indirect [details]
Downloads 27 total (21 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for langchain-hs-core-0.0.6.0

[back to package description]

langchain-hs-core

The foundational, effect-polymorphic core framework of the langchain-hs AI ecosystem.

langchain-hs-core provides pure GADT abstract syntax trees, effect-polymorphic chat models, streaming protocols, tools, agents, vector stores, retrievers, document loaders, memory, cache, output parsers, guardrails, resilience, observability, and the canonical Langchain.Prelude without concrete provider-specific dependencies.

Key Primitives & Modules

  • Runnables & Pure ASTs (Langchain.Runnable): Pure GADT abstract syntax tree (RunnableTree m i o) for pipeline composition via |>> (sequential), &>& (parallel fan-out), runLambda, runPrim, and deferred evaluation via interpret.
  • Chat Models & Types (Langchain.Model, Langchain.Model.Types): Effect-polymorphic ChatModel typeclass, Message, Role, ContentBlock (multi-modal text, images, tool calls, tool results).
  • Streaming Protocols (Langchain.Stream): Conduit-based incremental token streaming via StreamEvent and LLMChunk.
  • Tools & Dynamic Calling (Langchain.Tool, Langchain.Tool.Binding): Effect-polymorphic Tool m, createTool, Generic Schemas, and built-in tools (Calculator, FileSystem, Shell). Provider-agnostic tool binding via ToolBinder.
  • Agents (Langchain.Agent.ReAct, Langchain.Agent.PlanAndExecute):
    • ReAct Agent: Full reasoning + acting agent loop with tool inspection, memory integration, callbacks, and step traces.
    • Plan-and-Execute Agent: Two-phase agent decomposing complex user goals into discrete execution plans.
  • Prompt Templates (Langchain.PromptTemplate): String prompt templates with {var} f-string interpolation and pre-bound partial variables.
  • Vector Stores (Langchain.VectorStore): Abstract VectorStore typeclass and thread-safe InMemoryVectorStore.
  • Retrievers (Langchain.Retriever): BM25 keyword search (BM25Retriever), vector similarity retriever, and Reciprocal Rank Fusion (HybridRetriever).
  • Document Loaders & Text Splitters (Langchain.DocumentLoader, Langchain.TextSplitter): Document metadata abstraction and splitters for character chunks, Markdown, programming code, and tokens.
  • Memory & Cache (Langchain.Memory, Langchain.Cache): BaseMemory, ConversationBufferMemory, WindowBufferMemory, and STM-backed in-memory LLMCache.
  • Output Parsers (Langchain.OutputParser): Strongly typed JSON Schema generation (JsonOutputParser) and structured parsing.
  • Guardrails & Safety (Langchain.Guardrails): Input and output content moderation, PII redaction, and semantic safety validations.
  • Resilience & Fault Tolerance (Langchain.Resilience): State-machine CircuitBreaker, exponential backoff RetryConfig, and fallback handlers.
  • Observability & Tracing (Langchain.Observability, Langchain.Callback): OpenTelemetry distributed tracing spans, structured JSON event logging, and lifecycle event callbacks.
  • Chains (Langchain.Chain.RetrievalQA): End-to-end question answering pipeline over indexed knowledge bases.
  • Langchain Monad (Langchain.Monad): Decoupled LangchainT env m a reader and error transformer.
  • Canonical Prelude (Langchain.Prelude): Batteries-included single-import entry point providing the full core framework API.

Installation

Add to your cabal or package.yaml dependencies:

build-depends:
    langchain-hs-core >= 0.0.6.0 && < 0.0.7.0

To connect concrete LLMs, combine with satellite provider packages:

  • langchain-hs-ollama: Local & offline models (Llama 3, DeepSeek, Gemma).
  • langchain-hs-openai: OpenAI, OpenRouter, and OpenAI-compatible cloud endpoints.
  • langchain-hs-gemini: Google Gemini with multi-modal support.
  • langchain-hs-mcp: Model Context Protocol tool client.

For cyclic state machines, checkpointers, and multi-agent coordination, add langchain-hs-graph (or use the umbrella langchain-hs package).

License

Distributed under the MIT License. See LICENSE for details.