| 1 | open Ppxlib |
| 2 | |
| 3 | module type Attrs = sig |
| 4 | val ignore_label_declaration : (label_declaration, unit) Attribute.t |
| 5 | val ignore_core_type : (core_type, unit) Attribute.t |
| 6 | end |
| 7 | |
| 8 | module type S = sig |
| 9 | (** [type_ ~with_local ~hide ty] is [ty -> ty -> result_type] where [result_type] |
| 10 | is [int] for [compare] and [bool] for [equal]. |
| 11 | |
| 12 | [hide] controls whether some [[@merlin.hide]] attributes should be added. |
| 13 | |
| 14 | [with_local] adds local_ annotation around the input types. |
| 15 | *) |
| 16 | val type_ : with_local:bool -> hide:bool -> loc:Location.t -> core_type -> core_type |
| 17 | |
| 18 | (** [core_type ~with_local ty] is an expression of type [ty -> ty -> result_type] |
| 19 | |
| 20 | [~with_local:true] will make the arguments local *) |
| 21 | val core_type : with_local:bool -> core_type -> expression |
| 22 | |
| 23 | (** In [str_type_decl] and [sig_type_decl], passing [true] for the third argument |
| 24 | generates additional functions that take local arguments. We generate, e.g. |
| 25 | [val compare__local : local_ t -> local_ t -> int] in addition to [compare] |
| 26 | in order to incrementally grow the portion of the tree which supports local |
| 27 | comparison. |
| 28 | |
| 29 | We need both [compare] and [compare__local] since neither has a stronger type than |
| 30 | the other. In the case of polymorphic types, this is due to the fact that |
| 31 | [compare__local] requires local compare functions for each of its type arguments, |
| 32 | and in the case of monomorphic types, this is due to the possibility of partial |
| 33 | application producing a local closure. *) |
| 34 | |
| 35 | val str_type_decl |
| 36 | : ctxt:Expansion_context.Deriver.t |
| 37 | -> rec_flag * type_declaration list |
| 38 | -> bool (** [true] means generate a definition with local arguments *) |
| 39 | -> structure |
| 40 | |
| 41 | val sig_type_decl |
| 42 | : ctxt:Expansion_context.Deriver.t |
| 43 | -> rec_flag * type_declaration list |
| 44 | -> bool (** [true] means generate a signature with local arguments *) |
| 45 | -> signature |
| 46 | |
| 47 | module Attrs : Attrs |
| 48 | |
| 49 | val str_attributes : Attribute.packed list |
| 50 | end |