Source file expander_intf.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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
open! Ppxlib
open! Stdppx

type ('context, 'output) t =
  'context -> location -> type_name:string -> params:core_type list -> 'output

type parts =
  { pattern : pattern
  ; expression : expression
  ; type_ : core_type
  }

module type X = sig
  type ('a, 'b) expander := ('a, 'b) t
  type t

  val boxed : (t, parts) expander
  val unboxed : (t, parts) expander
end

module type S = sig
  type ('a, 'b) expander := ('a, 'b) t
  type t

  val structure_items : portable:bool -> (t, structure_item list) expander
  val signature_items : portable:bool -> (t, signature_item list) expander
end

module type Expander = sig
  type nonrec ('a, 'b) t = ('a, 'b) t
  type nonrec parts = parts

  module type S = S

  (** [value_name prefix ~type_name] is the value name generated by [[@@deriving box]] for
      a value with basename [prefix] on [type_name], including any ppx_template suffix.

      For example, [value_name "box" ~type_name:"foo__local"] is ["box_foo__local"], while
      [value_name "box" ~type_name:"t__local"] is ["box__local"]. *)
  val value_name : string -> type_name:string -> string

  module Make : functor (X : X) -> S with type t = X.t
end