HORIZON HASKELLDocslts/ghc-9.14.xd82dee82026-10-12Search names, modules, packages, or :: a typeCtrl K

GHC 9.14.1 · lts/ghc-9.14.x · d82dee8 · 2026-10-12

Modulecuddle-1.8.1.0GHC2021

Codec.CBOR.Cuddle.CDDL

This module defined the data structure of CDDL as specified in https://datatracker.ietf.org/doc/rfc8610/

  • 24 types
  • 1 class
  • 8 values
  • Packagecuddle-1.8.1.0
  • Exports38
  • LanguageGHC2021
  • LicenceApache-2.0
  • SourceCDDL.hs
datadata CDDL i
#

The CDDL constructor takes three arguments: 1. Top level comments that precede the first definition 2. The root definition 3. All the other top level comments and definitions This ensures that CDDL is correct by construction.

Constructors

Instances6IndexMappable, Eq, Show, Generic, Pretty, Rep
datadata TopLevel i
#
Instances6IndexMappable, Eq, Show, Generic, Pretty, Rep
newtypenewtype Name
#

A name can consist of any of the characters from the set {A to Z, "a" to "z", "0" to "9", "_", "-", "", ".", "$"}, starting with an alphabetic character (including "", "_", "$") and ending in such a character or a digit.

  • Names are case sensitive.

  • It is preferred style to start a name with a lowercase letter.

  • The hyphen is preferred over the underscore (except in a "bareword" (Section 3.5.1), where the semantics may actually require an underscore).

  • The period may be useful for larger specifications, to express some module structure (as in "tcp.throughput" vs. "udp.throughput").

  • A number of names are predefined in the CDDL prelude, as listed in Appendix D.

  • Rule names (types or groups) do not appear in the actual CBOR encoding, but names used as "barewords" in member keys do.

Constructors

