#pragma once #include #include namespace lily { enum reserved_types { type_id_int = 0, type_id_str, type_id_last }; struct type { virtual ~type() = default; virtual bool unify_with(type* other) = 0; }; struct type_internal : type { int type_id; type_internal(int id) : type_id(id) {} bool unify_with(type* other); }; struct type_parameter : type { type* actual_type = nullptr; bool unify_with(type* other); }; struct type_data : type { struct constructor { type_data* parent; int id; std::vector params; }; int type_id; std::vector> constructors; type_data(int id) : type_id(id) {} constructor* create_constructor(const std::string& name, std::vector&& params); bool unify_with(type* other); }; struct type_func : type { type* left; type* right; type_func(type* l, type* r) : left(l), right(r) {} bool unify_with(type* other); }; }