use std::sync::Arc; use vec1::Vec1; use crate::{ ast::{ Annotation, Arg, AssignmentKind, BinOp, CallArg, Clause, Pattern, RecordUpdateSpread, Span, TodoKind, TypedRecordUpdateArg, UntypedRecordUpdateArg, }, tipo::{ModuleValueConstructor, PatternConstructor, Type, ValueConstructor}, }; pub enum TypedExpr { Int { location: Span, tipo: Arc, value: String, }, Float { location: Span, tipo: Arc, value: String, }, String { location: Span, tipo: Arc, value: String, }, Sequence { location: Span, expressions: Vec, }, /// A chain of pipe expressions. /// By this point the type checker has expanded it into a series of /// assignments and function calls, but we still have a Pipeline AST node as /// even though it is identical to `Sequence` we want to use different /// locations when showing it in error messages, etc. Pipeline { location: Span, expressions: Vec, }, Var { location: Span, constructor: ValueConstructor, name: String, }, Fn { location: Span, tipo: Arc, is_capture: bool, args: Vec>>, body: Box, return_annotation: Option, }, List { location: Span, tipo: Arc, elements: Vec, tail: Option>, }, Call { location: Span, tipo: Arc, fun: Box, args: Vec>, }, BinOp { location: Span, tipo: Arc, name: BinOp, left: Box, right: Box, }, Assignment { location: Span, tipo: Arc, value: Box, pattern: Pattern>, kind: AssignmentKind, }, Try { location: Span, tipo: Arc, value: Box, then: Box, pattern: Pattern>, }, When { location: Span, tipo: Arc, subjects: Vec, clauses: Vec, String>>, }, RecordAccess { location: Span, tipo: Arc, label: String, index: u64, record: Box, }, ModuleSelect { location: Span, tipo: Arc, label: String, module_name: String, module_alias: String, constructor: ModuleValueConstructor, }, Tuple { location: Span, tipo: Arc, elems: Vec, }, TupleIndex { location: Span, tipo: Arc, index: u64, tuple: Box, }, Todo { location: Span, label: Option, tipo: Arc, }, RecordUpdate { location: Span, tipo: Arc, spread: Box, args: Vec, }, Negate { location: Span, value: Box, }, } pub enum UntypedExpr { Int { location: Span, value: String, }, Float { location: Span, value: String, }, String { location: Span, value: String, }, Sequence { location: Span, expressions: Vec, }, Var { location: Span, name: String, }, Fn { location: Span, is_capture: bool, arguments: Vec>, body: Box, return_annotation: Option, }, List { location: Span, elements: Vec, tail: Option>, }, Call { location: Span, fun: Box, arguments: Vec>, }, BinOp { location: Span, name: BinOp, left: Box, right: Box, }, PipeLine { expressions: Vec1, }, Assignment { location: Span, value: Box, pattern: Pattern<(), ()>, kind: AssignmentKind, annotation: Option, }, Try { location: Span, value: Box, pattern: Pattern<(), ()>, then: Box, annotation: Option, }, Case { location: Span, subjects: Vec, clauses: Vec>, }, FieldAccess { location: Span, label: String, container: Box, }, Tuple { location: Span, elems: Vec, }, TupleIndex { location: Span, index: u64, tuple: Box, }, Todo { kind: TodoKind, location: Span, label: Option, }, RecordUpdate { location: Span, constructor: Box, spread: RecordUpdateSpread, arguments: Vec, }, Negate { location: Span, value: Box, }, }