@@ -7,12 +7,12 @@ defining CDDL in Huddle.
77
88## Core Types
99Huddle utilizes several core types to represent CDDL constructs:
10- ● Huddle: The top-level type representing a collection of rules.
11- ● HuddleItem: Represents individual items within a Huddle, such as rules, groups, or generic rules.
12- ● Rule: A named type definition.
13- ● Named: A type wrapper for associating a name, value, and optional description with an item.
14- ● Value: A type representing primitive CBOR values.
15- ● Group: Represents a collection of entries within a map or array.
10+ - Huddle: The top-level type representing a collection of rules.
11+ - HuddleItem: Represents individual items within a Huddle, such as rules, groups, or generic rules.
12+ - Rule: A named type definition.
13+ - Named: A type wrapper for associating a name, value, and optional description with an item.
14+ - Value: A type representing primitive CBOR values.
15+ - Group: Represents a collection of entries within a map or array.
1616
1717## Language Extensions
1818
@@ -39,16 +39,18 @@ In addition, if using hlint, we suggest disabling the following hints:
3939Rules are defined using the =:= operator. The left-hand side of the operator is
4040the rule name (a T.Text value), and the right-hand side is the type definition.
4141
42- ruleName =:= typeDefinition
42+ ` ruleName =:= typeDefinition `
4343
4444### Example:
45- ` age =:= VUInt `
45+ ``` haskell
46+ age =:= VUInt
47+ ```
4648
4749## Maps
4850Maps are defined using the mp function and the ==> operator to specify key-value
4951pairs.
5052
51- mapName =:= mp [ key1 ==> value1, key2 ==> value2 ]
53+ ` mapName =:= mp [ key1 ==> value1, key2 ==> value2 ] `
5254
5355### Example:
5456``` haskell
@@ -61,26 +63,35 @@ location =:= mp [
6163## Arrays
6264Arrays are defined using the arr function and the a function to indicate array elements.
6365
64- arrayName =:= arr [ a element1, a element2 ]
66+ ` arrayName =:= arr [ a element1, a element2 ] `
6567
6668### Example:
69+ ``` haskell
6770point =:= arr [ a int, a int ]
71+ ```
72+
6873## Groups
6974Groups are collections of entries within maps or arrays. They can be named using
7075the =:~ operator.
7176
72- groupName =:~ grp [ entry1, entry2 ]
77+ ` groupName =:~ grp [ entry1, entry2 ] `
78+
7379### Example:
7480``` haskell
7581personalinfo =:~ grp [
7682 " name" ==> tstr,
7783 " age" ==> uint
7884]
7985```
86+
8087## Choices
88+
8189Huddle represents choices between types using the / operator.
90+
8291### Example:
92+ ``` haskell
8393value =:= int / tstr
94+ ```
8495
8596Huddle does not have a direct equivalent for the CDDL // operator (group
8697choice). Instead, choices within arrays are represented by creating separate
@@ -96,9 +107,9 @@ choice =:= optionA / optionB
96107## Quantifiers
97108Huddle provides functions to specify occurrence quantifiers for group entries
98109and array elements:
99- ● <+ : Lower bound
100- ● +> : Upper bound
101- ● opt: Optional (0 or 1 occurrences)
110+ - ` <+ ` : Lower bound
111+ - ` +> ` : Upper bound
112+ - ` opt ` : Optional (0 or 1 occurrences)
102113
103114### Example:
104115``` haskell
@@ -112,7 +123,7 @@ which will be included as comments in the generated CDDL.
112123### Example:
113124``` haskell
114125person =:= comment " Represents a person" $ mp [
115- comment " Person's name" $ " name " ==> VBytes ,
126+ " name" ==> VBytes & comment " Person's name " ,
116127 " age" ==> VUIntf
117128]
118129```
@@ -129,11 +140,11 @@ message = binding $ \t -> "message" =:= {
129140```
130141
131142## Converting to CDDL
132- The toCDDL and toCDDLNoRoot functions convert a Huddle definition to CDDL.
133- toCDDL generates a top-level root element, while toCDDLNoRoot skips the root
143+ The ` toCDDL ` and ` toCDDLNoRoot ` functions convert a Huddle definition to CDDL.
144+ ` toCDDL ` generates a top-level root element, while ` toCDDLNoRoot ` skips the root
134145element.
135146
136147## Example File (Conway.hs)
137- The Conway.hs example file showcases a practical application of Huddle to define
138- the CDDL for a specific data structure. The file defines numerous rules and
139- groups using the Huddle syntax and functions described above.
148+ The ` Conway.hs ` example file showcases a practical application of Huddle to
149+ define the CDDL for a specific data structure. The file defines numerous rules
150+ and groups using the Huddle syntax and functions described above.
0 commit comments