package bap-knowledge

  1. Overview
  2. Docs

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 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.

OCaml

Innovation. Community. Security.