package ppx_accessor

  1. Overview
  2. Docs

Source file common.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
open! Base
open! Import

let gen_symbol prefix ~loc =
  let sym = gen_symbol ~prefix () in
  pvar ~loc sym, evar ~loc sym
;;

let map_with_context list ~f =
  let rec loop prefix suffix acc =
    match suffix with
    | [] -> List.rev acc
    | x :: suffix ->
      loop (x :: prefix) suffix (f x ~context:(List.rev_append prefix suffix) :: acc)
  in
  loop [] list []
;;

let unsupported ~loc what =
  Location.raise_errorf
    ~loc
    "%s"
    (String.concat [ "ppx_accessor"; "unsupported"; what ] ~sep:": ")
;;
OCaml

Innovation. Community. Security.