Skip to content

Conversation

nc6
Copy link
Collaborator

@nc6 nc6 commented Jan 4, 2024

Adds CDDL resolution and CBOR generation

nc6 added 5 commits January 4, 2024 11:26
This makes it much easier to use for testing.
Though at the moment we don't use them, this should make it easier to
support in future.
This commit does a number of things related to "compiling" the parsed
CDDL into something easier to work with for the purposes of CBOR
generation and validation:

- Introduce the 'CTree' abstration in
  src/Codec/CBOR/Cuddle/CDDL/CTree.hs. This is a flattened, simplified
  structure which we use to represent CDDL in an easier-to-manipulate
  fashion.
- Introduce in src/Codec/CBOR/Cuddle/CDDL/Resolve.hs various compilation
  passes which implement:
  - Merging assignments
  - Building a CTree
  - Resolving the Postlude
  - Monomorphisation

In addition, we make a few unrelated changes:

- Move the 'Postlude' module to sit in CDDL/Postlude.
- Format the cabal file with cabal-fmt.
This commit adds support for generating CBOR terms corresponding to a
given CDDL file.

Needs better support for errors, and not all CDDL features are yet
supported.
@nc6 nc6 merged commit a62969a into master Jan 4, 2024
@nc6 nc6 deleted the nc/gen2 branch January 4, 2024 10:46
nc6 added a commit that referenced this pull request Feb 14, 2024
We allow Haskell functions to be used as generic
rules by implementing the `binding` function.

Currently this is only implemented for one or two
generic parameters, but conceptually supports any
number.

Examples are provided both in the Conway.hs file
and in the tests. The generated CDDL for Conway
now looks like:

```
transaction_body = {0 : set<transaction_index>
                    , 1 : [* transaction_output]
                    , 2 : coin
                    , ? 3 : uint
                    , ? 4 : certificates
                    , ? 5 : withdrawals
                    , ? 7 : auxiliary_data_hash
                    , ? 8 : uint
                    , ? 9 : mint
                    , ? 11 : script_data_hash
                    , ? 13 : nonempty_set<transaction_input>
                    , ? 14 : required_signers
                    , ? 15 : network_id
                    , ? 16 : transaction_output
                    , ? 17 : coin
                    , ? 18 : nonempty_set<transaction_input>
                    , ? 19 : voting_procedures
                    , ? 20 : proposal_procedures
                    , ? 21 : coin
                    , ? 22 : positive_coin}
```

...

```
constr<a0> = #6.1([* a0])
              / #6.2([* a0])
              / #6.3([* a0])
              / #6.4([* a0])
              / #6.5([* a0])
              / #6.6([* a0])
              / #6.7([* a0])
              / #6.2([uint, [* a0]])

nonempty_set<a0> = set<a0>

set<a0> = [* a0]
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant