shroom

Type-safe structured LLM prompting for Haskell

Stackage Nightly 2026-11-30:0.1.0.0
Latest on Hackage:0.1.0.0

See all snapshots shroom appears in

BSD-3-Clause licensed by Manuel Bärenz
Maintained by [email protected]
This version can be pinned in stack with:shroom-0.1.0.0@sha256:f7caf101deb52e95f407e15b043ba105fb2e40f31404f9bc5569a060a9669397,4925

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.

Changes

Revision history for shroom

0.1.0.0 – 2026-11-27

  • First release. Typed LLM prompting on effectful: a program written with context and prompt gets back a typed Haskell value, retried when a reply fails to parse or breaks a property, and may offer the model tools its type lists. Released on an unsuspecting world.