Legend:
Library
Module
Module type
Parameter
Class
Class type
Class is a collection of sorts.
A class k is denoted by an indexed type (k,s) cls, where s is a sort.
A class denotes a set of properties that describe objects and values of the given class. Thus, a class fully defines the structure of an object or a value. Sorts could be used to further partition the class into subsets, if needed.
Classes are declarative and each class should have a unique name. To prevent name clashing the Knowledge Library employs a Common Lisp style namespaces, where each name belongs to a package.
The type index, associated with the class, should be protected by the module that declares the class. For example, it is a bad idea to use the unit type as an index of a class.
assert_equal x y asserts the equality of two classes.
Usefull, in the context where the class is known for sure, (e.g., constrained by the module signature), but has to be recreated. The let T = assert_equal x y expression, establishes a type equality between objects in the typing context, so there is no need to invoke Object.cast.
let add : value obj -> value obj -> value obj = fun x y ->
let T = assert_equal bitv value in
x + y (* where (+) has type [bitv obj -> bitv obj -> bit obj] *)
val property :
?public:bool ->?desc:string ->?persistent:'ppersistent->?package:string ->('k, _)cls->string ->'pdomain->('k, 'p)slot
property cls name dom declares a new property of all instances of class k.
Each property should have a unique name. If a property with the given name was already, then the declaration fails.
The returned slot can be used to access the declarated property. If the property is expected to be public then it should be published via a library interface.
parameterpersistent
is an instance of the persistent class that will be used to persist the property.
parameterdesc
is a property documentation.
parameterpublic
(defaults to false) if specified, then the property will referenced in the Knowledge documentation output.