| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
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:
- First, we deal with any rule extensions and create a single map from identifiers to (potentially parametrised) entities.
- Second, we flatten the structure to a
CTree, which discards a lot of the extrenuous information. - 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.
- Finally, we monomorphise, synthesizing instances of rules with their generic arguments bound.
Synopsis
- buildResolvedCTree :: PartialCTreeRoot OrReferenced -> Either NameResolutionFailure (PartialCTreeRoot DistReferenced)
- buildRefCTree :: CDDLMap -> PartialCTreeRoot OrReferenced
- asMap :: CDDL CTreePhase -> CDDLMap
- buildMonoCTree :: PartialCTreeRoot DistReferenced -> Either NameResolutionFailure (CTreeRoot MonoReferenced)
- fullResolveCDDL :: CDDL CTreePhase -> Either NameResolutionFailure (CTreeRoot MonoReferenced)
- data NameResolutionFailure
- = UnboundReference Name
- | MismatchingArgs Name [Name]
- | ArgsToPostlude PTerm [CTree OrReferencedDropGen]
- data MonoReferenced
- data family XXCTree i
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.
fullResolveCDDL :: CDDL CTreePhase -> Either NameResolutionFailure (CTreeRoot MonoReferenced) Source #
data NameResolutionFailure Source #
Constructors
| UnboundReference Name | |
| MismatchingArgs Name [Name] | |
| ArgsToPostlude PTerm [CTree OrReferencedDropGen] |
Instances
| Show NameResolutionFailure Source # | |
Defined in Codec.CBOR.Cuddle.CDDL.Resolve Methods showsPrec :: Int -> NameResolutionFailure -> ShowS # show :: NameResolutionFailure -> String # showList :: [NameResolutionFailure] -> ShowS # | |
| Eq NameResolutionFailure Source # | |
Defined in Codec.CBOR.Cuddle.CDDL.Resolve Methods (==) :: NameResolutionFailure -> NameResolutionFailure -> Bool # (/=) :: NameResolutionFailure -> NameResolutionFailure -> Bool # | |
data MonoReferenced Source #
Instances
| IndexMappable CTree MonoReferenced ValidatorStage Source # | |
Defined in Codec.CBOR.Cuddle.CBOR.Validator Methods mapIndex :: CTree MonoReferenced -> CTree ValidatorStage Source # | |
| IndexMappable CTreeRoot MonoReferenced ValidatorStage Source # | |
Defined in Codec.CBOR.Cuddle.CBOR.Validator Methods mapIndex :: CTreeRoot MonoReferenced -> CTreeRoot ValidatorStage Source # | |
| data XXCTree MonoReferenced Source # | |
Defined in Codec.CBOR.Cuddle.CDDL.Resolve | |
data family XXCTree i Source #
Instances
| Show (XXCTree ValidatorStage) Source # | |
Defined in Codec.CBOR.Cuddle.CBOR.Validator | |
| newtype XXCTree ValidatorStage Source # | |
Defined in Codec.CBOR.Cuddle.CBOR.Validator | |
| data XXCTree MonoReferenced Source # | |
Defined in Codec.CBOR.Cuddle.CDDL.Resolve | |