diff --git a/crates/aiken-lang/src/ast.rs b/crates/aiken-lang/src/ast.rs index 4c8da18d..c757eb7a 100644 --- a/crates/aiken-lang/src/ast.rs +++ b/crates/aiken-lang/src/ast.rs @@ -145,6 +145,41 @@ pub struct TypeAlias { pub type TypedDataType = DataType>; impl TypedDataType { + pub fn ordering() -> Self { + DataType { + constructors: vec![ + RecordConstructor { + location: Span::empty(), + name: "Less".to_string(), + arguments: vec![], + doc: None, + sugar: false, + }, + RecordConstructor { + location: Span::empty(), + name: "Equal".to_string(), + arguments: vec![], + doc: None, + sugar: false, + }, + RecordConstructor { + location: Span::empty(), + name: "Greater".to_string(), + arguments: vec![], + doc: None, + sugar: false, + }, + ], + doc: None, + location: Span::empty(), + name: "Ordering".to_string(), + opaque: false, + parameters: vec![], + public: true, + typed_parameters: vec![], + } + } + pub fn option(tipo: Arc) -> Self { DataType { constructors: vec![ diff --git a/crates/aiken-lang/src/builtins.rs b/crates/aiken-lang/src/builtins.rs index feae3278..10021c1e 100644 --- a/crates/aiken-lang/src/builtins.rs +++ b/crates/aiken-lang/src/builtins.rs @@ -877,6 +877,16 @@ pub fn prelude_functions(id_gen: &IdGenerator) -> IndexMap IndexMap { let mut data_types = IndexMap::new(); + // Ordering + let ordering_data_type = TypedDataType::ordering(); + data_types.insert( + DataTypeKey { + module_name: "".to_string(), + defined_type: "Ordering".to_string(), + }, + ordering_data_type, + ); + // Option let option_data_type = TypedDataType::option(generic_var(id_gen.next())); data_types.insert(