diff --git a/samples/receiver.do b/samples/receiver.do deleted file mode 100644 index 9a81277..0000000 --- a/samples/receiver.do +++ /dev/null @@ -1,59 +0,0 @@ -#!/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() -} diff --git a/samples/usable.do b/samples/usable.do index 19ec3db..bd7bdb1 100644 --- a/samples/usable.do +++ b/samples/usable.do @@ -1,6 +1,6 @@ //! Sample doughlang code -struct Expr { +enum Expr { Atom (f64), Op (char, [Expr]), }