Module Ocaml_parsing.Language_extension

Language extensions provided by the Jane Street version of the OCaml compiler.

type maturity = Ocaml_utils.Language_extension_kernel.maturity =
  1. | Stable
  2. | Beta
  3. | Alpha

A setting for extensions that track multiple maturity levels

module Maturity : sig ... end
type 'a t = 'a Ocaml_utils.Language_extension_kernel.t =
  1. | Comprehensions : unit t
  2. | Mode : maturity t
  3. | Unique : maturity t
  4. | Overwriting : unit t
  5. | Include_functor : unit t
  6. | Polymorphic_parameters : unit t
  7. | Immutable_arrays : unit t
  8. | Module_strengthening : unit t
  9. | Layouts : maturity t
  10. | SIMD : maturity t
  11. | Labeled_tuples : unit t
  12. | Small_numbers : maturity t
  13. | Instances : unit t
  14. | Separability : unit t
  15. | Let_mutable : unit t
  16. | Layout_poly : maturity t
  17. | Runtime_metaprogramming : unit t

The type of language extensions. An 'a t is an extension that can either be off or be set to have any value in 'a, so a unit t can be either on or off, while a maturity t can have different maturity settings.

val assert_enabled : loc:Location.t -> 'a t -> 'a -> unit

Require that an extension is enabled for at least the provided level, or else throw an exception at the provided location saying otherwise.

val maturity_of_unique_for_drf : maturity
val maturity_of_unique_for_destruction : maturity
module Exist : sig ... end

Existentially packed language extension

val equal : 'a t -> 'b t -> bool

Equality on language extensions

module Universe : sig ... end

The type of language extension universes. Each universe allows a set of extensions, and every successive universe includes the previous one.

val disable_all : unit -> unit

Disable all extensions

val is_erasable : 'a 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.

val to_string : 'a t -> string

Print and parse language extensions; parsing is case-insensitive

val to_command_line_string : 'a t -> 'a -> string
val of_string : string -> Exist.t option
val maturity_to_string : maturity -> string
val get_command_line_string_if_enabled : 'a t -> string option

Get the command line string enabling the given extension, if it's enabled; otherwise None

val enable_of_string_exn : string -> unit

Enable and disable according to command-line strings; these raise an exception if the input string is invalid.

val disable_of_string_exn : string -> unit
val set : unit t -> enabled:bool -> unit

Enable and disable language extensions; these operations are idempotent

val enable : 'a t -> 'a -> unit
val disable : 'a t -> unit
val is_enabled : 'a t -> bool

Check if a language extension is currently enabled (at any maturity level)

val is_at_least : 'a t -> 'a -> bool

Check if a language extension is enabled at least at the given level

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

Tooling support: Temporarily enable and disable language extensions; these operations are idempotent. Calls to set, enable, disable 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.

val with_enabled : 'a t -> 'a -> (unit -> unit) -> unit
val with_disabled : 'a t -> (unit -> unit) -> unit
val erasable_extensions_only : unit -> bool

Check if the allowable extensions are restricted to only those that are "erasable". This is true when the universe is set to No_extensions or Upstream_compatible.

val set_universe_and_enable_all : Universe.t -> unit

Set the extension universe and enable all allowed extensions.

val set_universe_and_enable_all_of_string_exn : string -> unit

Parse a command-line string and call set_universe_and_enable_all. Raises if the argument is invalid.