Data.Sharedtype ('a, 'k) data = ('a, 'k) t('a, 'k) t is the type of 'as in a "sub-capsule" of 'k that has a shared view of 'k and uncontended access to the sub-capsule enclosing 'a.
Both read and write operations only require 'k Access.t @ shared. However, unlike ('a, 'k) Data.t, ('a, 'k) Data.Shared.t does not cross contention.
wrap ~access v returns a pointer to the value v, which lives in the sub-capsule of 'k. 'k is always the current capsule.
unwrap ~access t returns the value of t, which lives in the sub-capsule of 'k. 'k is always the current capsule.
A 'k Key.t @ global aliased indicates that all capsules have permanent read-only access to 'k. Therefore, ('a, 'k) t can be safely exposed.
val create : (unit -> 'a) @ local once portable -> ('a, 'k) t @@ portablecreate f runs f within the sub-capsule of 'k and returns a pointer to the result.
val map :
password:'k Password.Shared.t @ local ->
(f:('a -> 'b) @ local once portable ->
(('a, 'k) t ->
('b, 'k) t) @ local once) @ local @@ portablemap ~password ~f t applies f to the value of p within the sub-capsule of 'k and returns a pointer to the result.
both t1 t2 is a pointer to a pair of the values of t1 and t2.
fst t gives a pointer to the first value inside t
snd t gives a pointer to the second value inside t
val extract :
password:'k Password.Shared.t @ local ->
(f:('a -> 'b @ unique once portable contended) @ local once portable ->
(('a, 'k) t ->
'b @ unique once portable contended) @ local once) @ local @@ portableextract ~password ~f t applies f to the value of t within the sub-capsule of 'k and returns the result. The result has access to 'k so must be portable and is marked contended.
val inject : 'a 'k. 'a @ portable -> ('a, 'k) t @@ portableinject v is a pointer to an value v injected into the capsule 'k. It's a specialization of create to values that are always uncontended.
val project : 'a 'k. ('a, 'k) t -> 'a @ contended @@ portableproject t returns the value of t. The result is within 'k, so must be portable and is marked contended. Since it's always portable, unlike with extract, we don't need exclusive access to 'k: all accesses to the value happen only after it's marked contended.
val bind :
password:'k Password.Shared.t @ local ->
(f:('a -> ('b, 'j) t) @ local once portable ->
(('a, 'k) t ->
('b, 'j) t) @ local once) @ local @@ portablebind ~password ~f t is project (map ~password ~f t).
val iter :
password:'k Password.Shared.t @ local ->
(f:('a -> unit) @ local once portable ->
(('a, 'k) t ->
unit) @ local once) @ local @@ portableiter is extract with result type specialized to unit.
val map_into :
'a 'b 'k. password:'k Password.Shared.t @ local ->
(f:('a @ shared -> 'b) @ local once portable ->
(('a, 'k) data ->
('b, 'k) t) @ local once) @ local @@ portablemap_into is like Capsule.map_shared but returns a Shared.t.
module Local : sig ... endFunctions to work with ('a, 'k) t @ local.