shroom: Type-safe structured LLM prompting for Haskell

[ ai, bsd3, library, program ] [ Propose Tags ] [ Report a vulnerability ]

LLMs hallucinate, but if you use shroom, it will at least be a well-typed hallucination!

shroom lets an LLM understand the types you defined in Haskell and generate good values for them. A monadic program written with context and prompt returns a typed Haskell value, or a descriptive error. The model learns a type from what a human reader sees already: its Haddocks and its type, constructor and field names. Properties written as pure Haskell functions, example values and documentation for the model alone guide it further. A response that fails to parse or breaks a property is retried. The package includes the prompt monad and its effect interface (Control.Monad.Prompt.Effect), deriving via Generically, tool calls (Control.Monad.Prompt.Tool), and a mock backend that reads responses from files (Control.Monad.Prompt.FileMock). The classes describing types live in shroom-class, which this package re-exports.

A tool call is like an effect that the model triggers. The program's type decides which tools the model may use, and the model decides when and how.

shroom ships no backend for a real model. shroom-baikai supplies one for Claude and for OpenAI-compatible hosts such as a local Ollama.

library shroom

Modules

  • Control
    • Monad
      • Control.Monad.Prompt
        • Control.Monad.Prompt.Backend
        • Control.Monad.Prompt.Effect
        • Control.Monad.Prompt.FileMock
        • Control.Monad.Prompt.Promptable
        • Control.Monad.Prompt.Tool
          • Control.Monad.Prompt.Tool.Web
  • Data
    • Shroom
      • Data.Shroom.Class
        • Data.Shroom.Class.TH

library shroom:test-utils

Modules

  • CelebrityTypes
  • ConferenceTypes
  • GenericTypes
  • TestUtils
  • Types
  • WebToolReport

Flags

Manual Flags

NameDescriptionDefault
web

Build shroom-test-web-tools, which makes real calls to DuckDuckGo and Wikipedia.

Enabled
online

Master switch for the test suites that need network or an external service. Off under nix, where the sandbox has no network.

Enabled

Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0
Change log CHANGELOG.md
Dependencies aeson (>=2.2 && <2.3), base (>=4.20 && <4.22), bytestring (>=0.12 && <0.13), containers (>=0.6 && <0.8), directory (>=1.3 && <1.4), effectful (>=2.7 && <2.8), filepath (>=1.5 && <1.6), generics-sop (>=0.5.1 && <0.6), http-client (>=0.7 && <0.8), modern-uri (>=0.3 && <0.4), openapi3 (>=3.2 && <3.3), req (>=3.13 && <3.14), shroom, shroom-class (>=0.1 && <0.2), sop-core (>=0.5 && <0.6), tagsoup (>=0.14 && <0.15), tasty (>=1.4 && <1.6), tasty-hunit (>=0.10 && <0.11), template-haskell (>=2.22 && <2.25), text (>=2.1.2 && <2.2), time (>=1.14 && <1.15), universe-base (>=1.1 && <1.2), vector (>=0.13 && <0.14), witherable (>=0.5 && <0.6) [details]
Tested with ghc ==9.12
License BSD-3-Clause
Author Manuel Bärenz
Maintainer programming@manuelbaerenz.de
Uploaded by turion at 2026-11-27T12:25:39Z
Category AI
Distributions
Reverse Dependencies 1 direct, 0 indirect [details]
Executables shroom-dev
Downloads 0 total (0 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs not available [build log]
All reported builds failed as of 2026-11-27 [all 1 reports]