cuddle-1.1.0.0: CDDL Generator and test utilities
Safe HaskellNone
LanguageGHC2021

Codec.CBOR.Cuddle.CDDL.Resolve

Description

Module containing tools for resolving CDDL

Resolving the CDDL is a process of simplifying the representation to make further operations, such as CBOR generation or validation, easier. We operate with a number of passes:

  1. First, we deal with any rule extensions and create a single map from identifiers to (potentially parametrised) entities.
  2. Second, we flatten the structure to a CTree, which discards a lot of the extrenuous information.
  3. Then we resolve identifiers. Specifically, we do three things: - Resolve identifiers that map to the postlude. - Differentiate between generic args and references to top-level rules. - Validate that all references exist. Note that we cannot resolve all references since they may be circular.
  4. Finally, we monomorphise, synthesizing instances of rules with their generic arguments bound.
Synopsis

Documentation

buildResolvedCTree :: PartialCTreeRoot OrReferenced -> Either NameResolutionFailure (PartialCTreeRoot DistReferenced) Source #

buildRefCTree :: CDDLMap -> PartialCTreeRoot OrReferenced Source #

Build a CTree incorporating references.

This translation cannot fail.

asMap :: CDDL CTreePhase -> CDDLMap Source #

buildMonoCTree :: PartialCTreeRoot DistReferenced -> Either NameResolutionFailure (CTreeRoot MonoReferenced) Source #

Monomorphise the CTree

Concretely, for each reference in the tree to a generic rule, we synthesize a new monomorphic instance of that rule at top-level with the correct parameters applied.