← all repositories
Gabriella439/grace

A functional language that reverse-engineers prompts from types

Grace treats LLM outputs as typed expressions, inferring JSON schemas from how you actually use the result.

599 stars Haskell LLMOps · Eval
grace
Velocity · 7d
+0.3
★ / day
Trend
steady
star history

What it does

Grace is a small functional language where calling an LLM is just another function application. You write prompt{ key, text: "..." } : List Text and the interpreter handles the API call, then parses the response into a typed value. No client libraries, no manual schema wrangling.

The interesting bit

The type checker works backwards. If you interpolate a field into a string, Grace infers that field must be Text; if you loop over the result with for, it infers List. These inferred types become JSON schemas that constrain the model’s output. In some cases you can omit both the prompt text and the type annotation entirely—the model figures out what to generate from context alone. You can also write import prompt to have the model generate Grace code for you, including nested prompt calls.

Key highlights

  • Built-in prompt function with no dependencies or imports needed
  • Type inference drives JSON schema generation; schemas constrain model output
  • import prompt generates Grace code from a type signature or description
  • Browser-based REPL at trygrace.dev with interactive tutorial
  • Haskell implementation with CLI (interpret, repl, format, builtins)

Caveats

  • Name collision with Grace Language (gracelang.org); the longer “Fall-from-Grace” is needed for disambiguation
  • Only 595 stars; ecosystem and real-world battle-testing appear limited

Verdict

Worth a look if you build complex prompt chains and are tired of string templating and manual schema validation. Probably overkill if you’re just doing a few one-off API calls in Python.

heatdrop uses Google Analytics to see which pages get read — nothing else. Your call. How we handle data.