package ppxlib_jane

  1. Overview
  2. Docs

Module Jane_syntax.Mode_exprSource

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)

Sourcemodule Const : sig ... end

Constant modes

Sourceval empty : t

The empty mode expression.

Sourceval singleton : Const.t -> t

The mode expression containing a single mode constant.

Sourceval extension_name : string

The string used to mark extensions as containing mode expressions.

Sourceval attribute_name : string

The string used to mark attributes as containing mode expressions.

Sourceval extract_attr : Ppxlib_jane__.Shadow_compiler_distribution.Parsetree.attributes -> Ppxlib_jane__.Shadow_compiler_distribution.Parsetree.attribute option * Ppxlib_jane__.Shadow_compiler_distribution.Parsetree.attributes

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

Sourceval attr_of : t -> Ppxlib_jane__.Shadow_compiler_distribution.Parsetree.attribute option

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

Sourceval maybe_of_attrs : Ppxlib_jane__.Shadow_compiler_distribution.Parsetree.attributes -> t option * Ppxlib_jane__.Shadow_compiler_distribution.Parsetree.attributes

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

Sourceval of_attrs : Ppxlib_jane__.Shadow_compiler_distribution.Parsetree.attributes -> t * Ppxlib_jane__.Shadow_compiler_distribution.Parsetree.attributes
Sourceval payload_of : t -> Ppxlib_jane__.Shadow_compiler_distribution.Parsetree.payload option

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

Sourceval of_payload : loc:Location.t -> Ppxlib_jane__.Shadow_compiler_distribution.Parsetree.payload -> t

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

Sourceval 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.