package gel

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
type 'a t = {
  1. g : 'a;
}

A shim to mark non-record fields global. "GEL" stands for "Global Even if inside a Local", but is kept short since we'll need this boilerplate a lot.

For example, if you have a list:

type t = string list

and want to make it local, but still keep the strings global, you can write:

type t = string Gel.t list

and it will be so, but with some extra boilerplate when using it.

This is for use with existing types that don't have the desired global_ annotation. If you find yourself reaching for this for a new type you are defining, you can avoid the boilerplate. For example:

type t =
  { global_ foo : string
  ; bar : int
  }

type t =
  | Foo of global_ string
  | Bar of { global_ foo : string; bar : int }
  | Baz of global_ string * int * global_ string
include Bin_prot.Binable.S1 with type 'a t := 'a t
val bin_shape_t : Bin_prot.Shape.t -> Bin_prot.Shape.t
val bin_size_t : ('a, 'a t) Bin_prot.Size.sizer1
val bin_write_t : ('a, 'a t) Bin_prot.Write.writer1
val bin_read_t : ('a, 'a t) Bin_prot.Read.reader1
val __bin_read_t__ : ('a, int -> 'a t) Bin_prot.Read.reader1
val bin_writer_t : ('a, 'a t) Bin_prot.Type_class.S1.writer
val bin_reader_t : ('a, 'a t) Bin_prot.Type_class.S1.reader
val bin_t : ('a, 'a t) Bin_prot.Type_class.S1.t
include Ppx_compare_lib.Comparable.S1 with type 'a t := 'a t
val compare : ('a -> 'a -> int) -> 'a t -> 'a t -> int
include Ppx_compare_lib.Equal.S1 with type 'a t := 'a t
val equal : ('a -> 'a -> bool) -> 'a t -> 'a t -> bool
include Ppx_hash_lib.Hashable.S1 with type 'a t := 'a t
val hash_fold_t : (Base.Hash.state -> 'a -> Base.Hash.state) -> Base.Hash.state -> 'a t -> Base.Hash.state
include Sexplib0.Sexpable.S1 with type 'a t := 'a t
val t_of_sexp : (Sexplib0.Sexp.t -> 'a) -> Sexplib0.Sexp.t -> 'a t
val sexp_of_t : ('a -> Sexplib0.Sexp.t) -> 'a t -> Sexplib0.Sexp.t
val create : 'a -> 'a t
val g : 'a t -> 'a
val map : 'a t -> f:('a -> 'b) -> 'b t
val globalize : _ -> 'a t -> 'a t
val drop_some : 'a t Base.option -> 'a Base.option

Removes a Gel.t from inside an option type with zero runtime cost. This is useful when some other function returns an X.t Gel.t option, you know X.t is mode-crossing, and you want to drop the inner Gel.t without allocating another local option.

val drop_ok : ('a t, 'b) Base.Result.t -> ('a, 'b) Base.Result.t

Like drop_some, but for the Ok _ branch of a result.

val drop_error : ('a, 'b t) Base.Result.t -> ('a, 'b) Base.Result.t

Like drop_some, but for the Error _ branch of a result.

val inject_some : 'a Base.option -> 'a t Base.option

Treat an existing global option as a local while maintaining the knowledge that the data inside the option is global. Zero runtime cost.

"Injects some gel between the option and its Some _ case."

val inject_ok : ('a, 'b) Base.Result.t -> ('a t, 'b) Base.Result.t

Like inject_some, but for the Ok _ case of a result.

val inject_error : ('a, 'b) Base.Result.t -> ('a, 'b t) Base.Result.t

Like inject_some, but for the Error _ case of a result.

val inject_result : ('a, 'b) Base.Result.t -> ('a t, 'b t) Base.Result.t

Like inject_some, but for the contents of a result.

OCaml

Innovation. Community. Security.