DefinedTypeNode

From OpenCog
Jump to: navigation, search

The DefinedTypeNode is used to give a name to anonymous types, but using the DefineLink to couple a name with the anonymous type definition.

A DefinedTypeNode can be used anywhere that an ordinary TypeNode can be used.

Example

One can define a function type to describe the algebraic operator that accepts two numbers as input, and returns a third, as follows:

 ArrowLink
     ListLink      ;; the input argument types
         NumberNode
         NumberNode
     NumberNode     ;; the type of the output

Since the ArrowLink is a bona-fide type constructor, this is a new type, and it can be used anywhere that an ordinary TypeNode can be used. However, it is anonymous: it has no name. It can be given a name simply by doing this:

 DefineLink
     DefinedTypeNode "binary numeric operator"
     ArrowLink
         ListLink
             NumberNode
             NumberNode
         NumberNode

The name here is "binary numeric operator" and this named type can now be used freely wherever an ordinary TypeNode can be used.