package ppxlib_jane

  1. Overview
  2. Docs

Mode_expr appears in several places:

  • let local_ x = ...
  • local_ exp
  • local string -> string
  • global_ x : int

Note that in the first two cases, axes other than locality are not specified; in the second case, other axes are defaulted to legacy. In the last case, we are specifying modalities.

In the future the three annotations will be quite different, but for now they are all lists of modes/modalities. Typemode has the three different interpretations of the annotation.

(TODO: in the future we will have mutable(...), which is similar to the second occurrence above and should be covered by this module)

module Const : sig ... end

Constant modes

type t = Const.t list Location.loc
val empty : t

The empty mode expression.

val singleton : Const.t -> t

The mode expression containing a single mode constant.

val extension_name : string

The string used to mark extensions as containing mode expressions.

val attribute_name : string

The string used to mark attributes as containing mode expressions.

Extract the mode attribute (if any) from a list of attributes; also returns the rest of the attributes; Raises if multiple relevant attributes are found

val attr_of : t -> Ppxlib_ast.Parsetree.attribute option

Encode a mode expression into a attribute. If the expression is safe to empty (and thus safe to ignore), returns None.

Given a list of attributes, extracts the mode expression and returns the rest of attributes. Raises if multiple relevant attributes are found. Raises if attributes encodes empty mode expression

val payload_of : t -> Ppxlib_ast.Parsetree.payload option

Encodes a mode expression into a payload. If the expression is safe to ignore (i.e. empty), returns None.

val of_payload : loc:Location.t -> Ppxlib_ast.Parsetree.payload -> t

Decode a mode expression from a payload whose location is loc. Raises if the payload encodes an empty mode expression.

val ghostify : t -> t

In some cases, a single mode expression appears twice in the parsetree; one of them needs to be made ghost to make our internal tools happy.

OCaml

Innovation. Community. Security.