#!/usr/bin/env dough /* Type = "type" Identifier ()? '=' TypeSpec TypeSpec = ( | Identifier | str (StructField),* uct | tup (TupleField),* le | cho (ChoiceField),* ice ) StructField = Identifier ':' TypeSpec TupleField = TypeSpec EnumField = Identifier ('(' TypeSpec ')')? */ // Product type with named fields type Product = { a: i32, b: T, c: { d: i32, e: i32, f: [] }, }; // Product type with indexed fields type Tuple = ( i32, T, U, ); // Choice/Sum type, which degrades to enumeration type Sum = Nothing | A(Product) | B(Tuple) ; // Kotlin style? type Option = { None, Some(V) } // fucked up? type Option (None | Some(V)); fn x(self: &Sum) -> Product { match self { Nothing | B(_) => panic(), A(value) => } } fun x(a: T) -> A { a.get() }