jon.recoil.org

Module Parser_extended.Language_extensionSource

Language extensions provided by ocaml-jst

Sourcetype maturity =
  1. | Stable
  2. | Beta
  3. | Alpha
Sourcetype t =
  1. | Comprehensions
  2. | Local
  3. | Include_functor
  4. | Polymorphic_parameters
  5. | Immutable_arrays
  6. | Module_strengthening
  7. | Layouts of maturity

The type of language extensions

Sourceval equal : t -> t -> bool

Equality on language extensions

Sourceval all : t list

A list of all possible language extensions

Sourceval max_compatible : t list

A maximal list of compatible language extensions (of the layouts extensions, "layouts_alpha" is selected).

Sourceval is_erasable : t -> bool

Check if a language extension is "erasable", i.e. whether it can be harmlessly translated to attributes and compiled with the upstream compiler.

Sourceval to_string : t -> string

Print and parse language extensions; parsing is case-insensitive

Sourceval of_string : string -> t option
Sourceval of_string_exn : string -> t
Sourceval set : t -> enabled:bool -> unit

Enable and disable language extensions; these operations are idempotent

Sourceval enable : t -> unit
Sourceval disable : t -> unit
Sourceval is_enabled : t -> bool

Check if a language extension is currently enabled

Sourceval with_set : t -> enabled:bool -> (unit -> unit) -> unit

Tooling support: Temporarily enable and disable language extensions; these operations are idempotent. Calls to set, enable, disable, and disallow_extensions inside the body of the function argument will also be rolled back when the function finishes, but this behavior may change; nest multiple with_* functions instead.

Sourceval with_enabled : t -> (unit -> unit) -> unit
Sourceval with_disabled : t -> (unit -> unit) -> unit
Sourceval restrict_to_erasable_extensions : unit -> unit

Permanently restrict the allowable extensions to those that are "erasable", i.e. those that can be harmlessly translated to attributes and compiled with the upstream compiler. Used for -only-erasable-extensions to ensure that some code is guaranteed to be compatible with upstream OCaml after rewriting to attributes. When called, disables any currently-enabled non-erasable extensions, including any that are on by default. Causes any future uses of set ~enabled:true, enable, and their with_ variants to raise if used with a non-erasable extension. The is_enabled function will still work on any extensions, it will just always return false on non-erasable ones. Will raise if called after disallow_extensions; the ratchet of extension restriction only goes one way.

Sourceval disallow_extensions : unit -> unit

Permanently ban all extensions; used for -disable-all-extensions to ensure that some code is 100% extension-free. When called, disables any currently-enabled extensions, including the defaults. Causes any future uses of set ~enabled:true, enable, and their with_ variants to raise; also causes any future uses of only_erasable_extensions to raise. The is_enabled function will still work, it will just always return false.