|
| 1 | +<h1 align="center">Cuddle</h1> |
| 2 | + |
| 3 | +Cuddle is a library for generating and manipulating [CDDL](https://datatracker.ietf.org/doc/html/rfc8610). |
| 4 | + |
| 5 | +<p align="center"> |
| 6 | + <a href="https://github.com/input-output-hk/cuddle/actions/workflows/ci.yml"> |
| 7 | + <img alt="GitHub Workflow Status (master)" src="https://img.shields.io/github/actions/workflow/status/input-output-hk/cuddle/ci.yml?branch=master&style=for-the-badge" /> |
| 8 | + </a> |
| 9 | +</p> |
| 10 | + |
| 11 | +## Supported features |
| 12 | + |
| 13 | +Cuddle currently supports the following CDDL features: |
| 14 | + |
| 15 | +- Groups |
| 16 | +- Values |
| 17 | +- Choices |
| 18 | +- Maps |
| 19 | + - Structs |
| 20 | + - Tables |
| 21 | +- Predefined CDDL types |
| 22 | +- Tags |
| 23 | +- Unwrapping |
| 24 | +- Sockets/plugs |
| 25 | +- Generics |
| 26 | + |
| 27 | +### Partial support |
| 28 | + |
| 29 | +- Representation types |
| 30 | + - Representation types are correctly parsed and formatted, but only certain |
| 31 | + types are understood in CBOR generation. |
| 32 | +- Cuts |
| 33 | + - Cut syntax is parsed and formatted, but ignored for CBOR generation. |
| 34 | +- Controls |
| 35 | + - Controls are correctly parsed and formatted, but only certain controls are |
| 36 | + understood in CBOR generation. |
| 37 | +- Operator precedence |
| 38 | +- Comments |
| 39 | + - Comments are currently stripped during formatting. |
| 40 | + |
| 41 | +### Unsupported |
| 42 | + |
| 43 | +- Escaping in bytestrings |
| 44 | + |
| 45 | + |
| 46 | +## The cuddle tool |
| 47 | + |
| 48 | +Included in this package is a command line tool for working with CDDL files. It |
| 49 | +currently supports three functions: |
| 50 | + |
| 51 | +- Formatting of CDDL files |
| 52 | +- Validating that a CDDL file is legal |
| 53 | +- Generating random CBOR terms matching CDDL productions. |
| 54 | + |
| 55 | +# Huddle |
| 56 | + |
| 57 | +One of the principal features of Cuddle is the ability to define your CDDL in a |
| 58 | +Haskell DSL, called Huddle. This offers the following benefits: |
| 59 | + |
| 60 | +- Ability to use Haskell's abstraction facilities to define more complex CDDL |
| 61 | + constructions. |
| 62 | +- Some measure of compile-time safety for your CDDL. Attempting to reference |
| 63 | + an undefined identifier will be a compile-time error, for example. |
| 64 | +- The ability to modularise your configuration. CDDL lacks any real facility |
| 65 | + for splitting a CDDL spec amongst multiple files. We solve this instead using |
| 66 | + Haskell's module system. |
| 67 | + |
| 68 | +Obviously, this comes with the downside of needing to sensibly mesh the |
| 69 | +different abstraction facilities offered by Haskell and CDDL. We have tried to |
| 70 | +find a balance where the Huddle code roughly matches the CDDL but gains many |
| 71 | +of the advantages of writing in Haskell. |
0 commit comments