Module Capsule_expert.Access

An Access.t allows wrapping and unwrapping Data.t values from the current capsule.

type 'k t

'k t represents access to the current capsule, allowing wrapping and unwrapping Data.t values. An uncontended 'k t indicates that 'k is the current capsule. A shared 'k t indicates that 'k is the current capsule but that it may be shared with other threads.

'k ts captured in a portable closure become contended, which prevents sharing them with other threads.

type packed =
  1. | P : 'k t -> packed

packed is the type of access to some unknown capsule. Unpacking one provides a 'k t together with a fresh existential type brand for 'k.

type 'k boxed

A boxed version of Access.t for places where you need a type with layout value.

val box : 'k t -> 'k boxed @@ portable
val unbox : 'k boxed -> 'k t @@ portable
val equality_witness : 'k t -> 'j t -> ('k, 'j) Type.eq @@ portable

equality_witness a b returns a witness that the brands of a and b are equal. This must be true since they are both present uncontended within the same capsule.