Module Modes.At_locality

Abstract over whether a value is local or global.

module type Without_crossing = sig ... end

Abstract over whether a value is local or global.

module type At_locality = sig ... end
include At_locality
type actually_local

Phantom type parameter for t representing that the inhabitant may be local. This type does not cross locality to enforce the relationship between mode-crossing and phantom types in the with clauses on type t below.

type global = [
  1. | `global
]

Phantom type parameter for t which represents that the inhabitant is known to be global.

type local = [
  1. | `global
  2. | `local of actually_local
]

Phantom type parameter for t which represents that the locality of the inhabitant is unknown, and so must be assumed to be local.

type (+'a, +'locality) t

Abstract over whether a value is global or local, with zero runtime cost, supporting mode crossing locality in the global case

('a, global) t represents a 'a that is known to be global. This type importantly mode-crosses along the locality axis, even if 'a usually does not.

('a, local) t represents a 'a whose locality is unknown. This type does not mode-cross along the locality axis, even if 'a usually does.

val compare_local : local -> local -> int
val compare_local__local : local @ local -> (local @ local -> int) @ local
val equal_local : local -> local -> bool
val equal_local__local : local @ local -> (local @ local -> bool) @ local
val sexp_of_local : local -> Sexplib0.Sexp.t
val local_sexp_grammar : local Sexplib0.Sexp_grammar.t @@ portable
val compare_global : global -> global -> int
val compare_global__local : global @ local -> (global @ local -> int) @ local
val equal_global : global -> global -> bool
val equal_global__local : global @ local -> (global @ local -> bool) @ local
val sexp_of_global : global -> Sexplib0.Sexp.t
val global_sexp_grammar : global Sexplib0.Sexp_grammar.t @@ portable
include Ppx_compare_lib.Comparable.S2 with type (+'a, 'locality) t := ('a, 'locality) t
val compare : ('a -> 'a -> int) -> ('b -> 'b -> int) -> ('a, 'b) t -> ('a, 'b) t -> int
include Ppx_compare_lib.Comparable.S2__local with type (+'a, 'locality) t := ('a, 'locality) t
include Ppx_compare_lib.Equal.S2 with type (+'a, 'locality) t := ('a, 'locality) t
val equal : ('a -> 'a -> bool) -> ('b -> 'b -> bool) -> ('a, 'b) t -> ('a, 'b) t -> bool
include Ppx_compare_lib.Equal.S2__local with type (+'a, 'locality) t := ('a, 'locality) t
include Ppx_hash_lib.Hashable.S2_any with type (+'a, 'locality) t := ('a, 'locality) t
val globalize : 'a 'locality. ('a @ local -> 'a) -> ('locality @ local -> 'locality) -> ('a, 'locality) t @ local -> ('a, 'locality) t
val sexp_of_t : ('a -> Sexplib0.Sexp.t) -> ('locality -> Sexplib0.Sexp.t) -> ('a, 'locality) t -> Sexplib0.Sexp.t
val t_sexp_grammar : 'a 'locality. 'a Sexplib0.Sexp_grammar.t -> 'locality Sexplib0.Sexp_grammar.t -> ('a, 'locality) t Sexplib0.Sexp_grammar.t @@ portable
val wrap : 'a -> ('a, _) t

Create a global wrapper. Can have any phantom type.

val unwrap : ('a, _) t -> 'a

Unwrap a global wrapper. When the wrapper is global, the contents are too.

val wrap_local : 'a @ local -> ('a, local) t @ local

Wrap local contents.

val unwrap_local : ('a, _) t @ local -> 'a @ local

Unwrap local contents. Global or local contents can be unwrapped as local.

val unwrap_global : ('a, global) t @ local -> 'a

Unwrap global contents.

val to_local : ('a, _) t @ local -> ('a, local) t @ local

Convert phantom type of a wrapper to local.

val to_global : ('a, _) t -> ('a, global) t

Convert phantom type of a global wrapper to global.

val globalize_global : ('a, global) t @ local -> ('a, global) t

Globalize a wrapper where the contents are already global.