Open alanrgan opened 7 years ago
def data Option { Some(int); Nothing; }
ADTs can be destructured via the following construction:
if [ADT name]? [ident] -> [(e1, e2, ... , en)] { }
Example:
let x: Option = Some(3); if Option.Some? x -> (inner_val) { print("found inner val " + inner_val); }
Pattern matching can be done via the case [ident] for construction:
case [ident] for
case x { for (Option.Some -> inner_val) { print("found some! " + inner_val); }, for (Option.Nothing) { print("nothing here..."); }, _ -> {} }
When designing ADTs, internal type representation should be considered, as well as how it will interact with the (future) type-inferencer / unification engine.
ADTs can be destructured via the following construction:
Example:
Pattern matching can be done via the
case [ident] for
construction: