Introduction
Dhall is a programmable configuration language designed to replace hand-written JSON, YAML, and TOML files. It provides functions, types, and imports while guaranteeing that every Dhall expression terminates — there are no infinite loops or unbounded recursion. This makes it safe to evaluate untrusted configuration code.
What Dhall Does
- Generates JSON, YAML, TOML, Bash, and other formats from typed Dhall expressions
- Provides functions, records, unions, and generics for DRY configuration
- Guarantees termination — every Dhall program finishes in finite time
- Supports remote imports with integrity checking via SHA-256 hashes
- Catches configuration errors at evaluation time with a strong type system
Architecture Overview
Dhall is a total functional programming language — it deliberately excludes Turing-complete features like general recursion. The evaluator normalizes expressions (resolving imports, applying functions, and reducing terms) to produce a final value that is then serialized to the target format. The type checker runs before evaluation and ensures all expressions are well-typed. Remote imports are fetched over HTTPS and can be pinned to a specific hash for reproducibility.
Self-Hosting & Configuration
- Install the dhall binary and format-specific tools (dhall-to-json, dhall-to-yaml) via Homebrew or GitHub releases
- Bindings and integrations are available for Haskell, Rust, Go, Kotlin, Ruby, and Python
- Use the Dhall Prelude (a standard library) for common patterns like list manipulation and optional handling
- Pin remote imports with integrity checks: https://example.com/config.dhall sha256:abc123...
- IDE support via a Language Server Protocol implementation for VS Code and other editors
Key Features
- Guaranteed termination prevents runaway evaluation of configuration code
- Strong static type system catches typos, missing fields, and type mismatches before deployment
- Functions and imports enable shared, reusable configuration modules
- Integrity-checked remote imports make configuration composable across repositories
- Standard formatting tool (dhall format) ensures consistent style
Comparison with Similar Tools
- Jsonnet — Turing-complete templating; Dhall guarantees termination and has stronger types
- CUE — constraint-based config language; Dhall uses functions and types rather than unification
- Pkl — Apple's config language; Dhall predates it and provides formal termination guarantees
- HCL (Terraform) — domain-specific for IaC; Dhall is a general-purpose config language
- YAML with anchors — limited reuse via anchors; Dhall offers full functions and type checking
FAQ
Q: Why does termination matter for configuration? A: It means you can safely evaluate Dhall config from any source without risking an infinite loop. CI/CD pipelines and build systems benefit from this guarantee.
Q: Can Dhall replace Helm charts? A: Yes. The dhall-kubernetes project provides typed Kubernetes resource definitions that generate YAML manifests.
Q: Is Dhall Turing-complete? A: No, by design. It trades general recursion for the guarantee that every expression finishes evaluating.
Q: How do I start if my project uses JSON/YAML today? A: Use dhall-to-json or dhall-to-yaml to output your existing formats. You can migrate incrementally by replacing one config file at a time.