About
This documentation contains the definition of the main concepts introduced in typed. They are present in logic ordering.
Concepts
The typed universe is the class
__UNIVERSE__that works as the metaclass for all abstract metatypes. It requires the implementation of a__instancecheck__method. Also, it provides a__contains__method which is implemented precisely by the given__instancecheck__.
A universal metatype is a Python {lib:class} that has the
__UNIVERSE__as metaclass. The canonical example is_TYPE_: the universal metatype which is the {py:abstract metatype} of the concrete metatypeTYPEof all types.
An abstract metatype is a Python class which is a subclass of a universal metatype. They are named in uppercase:
SOME_META,OTHER_META, …
type.
A type is a class that has an abstract metatype as a metaclass. Types are names in
CamelCase:SomeType,OtherType, …
A concrete metatype is a type
SomeTypewhose objects are themselves types. There is the concrete metatypeTYPEof all types.
A domain hinted function is a function such that every parameter has a type annotation. They form a type
DomHinted.
A codomain hinted function is a function whose return have a type annotation. They form a type
CodHinted.
A hinted function is a function which is both domain hinted and codomain hinted. There is the type
Hintedof all hinted functions. It is a subtype of bothDomHintedandCodHinted.
The domain of a domain hinted function is the tuple of the type annotations of their parameters.
The codomain of a codomain hinted function is its return type annotations.
A domain typed function is a domain hinted function whose type annotations are types or dependent types which are checked at runtime. They form a type
DomTypedwhich is a subtype ofDomHinted.
A codomain typed function is a codomain hinted function whose return type annotation is a type or a dependent type, checked at runtime. They form a type
CodTypedwhich is a subtype ofCodHinted.
A typed function is a function which is both domain hinted and codomain hinted, so that all their type annotations are types or dependent types, being checked at runtime. There is the type
Typedof all typed functions. It is a subtype of bothDomTyped,CodTypedandHinted.
A type factory is a typed function whose codomain is
TYPE, the concrete metatype of all types. Thus, a type factory is some process constructing a type depending on certain parameters.
A parametric type is type which also is a type factory. Thus, it is a type whose abstract metatype has a
__call__method that returns a type factory.
A dependent type is type which also is a type factory. Thus, it is a type whose abstract metatype has a
__call__method that returns a type factory.
A condition (a.k.a predicate) is a type factory that constructs booleans, hence that take values into
Bool.