diff --git a/schala-lang/src/eval.rs b/schala-lang/src/eval.rs index 02da78d..ff1f2f7 100644 --- a/schala-lang/src/eval.rs +++ b/schala-lang/src/eval.rs @@ -77,7 +77,7 @@ impl Expr { UserDefined { name: None, .. } => format!(""), UserDefined { name: Some(name), .. } => format!("", name), }, - Expr::NewConstructor { + Expr::Constructor { type_name, name, tag, arity, } => if *arity == 0 { format!("{}", name) @@ -152,13 +152,13 @@ impl<'a> State<'a> { literal @ Lit(_) => Ok(literal), Call { box f, args } => { match self.expression(f)? { - NewConstructor { type_name, name, tag, arity} => self.apply_data_constructor(type_name, name, tag, arity, args), + Constructor { type_name, name, tag, arity} => self.apply_data_constructor(type_name, name, tag, arity, args), Func(f) => self.apply_function(f, args), other => return Err(format!("Tried to call {:?} which is not a function or data constructor", other)), } }, Val(v) => self.value(v), - constructor @ NewConstructor { .. } => Ok(constructor), + constructor @ Constructor { .. } => Ok(constructor), func @ Func(_) => Ok(func), Tuple(exprs) => Ok(Tuple(exprs.into_iter().map(|expr| self.expression(expr)).collect::,_>>()?)), Conditional { box cond, then_clause, else_clause } => self.conditional(cond, then_clause, else_clause), diff --git a/schala-lang/src/reduced_ast.rs b/schala-lang/src/reduced_ast.rs index 6705cde..66a4865 100644 --- a/schala-lang/src/reduced_ast.rs +++ b/schala-lang/src/reduced_ast.rs @@ -29,7 +29,7 @@ pub enum Expr { Tuple(Vec), Func(Func), Val(Rc), - NewConstructor { + Constructor { type_name: Rc, name: Rc, tag: usize, @@ -118,7 +118,7 @@ impl Expression { PrefixExp(op, arg) => op.reduce(symbol_table, arg), Value(name) => { match symbol_table.lookup_by_name(name) { - Some(Symbol { spec: SymbolSpec::DataConstructor { index, type_args, type_name}, .. }) => Expr::NewConstructor { + Some(Symbol { spec: SymbolSpec::DataConstructor { index, type_args, type_name}, .. }) => Expr::Constructor { type_name: type_name.clone(), name: name.clone(), tag: index.clone(),