Skip to content

Commit 866df0a

Browse files
committed
Add a section documenting anti-quotation for patterns to README
1 parent 68041f7 commit 866df0a

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,3 +143,19 @@ let f = function
143143
| `Assoc [("b", `Bool true); ("a", `Int 1)]
144144
) -> (1, true)
145145
```
146+
147+
#### Anti-quotation
148+
149+
You can also escape regular `Yojson` patterns in `ppx_yojson` pattern extensions' payload
150+
using `[%y? json_pat]`. You can use it to further deconstruct a `Yojson` value. For example:
151+
152+
```ocaml
153+
let f = function
154+
| [%yojson? {a = [%y? `Int i]} -> i + 1
155+
```
156+
157+
is expanded into:
158+
```ocaml
159+
let f = function
160+
| `Assoc [("a", `Int i)] -> i + 1
161+
```

0 commit comments

Comments
 (0)