Skip to content

Commit 19a8100

Browse files
committed
Improve markup of huddle tutorial
1 parent c8546fc commit 19a8100

File tree

1 file changed

+25
-14
lines changed

1 file changed

+25
-14
lines changed

docs/huddle.md

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,18 @@ In addition, if using hlint, we suggest disabling the following hints:
3939
Rules are defined using the =:= operator. The left-hand side of the operator is
4040
the 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
4850
Maps are defined using the mp function and the ==> operator to specify key-value
4951
pairs.
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
6264
Arrays 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
6770
point =:= arr [ a int, a int ]
71+
```
72+
6873
## Groups
6974
Groups are collections of entries within maps or arrays. They can be named using
7075
the =:~ operator.
7176

72-
groupName =:~ grp [ entry1, entry2 ]
77+
`groupName =:~ grp [ entry1, entry2 ]`
78+
7379
### Example:
7480
```haskell
7581
personalinfo =:~ grp [
7682
"name" ==> tstr,
7783
"age" ==> uint
7884
]
7985
```
86+
8087
## Choices
88+
8189
Huddle represents choices between types using the / operator.
90+
8291
### Example:
92+
```haskell
8393
value =:= int / tstr
94+
```
8495

8596
Huddle does not have a direct equivalent for the CDDL // operator (group
8697
choice). Instead, choices within arrays are represented by creating separate
@@ -96,9 +107,9 @@ choice =:= optionA / optionB
96107
## Quantifiers
97108
Huddle provides functions to specify occurrence quantifiers for group entries
98109
and 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
114125
person =:= 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
134145
element.
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

Comments
 (0)