Skip to content

input-output-hk/cuddle

Repository files navigation

Cuddle

Cuddle is a library for generating and manipulating CDDL.

GitHub Workflow Status (master)

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 three functions:

  • Formatting of CDDL files
  • Validating that a CDDL file is legal
  • Generating random CBOR terms matching CDDL productions.

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 goes into more details.

Releases

No releases published

Languages