https://github.com/input-output-hk/cuddle
CDDL DSL and Testing Tools
https://github.com/input-output-hk/cuddle
cbor cddl
Last synced: 9 months ago
JSON representation
CDDL DSL and Testing Tools
- Host: GitHub
- URL: https://github.com/input-output-hk/cuddle
- Owner: input-output-hk
- License: apache-2.0
- Created: 2023-09-29T14:03:43.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2025-10-01T14:03:23.000Z (9 months ago)
- Last Synced: 2025-10-01T16:08:21.042Z (9 months ago)
- Topics: cbor, cddl
- Language: Haskell
- Homepage:
- Size: 419 KB
- Stars: 6
- Watchers: 4
- Forks: 4
- Open Issues: 22
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
Cuddle
Cuddle is a library for generating and manipulating [CDDL](https://datatracker.ietf.org/doc/html/rfc8610).
## Supported features
Cuddle currently supports the following CDDL features:
- Groups
- Values
- Choices
- Maps
- Structs
- Tables
- Predefined CDDL types
- Tags
- Unwrapping
- Sockets/plugs
- Generics
### Partial support
- Representation types
- Representation types are correctly parsed and formatted, but only certain
types are understood in CBOR generation.
- Cuts
- Cut syntax is parsed and formatted, but ignored for CBOR generation.
- Controls
- Controls are correctly parsed and formatted, but only certain controls are
understood in CBOR generation.
- Operator precedence
- Comments
- Comments are currently stripped during formatting.
### Unsupported
- Escaping in bytestrings
## The cuddle tool
Included in this package is a command line tool for working with CDDL files. It
currently supports four functions:
- Formatting of CDDL files
- Validating that a CDDL file is legal
- Generating random CBOR terms matching CDDL productions
- Testing compliance of a CBOR file against a CDDL spec.
# Huddle
One of the principal features of Cuddle is the ability to define your CDDL in a
Haskell DSL, called Huddle. This offers the following benefits:
- Ability to use Haskell's abstraction facilities to define more complex CDDL
constructions.
- Some measure of compile-time safety for your CDDL. Attempting to reference
an undefined identifier will be a compile-time error, for example.
- The ability to modularise your configuration. CDDL lacks any real facility
for splitting a CDDL spec amongst multiple files. We solve this instead using
Haskell's module system.
Obviously, this comes with the downside of needing to sensibly mesh the
different abstraction facilities offered by Haskell and CDDL. We have tried to
find a balance where the Huddle code roughly matches the CDDL but gains many
of the advantages of writing in Haskell.
[A guide to writing Huddle](docs/huddle.md) goes into more details.