package base
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>
Full standard library replacement for OCaml
Install
dune-project
Dependency
Authors
Maintainers
Sources
v0.16.5.tar.gz
md5=109456ad2350671ad3159cbbca993e3e
sha512=445d08b965e0d559e4046b874f611c8f36de47fa5c23a047146f48ee638588c1b73789a7adb5ead235c0ad2f44b56fd513a6d60bcb8b6c9f11566d32fd7760f2
doc/src/base/ref.ml.html
Source file ref.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77open! Import include ( struct type 'a t = 'a ref [@@deriving_inline compare, equal, globalize, sexp, sexp_grammar] let compare : 'a. ('a -> 'a -> int) -> 'a t -> 'a t -> int = compare_ref let equal : 'a. ('a -> 'a -> bool) -> 'a t -> 'a t -> bool = equal_ref let globalize : 'a. (('a[@ocaml.local]) -> 'a) -> ('a t[@ocaml.local]) -> 'a t = fun (type a__009_) : (((a__009_[@ocaml.local]) -> a__009_) -> (a__009_ t[@ocaml.local]) -> a__009_ t) -> globalize_ref ;; let t_of_sexp : 'a. (Sexplib0.Sexp.t -> 'a) -> Sexplib0.Sexp.t -> 'a t = ref_of_sexp let sexp_of_t : 'a. ('a -> Sexplib0.Sexp.t) -> 'a t -> Sexplib0.Sexp.t = sexp_of_ref let t_sexp_grammar : 'a. 'a Sexplib0.Sexp_grammar.t -> 'a t Sexplib0.Sexp_grammar.t = fun _'a_sexp_grammar -> ref_sexp_grammar _'a_sexp_grammar ;; [@@@end] end : sig type 'a t = 'a ref [@@deriving_inline compare, equal, globalize, sexp, sexp_grammar] include Ppx_compare_lib.Comparable.S1 with type 'a t := 'a t include Ppx_compare_lib.Equal.S1 with type 'a t := 'a t val globalize : (('a[@ocaml.local]) -> 'a) -> ('a t[@ocaml.local]) -> 'a t include Sexplib0.Sexpable.S1 with type 'a t := 'a t val t_sexp_grammar : 'a Sexplib0.Sexp_grammar.t -> 'a t Sexplib0.Sexp_grammar.t [@@@end] end) (* In the definition of [t], we do not have [[@@deriving compare, sexp]] because in general, syntax extensions tend to use the implementation when available rather than using the alias. Here that would lead to use the record representation [ { mutable contents : 'a } ] which would result in different (and unwanted) behavior. *) type 'a t = 'a ref = { mutable contents : 'a } external create : 'a -> ('a t[@local_opt]) = "%makemutable" external ( ! ) : ('a t[@local_opt]) -> 'a = "%field0" external ( := ) : ('a t[@local_opt]) -> 'a -> unit = "%setfield0" let swap t1 t2 = let tmp = !t1 in t1 := !t2; t2 := tmp ;; let replace t f = t := f !t let set_temporarily t a ~f = let restore_to = !t in t := a; Exn.protect ~f ~finally:(fun () -> t := restore_to) ;; module And_value = struct type t = T : 'a ref * 'a -> t [@@deriving sexp_of] let set (T (r, a)) = r := a let sets ts = List.iter ts ~f:set let snapshot (T (r, _)) = T (r, !r) let snapshots ts = List.map ts ~f:snapshot end let sets_temporarily and_values ~f = let restore_to = And_value.snapshots and_values in And_value.sets and_values; Exn.protect ~f ~finally:(fun () -> And_value.sets restore_to) ;;
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>