std::optional experimental::typeClassFromTypeClassName(TypeClassName const& _typeClass) { return std::visit(util::GenericVisitor{ [&](ASTPointer _path) -> optional { auto classDefinition = dynamic_cast (_path->annotation().referencedDeclaration); if (!classDefinition) return nullopt; return TypeClass{classDefinition};
| 117 | } |
| 118 | */ |
| 119 | experimental::Type TypeSystemHelpers::tupleType(std::vector<Type> _elements) const |
| 120 | { |
| 121 | if (_elements.empty()) |
| 122 | return typeSystem.type(PrimitiveType::Unit, {}); |
| 123 | if (_elements.size() == 1) |
| 124 | return _elements.front(); |
| 125 | Type result = _elements.back(); |
| 126 | for (Type type: _elements | ranges::views::reverse | ranges::views::drop_exactly(1)) |
| 127 | result = typeSystem.type(PrimitiveType::Pair, {type, result}); |
| 128 | return result; |
| 129 | } |
| 130 | |
| 131 | std::vector<experimental::Type> TypeSystemHelpers::destTupleType(Type _tupleType) const |
| 132 | { |