Instances19Eq, Ord, Show, IsString, Generic, Semigroup, …
  • Eq NameDefined in cuddle-1.8.1.0 · Codec.CBOR.Cuddle.CDDL
  • Ord NameDefined in cuddle-1.8.1.0 · Codec.CBOR.Cuddle.CDDL
  • Show NameDefined in cuddle-1.8.1.0 · Codec.CBOR.Cuddle.CDDL
  • IsString NameDefined in cuddle-1.8.1.0 · Codec.CBOR.Cuddle.CDDL
  • Generic NameDefined in cuddle-1.8.1.0 · Codec.CBOR.Cuddle.CDDL
  • Semigroup NameDefined in cuddle-1.8.1.0 · Codec.CBOR.Cuddle.CDDL
  • Monoid NameDefined in cuddle-1.8.1.0 · Codec.CBOR.Cuddle.CDDL
  • Pretty NameDefined in cuddle-1.8.1.0 · Codec.CBOR.Cuddle.Pretty · orphan
  • Hashable NameDefined in cuddle-1.8.1.0 · Codec.CBOR.Cuddle.CDDL
  • HasName NameDefined in cuddle-1.8.1.0 · Codec.CBOR.Cuddle.CDDL
  • CollectComments NameDefined in cuddle-1.8.1.0 · Codec.CBOR.Cuddle.CDDL
  • HasSource "synth" MonoState MonoMDefined in cuddle-1.8.1.0 · Codec.CBOR.Cuddle.CDDL.Resolve
  • HasState "synth" MonoState MonoMDefined in cuddle-1.8.1.0 · Codec.CBOR.Cuddle.CDDL.Resolve
  • HasSink "synth" MonoState MonoMDefined in cuddle-1.8.1.0 · Codec.CBOR.Cuddle.CDDL.Resolve
  • HasReader "global" (Map Name (ProvidedParameters (CTree DistReferenced))) MonoMDefined in cuddle-1.8.1.0 · Codec.CBOR.Cuddle.CDDL.Resolve
  • HasReader "local" (Map Name (CTree MonoReferenced)) MonoMDefined in cuddle-1.8.1.0 · Codec.CBOR.Cuddle.CDDL.Resolve
  • HasSource "global" (Map Name (ProvidedParameters (CTree DistReferenced))) MonoMDefined in cuddle-1.8.1.0 · Codec.CBOR.Cuddle.CDDL.Resolve
  • HasSource "local" (Map Name (CTree MonoReferenced)) MonoMDefined in cuddle-1.8.1.0 · Codec.CBOR.Cuddle.CDDL.Resolve
  • type Rep Name = D1 ('MetaData "Name" "Codec.CBOR.Cuddle.CDDL" "cuddle-1.8.1.0-1n67ahaIhMs3FQkr3b5WBN" 'True) (C1 ('MetaCons "Name" 'PrefixI 'True) (S1 ('MetaSel ('Just "unName") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)))Defined in cuddle-1.8.1.0 · Codec.CBOR.Cuddle.CDDL
datadata Rule i
#

rule = typename [genericparm] S assignt S type / groupname [genericparm] S assigng S grpent

typename = id groupname = id

A rule defines a name for a type expression (production "type") or for a group expression (production "grpent"), with the intention that the semantics does not change when the name is replaced by its (parenthesized if needed) definition. Note that whether the name defined by a rule stands for a type or a group isn't always determined by syntax alone: e.g., "a = b" can make "a" a type if "b" is a type, or a group if "b" is a group. More subtly, in "a = (b)", "a" may be used as a type if "b" is a type, or as a group both when "b" is a group and when "b" is a type (a good convention to make the latter case stand out to the human reader is to write "a = (b,)"). (Note that the same dual meaning of parentheses applies within an expression but often can be resolved by the context of the parenthesized expression. On the more general point, it may not be clear immediately either whether "b" stands for a group or a type -- this semantic processing may need to span several levels of rule definitions before a determination can be made.)

Instances7IndexMappable, Eq, Show, Generic, Pretty, HasComment, …
datadata TypeOrGroup i
#

Constructors

Instances6IndexMappable, Eq, Show, Generic, CollectComments, Rep
datadata Assign
#

assignt = "=" "=" assigng = "=" "/="

A plain equals sign defines the rule name as the equivalent of the expression to the right; it is an error if the name was already defined with a different expression. A "=" or "/=" extends a named type or a group by additional choices; a number of these could be replaced by collecting all the right-hand sides and creating a single rule with a type choice or a group choice built from the right-hand sides in the order of the rules given. (It is not an error to extend a rule name that has not yet been defined; this makes the right-hand side the first entry in the choice being created.)

Instances4Eq, Show, Generic, Rep
newtypenewtype GenericArg i
#

Constructors

Instances8IndexMappable, Eq, Show, Generic, Semigroup, Pretty, …
newtypenewtype GenericParameters i
#

Generics

Using angle brackets, the left-hand side of a rule can add formal parameters after the name being defined, as in:

messages = message"now" / message1..100 messagev = {type: t, value: v}

When using a generic rule, the formal parameters are bound to the actual arguments supplied (also using angle brackets), within the scope of the generic rule (as if there were a rule of the form parameter = argument).

Generic rules can be used for establishing names for both types and groups.

Instances7IndexMappable, Eq, Show, Generic, Semigroup, Pretty, …
datadata GenericParameter i
#
Instances8IndexMappable, Eq, Show, Generic, Pretty, CollectComments, …
newtypenewtype Type0 i
#

A type can be given as a choice between one or more types. The choice matches a data item if the data item matches any one of the types given in the choice.

Constructors

Instances8IndexMappable, Eq, Show, Generic, Semigroup, Pretty, …
datadata Type1 i
#

Two types can be combined with a range operator (see below)

Constructors

Instances8IndexMappable, Eq, Show, Generic, Pretty, CollectComments, …
datadata Type2 i
#

Constructors

  • T2Value Value

    A type can be just a single value (such as 1 or "icecream" or h'0815'), which matches only a data item with that specific value (no conversions defined),

  • T2Name Name (Maybe (GenericArg i))

    or be defined by a rule giving a meaning to a name (possibly after supplying generic arguments as required by the generic parameters)

  • T2Group (Type0 i)

    or be defined in a parenthesized type expression (parentheses may be necessary to override some operator precedence),

  • T2Map (Group i)

    a map expression, which matches a valid CBOR map the key/value pairs of which can be ordered in such a way that the resulting sequence matches the group expression, or

  • T2Array (Group i)

    an array expression, which matches a CBOR array the elements of which when taken as values and complemented by a wildcard (matches anything) key each -- match the group, or

  • T2Unwrapped Name (Maybe (GenericArg i))

    an "unwrapped" group (see Section 3.7), which matches the group inside a type defined as a map or an array by wrapping the group, or

  • T2Enum (Group i)

    an enumeration expression, which matches any value that is within the set of values that the values of the group given can take, or

  • T2EnumRef Name (Maybe (GenericArg i))
  • T2Tag (Maybe Word64) (Type0 i)

    a tagged data item, tagged with the "uint" given and containing the type given as the tagged value, or

  • T2DataItem Word8 (Maybe Word64)

    a data item of a major type (given by the DIGIT), optionally constrained to the additional information given by the uint, or

  • T2Any

    Any data item

  • XXType2 (XXType2 i)
Instances7IndexMappable, Eq, Show, Generic, Pretty, CollectComments, …
datadata TyOp
#
Instances5Eq, Show, Generic, Pretty, Rep
datadata RangeBound
#

A range operator can be used to join two type expressions that stand for either two integer values or two floating-point values; it matches any value that is between the two values, where the first value is always included in the matching set and the second value is included for ".." and excluded for "...".

Instances5Eq, Show, Generic, Hashable, Rep
datadata OccurrenceIndicator
#

An optional _occurrence_ indicator can be given in front of a group entry. It is either (1) one of the characters "?" (optional), "*" (zero or more), or "+" (one or more) or (2) of the form n*m, where n and m are optional unsigned integers and n is the lower limit (default 0) and m is the upper limit (default no limit) of occurrences.

If no occurrence indicator is specified, the group entry is to occur exactly once (as if 1*1 were specified). A group entry with an occurrence indicator matches sequences of name/value pairs that are composed by concatenating a number of sequences that the basic group entry matches, where the number needs to be allowed by the occurrence indicator.

Instances6Eq, Show, Generic, Pretty, Hashable, Rep
newtypenewtype Group i
#

A group matches any sequence of key/value pairs that matches any of the choices given (again using PEG semantics).

Constructors

Instances8IndexMappable, Eq, Show, Generic, Semigroup, CollectComments, …
datadata GroupEntry i
#

A group entry can be given by a value type, which needs to be matched by the value part of a single element; and, optionally, a memberkey type, which needs to be matched by the key part of the element, if the memberkey is given. If the memberkey is not given, the entry can only be used for matching arrays, not for maps. (See below for how that is modified by the occurrence indicator.)

Instances8IndexMappable, Eq, Show, Generic, Pretty, CollectComments, …
datadata GroupEntryVariant i
#
Instances6IndexMappable, Eq, Show, Generic, CollectComments, Rep
datadata MemberKey i
#

Key types can be given by a type expression, a bareword (which stands for a type that just contains a string value created from this bareword), or a value (which stands for a type that just contains this value). A key value matches its key type if the key value is a member of the key type, unless a cut preceding it in the group applies (see Section 3.5.4 for how map matching is influenced by the presence of the cuts denoted by "^" or ":" in previous entries).

Instances6IndexMappable, Eq, Show, Generic, Pretty, Rep
datadata Value
#
Instances8Eq, Show, Generic, Pretty, Hashable, Default, …
datadata ValueVariant
#
Instances8Eq, Show, Generic, Pretty, Hashable, Default, …
datadata GrpChoice i
#
Instances7IndexMappable, Eq, Show, Generic, CollectComments, HasComment, …
classclass HasName a where
#

Methods

Instances6HasName
  • HasName NameDefined in cuddle-1.8.1.0 · Codec.CBOR.Cuddle.CDDL
  • HasName AnyRefDefined in cuddle-1.8.1.0 · Codec.CBOR.Cuddle.Huddle
  • HasName GRuleDefDefined in cuddle-1.8.1.0 · Codec.CBOR.Cuddle.Huddle
  • HasName GroupDefDefined in cuddle-1.8.1.0 · Codec.CBOR.Cuddle.Huddle
  • HasName HuddleItemDefined in cuddle-1.8.1.0 · Codec.CBOR.Cuddle.Huddle
  • HasName RuleDefined in cuddle-1.8.1.0 · Codec.CBOR.Cuddle.Huddle
newtypenewtype GRef
#

A reference to a generic parameter inside the body of a generic rule.

Constructors

Instances6Show, IsType0, IsChoosable, IsConstrainable, IsCborable, IsComparable
  • Show GRefDefined in cuddle-1.8.1.0 · Codec.CBOR.Cuddle.CDDL
  • IsType0 GRefDefined in cuddle-1.8.1.0 · Codec.CBOR.Cuddle.Huddle
  • IsChoosable GRef Type2Defined in cuddle-1.8.1.0 · Codec.CBOR.Cuddle.Huddle
  • IsConstrainable GRef CGRefTypeDefined in cuddle-1.8.1.0 · Codec.CBOR.Cuddle.Huddle
  • IsCborable GRefDefined in cuddle-1.8.1.0 · Codec.CBOR.Cuddle.Huddle
  • IsComparable GRefDefined in cuddle-1.8.1.0 · Codec.CBOR.Cuddle.Huddle
data familydata family XCddl i
#
Instances32IndexMappable, Eq, Ord, Show, Generic, Semigroup, …
data familydata family XTerm i
#
Instances39IndexMappable, Eq, Ord, Show, IsString, Generic, …
data familydata family XRule i
#
Instances31IndexMappable, Eq, Show, Generic, Semigroup, Monoid, …
data familydata family XXTopLevel i
#
Instances28IndexMappable, Eq, Ord, Show, Generic, Semigroup, …
data familydata family XXType2 i
#
Instances30IndexMappable, Eq, Ord, Show, Generic, Semigroup, …