package base

  1. Overview
  2. Docs
Full standard library replacement for OCaml

Install

Dune Dependency

Authors

Maintainers

Sources

v0.17.3.tar.gz
md5=2100b0ed13fecf43be86ed45c5b2cc4d
sha512=628610caff7e124631870fa1e29661caac28bdfdb18750ee43b868037da3d65d6dd9023b4be7c4c52405679efb5e865a6632d95606a22b28a36636a6bf706ef3

doc/base/Base/Staged/index.html

Module Base.StagedSource

A type for making staging explicit in the type of a function.

For example, you might want to have a function that creates a function for allocating unique identifiers. Rather than using the type:

  val make_id_allocator : unit -> unit -> int

you would have

  val make_id_allocator : unit -> (unit -> int) Staged.t

Such a function could be defined as follows:

  let make_id_allocator () =
    let ctr = ref 0 in
    stage (fun () -> incr ctr; !ctr)

and could be invoked as follows:

  let (id1,id2) =
    let alloc = unstage (make_id_allocator ()) in
    (alloc (), alloc ())

both stage and unstage functions are available in the toplevel namespace.

(Note that in many cases, including perhaps the one above, it's preferable to create a custom type rather than use Staged.)

Sourcetype +'a t
Sourceval stage : 'a -> 'a t
Sourceval unstage : 'a t -> 'a
OCaml

Innovation. Community. Security.