terohuttunen / proto-vulcan

A relational logic programming language embedded in Rust.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Implement enum-kind compound types.

terohuttunen opened this issue · comments

Only struct-kind compound types are supported at the moment. However, compound types were implemented with enum-kinds in mind. Each enum-variant is converted into new struct-kind type and put under EnumType_compound-module where the macros will be looking for the types.

The per-variant types will implement Downcast so that even though enum-variants have separate pattern/constructor structs, they are downcast into single type.

Compound macro

The procedural macro should be updated so that compound type can be generated as:

#[compound]
enum EnumType {
    Option1(Bar),
    Option2(LTerm, Baz),
    Option3(Foo),
}

where Bar and Baz are compound types.

Pattern matching

Pattern matching expressions should support the enum types:

match term {
    EnumType::Option(b) => ...,
}

Constructors

Constructor expressions should support the enum types:

relation(EnumType::Option(b)),