Skip to content

Commit 9d6af78

Browse files
committed
Update README.md
1 parent 26cae83 commit 9d6af78

1 file changed

Lines changed: 23 additions & 2 deletions

File tree

README.md

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,30 @@ Add to `lakefile.lean`:
77
require binary from git "https://github.com/Lean-zh/binary.git"
88
```
99

10-
In file:
10+
## Deriving
11+
```lean
12+
import Binary
13+
14+
open Binary Primitive
1115
16+
open LE in
17+
@[bin_enum 4 [0, 2]]
18+
inductive A where
19+
| a -- 0
20+
| b (s : Int32) -- 2
21+
deriving Encode, Decode
22+
23+
open BE in
24+
structure B where
25+
s : Int32
26+
deriving Encode, Decode
27+
28+
#eval Put.run 128 (put (A.b 1234))
1229
```
30+
31+
## Serialization/Deserialization
32+
33+
```lean
1334
import Binary
1435
1536
open Binary Primitive.LE
@@ -20,7 +41,7 @@ Or open `Primitive.BE` when you want to handle data in big endian.
2041

2142
The recommended usage is
2243

23-
```
44+
```lean
2445
import Binary
2546
2647
open Binary Primitive

0 commit comments

Comments
 (0)