File: test.ml

package info (click to toggle)
ppxlib 0.37.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,804 kB
  • sloc: ml: 66,587; sh: 103; makefile: 40; python: 36
file content (23 lines) | stat: -rw-r--r-- 572 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
open Ppxlib

module B = Ast_builder.Make (struct
  let loc = !Ast_helper.default_loc
end)
[%%ignore]

(** Using multiple calls to [pexp_fun] still produces a maximum arity function
*)
let _ =
  let inner =
    B.pexp_fun Nolabel None
      (B.ppat_var { txt = "y"; loc = B.loc })
      (B.pexp_apply (B.evar "Int.add")
         [ (Nolabel, B.evar "x"); (Nolabel, B.evar "y") ])
  in
  let e =
    B.pexp_fun Nolabel None (B.ppat_var { txt = "x"; loc = B.loc }) inner
  in
  Format.asprintf "%a" Pprintast.expression e
[%%expect{|
- : string = "fun x y -> Int.add x y"
|}]