types module
- class cls.types.Arrow(source: Type, target: Type)[source]
The Arrow class represents the type of a function from a source type to a target type.
- Parameters
source (Type) – The source type.
target (Type) – The target type.
is_omega (bool) – Indicates whether this type is omega.
size (int) – The size of this type.
organized (set[Type]) – The organized forms of this type.
path (tuple[list[Type], Type] | None) – The path to the root of the organized forms of this type.
- _abc_impl = <_abc._abc_data object>
- _is_omega() bool [source]
Return a flag indicating whether the type is omega.
- Returns
A flag indicating whether the type is omega.
- Return type
bool
- _organized() set['Type'] [source]
Return the set of types that the type is organized into.
- Returns
The set of types that the type is organized into.
- Return type
set
- _path() tuple[list['Type'], 'Type'] | None [source]
Return the path to the type.
- Returns
The path to the type, represented as a list of types and the type itself.
- Return type
tuple
- _str_prec(prec: int) str [source]
Return a string representation of the type with a given precedence.
- Parameters
prec (int) – The precedence to use when generating the string representation.
- Returns
The string representation of the type with the given precedence.
- Return type
str
- is_omega: bool
- organized: set[cls.types.Type]
- path: tuple[list['Type'], 'Type'] | None
- size: int
- class cls.types.Constructor(name: object, arg: Type = Omega(is_omega=True, size=1, organized=set(), path=None))[source]
A type constructor that is used to build more complex types.
- Parameters
name (object) – The name of the constructor.
arg (Type) – The argument of the constructor.
- Variables
is_omega – Indicates whether the type is an Omega type.
size – The size of the type.
organized – A set of `Type`s that are organized in this type.
path – A tuple representing the path to a Type in this type.
- _abc_impl = <_abc._abc_data object>
- _is_omega() bool [source]
Return a flag indicating whether the type is omega.
- Returns
A flag indicating whether the type is omega.
- Return type
bool
- _organized() set['Type'] [source]
Return the set of types that the type is organized into.
- Returns
The set of types that the type is organized into.
- Return type
set
- _path() tuple[list['Type'], 'Type'] | None [source]
Return the path to the type.
- Returns
The path to the type, represented as a list of types and the type itself.
- Return type
tuple
- _str_prec(prec: int) str [source]
Return a string representation of the type with a given precedence.
- Parameters
prec (int) – The precedence to use when generating the string representation.
- Returns
The string representation of the type with the given precedence.
- Return type
str
- is_omega: bool
- name: object
- organized: set[cls.types.Type]
- path: tuple[list['Type'], 'Type'] | None
- size: int
- class cls.types.Intersection(left: Type, right: Type)[source]
A type representing the intersection of two other types.
- Parameters
left (Type) – The left type in the intersection.
right (Type) – The right type in the intersection.
is_omega (bool) – Indicates if both left and right are equal to omega.
size (int) – The number of distinct primitive types in the intersection.
organized (set[Type]) – A set of primitive types in the intersection.
path (tuple[list[Type], Type] | None) – A path to the root of the intersection, or None if there is no such path.
- _abc_impl = <_abc._abc_data object>
- _is_omega() bool [source]
Return a flag indicating whether the type is omega.
- Returns
A flag indicating whether the type is omega.
- Return type
bool
- _organized() set['Type'] [source]
Return the set of types that the type is organized into.
- Returns
The set of types that the type is organized into.
- Return type
set
- _path() tuple[list['Type'], 'Type'] | None [source]
Return the path to the type.
- Returns
The path to the type, represented as a list of types and the type itself.
- Return type
tuple
- _str_prec(prec: int) str [source]
Return a string representation of the type with a given precedence.
- Parameters
prec (int) – The precedence to use when generating the string representation.
- Returns
The string representation of the type with the given precedence.
- Return type
str
- is_omega: bool
- organized: set[cls.types.Type]
- path: tuple[list['Type'], 'Type'] | None
- size: int
- class cls.types.Omega[source]
Represents the omega type in type theory. This class extends the abstract class Type.
- _abc_impl = <_abc._abc_data object>
- _is_omega() bool [source]
Return a flag indicating whether the type is omega.
- Returns
A flag indicating whether the type is omega.
- Return type
bool
- _organized() set['Type'] [source]
Return the set of types that the type is organized into.
- Returns
The set of types that the type is organized into.
- Return type
set
- _path() tuple[list['Type'], 'Type'] | None [source]
Return the path to the type.
- Returns
The path to the type, represented as a list of types and the type itself.
- Return type
tuple
- _str_prec(prec: int) str [source]
Return a string representation of the type with a given precedence.
- Parameters
prec (int) – The precedence to use when generating the string representation.
- Returns
The string representation of the type with the given precedence.
- Return type
str
- is_omega: bool
- organized: set[cls.types.Type]
- path: tuple[list['Type'], 'Type'] | None
- size: bool
- class cls.types.Product(left: Type, right: Type)[source]
Class representing the product type in the type theory.
- Parameters
left (Type) – The left-hand side type.
right (Type) – The right-hand side type.
is_omega (bool) – Indicates whether this type is omega.
size (int) – The size of this type.
organized (set[Type]) – The organized forms of this type.
path (tuple[list[Type], Type] | None) – The path to the root of the organized forms of this type.
- _abc_impl = <_abc._abc_data object>
- _is_omega() bool [source]
Return a flag indicating whether the type is omega.
- Returns
A flag indicating whether the type is omega.
- Return type
bool
- _organized() set['Type'] [source]
Return the set of types that the type is organized into.
- Returns
The set of types that the type is organized into.
- Return type
set
- _path() tuple[list['Type'], 'Type'] | None [source]
Return the path to the type.
- Returns
The path to the type, represented as a list of types and the type itself.
- Return type
tuple
- _str_prec(prec: int) str [source]
Return a string representation of the type with a given precedence.
- Parameters
prec (int) – The precedence to use when generating the string representation.
- Returns
The string representation of the type with the given precedence.
- Return type
str
- is_omega: bool
- organized: set[cls.types.Type]
- path: tuple[list['Type'], 'Type'] | None
- size: int
- class cls.types.Type(*, is_omega: bool, size: int, organized: set['Type'], path: tuple[list['Type'], 'Type'] | None)[source]
Abstract base class for a type.
This class serves as an abstract base class for all types in the system. It provides the basic structure for all types, including properties and methods common to all types.
- Variables
is_omega – Indicates whether the type is an Omega type.
size – The size of the type.
organized – A set of `Type`s that are organized in this type.
path – A tuple representing the path to a Type in this type.
- _abc_impl = <_abc._abc_data object>
- abstract _is_omega() bool [source]
Return a flag indicating whether the type is omega.
- Returns
A flag indicating whether the type is omega.
- Return type
bool
- abstract _organized() set['Type'] [source]
Return the set of types that the type is organized into.
- Returns
The set of types that the type is organized into.
- Return type
set
- static _parens(s: str) str [source]
Return a string with parentheses.
- Parameters
s (str) – The string to wrap in parentheses.
- Returns
The string with parentheses.
- Return type
str
- abstract _path() tuple[list['Type'], 'Type'] | None [source]
Return the path to the type.
- Returns
The path to the type, represented as a list of types and the type itself.
- Return type
tuple
- abstract _size() int [source]
Return the size of the type.
- Returns
The size of the type.
- Return type
int
- abstract _str_prec(prec: int) str [source]
Return a string representation of the type with a given precedence.
- Parameters
prec (int) – The precedence to use when generating the string representation.
- Returns
The string representation of the type with the given precedence.
- Return type
str
- static intersect(types: Sequence[Type]) Type [source]
Returns the intersection of the given sequence of types.
- Parameters
types (Sequence["Type"]) – The sequence of types to be intersected.
- Returns
The result of the intersection of the given types.
- Return type
- is_omega: bool
- organized: set['Type']
- path: tuple[list['Type'], 'Type'] | None
- size: int