Module Knowledge.Object

Knowledge Base Objects.

The knowledge base stores object properties. The object itself is an identifier, and could be seen as a pointer or a database key.

type 'a t = 'a obj
type 'a ord
val create : ('a, _) cls -> 'a obj knowledge

create is a fresh new object with an idefinite extent.

val scoped : ('a, _) cls -> ('a obj -> 'b knowledge) -> 'b knowledge

scoped scope pass a fresh new object to scope.

The extent of the created object is limited with the extent of the function scope. The object passed to the scope function is automatically deleted after the computation, returned by scope evaluates to a value. The identity of an object could be reused, which may lead to hard detected bugs, thus care should be taken to prevent the object value from escaping the scope of the function.

val null : ('a, _) cls -> 'a obj

null cls is the null object of the class cls.

For each class cls there is null that represents an absence of object. It is unique and is represented as zero.

Dereference of the null object (e.g., using collect) always returns an empty denotation. Any information stored in the object is forgotten (discarded). Promises are never run on the null object, therefore the promise will never receive the null object as its input.

  • since 2.4.0
val is_null : _ obj -> bool

is_null obj is true iff obj is the null object of its class.

  • since 2.4.0
val repr : ('a, _) cls -> 'a t -> string knowledge

repr x returns a textual representation of the object x

val read : ('a, _) cls -> string -> 'a t knowledge

read s returns an object x such that repr x = s.

val cast : ('a obj, 'b obj) Core_kernel.Type_equal.t -> 'a obj -> 'b obj

cast class_equality x changes the type of an object.

Provided with an equality of two object types, returns the same object x with a new type.

The type equality of two object types could be obtained through Class.equal or Class.assert_equal. Note, this function doesn't do any magic, this is just the Type_equal.conv, lifted into the Object module for covenience.

val id : 'a obj -> Core_kernel.Int63.t

id obj returns the internal representation of an object.

module type S = sig ... end

Ordered and persistent data types.

val derive : ('a, 'd) cls -> (module S with type comparator_witness = 'a ord and type t = 'a obj)

derive cls a module of type S for the given class cls.