Expand description
Contains Rust functions working on types. All MeTTa specific constants are exported as a part of metta module.
To designate the atom a has a type A one need add to the space the
expression (: a A). One can also assign a type to type, for example to
designate A is a type add (: A Type). -> is used to create a function
type, for example (: foo (-> A B)). Types can also be parameterized by
type or by value. For example list of numbers can be represented as
(: ns (List Number)).
There are five special meta-types: Atom, Symbol, Variable, Grounded
and Expression. These types should not be assigned explicitly, but they
can be used in type expressions and will be checked. For example one can
define a function which accepts Atom as an argument: (: bar (-> Atom A)).
When such expression is interpreted the argument is accepted without
reduction (see [metta::interpreter] algorithm).
When atom has no type assigned by user it has type %Undefined%. The value
of %Undefined% type can be matched with any type required.
Structs§
Functions§
- check_
type - Checks if passed
atomhas the giventypin context of the givenspace. This function can be used for a simple type check when there is no need to know type parameters. - get_
atom_ types - Returns vector of the types for the given
atomin context of the givenspace. Returns [%Undefined%] if atom has no type assigned. - get_
meta_ type - is_func
- Returns true if passed type is a type of function.
- match_
reducted_ types - Matches two types and returns an iterator over resulting bindings.
- validate_
atom - Returns true if atom is typed correctly. For example it can be used to check if function arguments have correct types.