Module proto_vulcan::compound[][src]

Expand description

Compound types provide structural types to proto-vulcan langugage.

In proto-vulcan type system, LTerm is the supertype of all types, and all its subtypes types can be cast back to it. Compound types are Rust structs that are built from LTerms and other compound types. Proto-vulcan compound types are comparable to prolog compound types.

└─ LTerm
   ├─ Val
   │  ├─ Bool
   │  ├─ Number
   │  ├─ Char
   │  └─ String
   ├─ Var
   │  ├─ x
   │  └─ _
   ├─ User
   ├─ Empty/None
   ├─ Cons
   └─ Compound

Compound types are further divided into compound objects and compound terms – compound terms are also always compound objects.

Compound objects

  • Destructuring directly
  • Cannot be recursive
  • Existing types can be made into objects

Compound terms

  • Destructuring via unification only
  • Can be recursive
  • Can be wildcard variable _ or [] instead of structural content.

use-clauses

When useing compound object or term Bar, the corresponding Bar_compound module must also be imported for the compound type to work in proto-vulcan expressions: use path::to::{Bar, Bar_compound};.

Type conversions

Type conversions to supertypes are done implicitly via inserted Into::into calls; for conversions to subtypes, such as compound types, unification must be used.

Traits