File: quoter.mli

package info (click to toggle)
ppxlib 0.15.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid
  • size: 1,284 kB
  • sloc: ml: 17,184; sh: 149; makefile: 36; python: 36
file content (23 lines) | stat: -rw-r--r-- 806 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
(** Generate expressions in a hygienic way.

    The idea is that whenever we want to refer to an expression in
    generated code we first quote it. The result will be an identifier
    that is guaranteed to refer to the expression it was created
    from. This way it is impossible for quoted fragments to refer to
    newly introduced expressions. *)

open Import

type t

val create : unit -> t
(** Creates a quoter. A quoter guarantees to give names that do not clash with
    any other names used before *)

val quote : t -> expression -> expression
(** [quote t e] returns the expression that is safe to use in place of [e] in
    generated code*)

val sanitize : t -> expression -> expression
(** [sanitize t e] Returns [e] wrapped with bindings for all quoted expressions
    in the quoter [t] *)