From OpenCog

The TypedAtomLink is a kind of UniqueLink that can be used to associate a type to an atom. The association is globally valid, and must be unique; it is not possible to associate two different types to an atom. If polymorphism is desired, use the TypeChoice link. The TypedAtomLink resembles the TypedVariableLink, except that the typing of variables is always local in scope, whereas the typing of atoms is always global and unique. That is, only bound variables can be typed, and the type definition of a bound variable does not escape the scope of the binding. Free variables cannot be typed at all. as a corollary, the TypedVariableLink can only be used on variables, and the TypedAtomLink can only be used on atoms that are not variables.


See ArrowLink for an example of a TypedAtomLink in use, as well as a motivation for its usefulness.

It is anticipated that the TypedAtomLink will play an important role in the unified rule engine, to assign types to rules, and thus help constrain which rules can be chained together.

Implementation Notes

The AtomSpace will throw an exception if an attempt is made to link a second conflicting type to an atom. This is similar to the behavior of DefineLink. To change an atom type, the current TypedAtomLink must first be deleted. Perhaps we need a TypeStateLink, in analogy to StateLink.

Design Flaws

Currently, the only way of stating that some atom can be one of two types is to use the TypeChoiceLink; to say that it's both of two types, one would use TypeSetLink. Both of these can be awkward, if the type specification changes over time. That is, the need to first delete, and then re-create the TypedAtomLink is awkward, when the desired set-membership needs to be changed. The issue with set membership is discussed in github issue #1502.