Add Ordering data-type definition to prelude known constructors.
This commit is contained in:
parent
6be2a9ed80
commit
b5cf8c78a5
|
@ -145,6 +145,41 @@ pub struct TypeAlias<T> {
|
|||
pub type TypedDataType = DataType<Arc<Type>>;
|
||||
|
||||
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<Type>) -> Self {
|
||||
DataType {
|
||||
constructors: vec![
|
||||
|
|
|
@ -877,6 +877,16 @@ pub fn prelude_functions(id_gen: &IdGenerator) -> IndexMap<FunctionAccessKey, Ty
|
|||
pub fn prelude_data_types(id_gen: &IdGenerator) -> IndexMap<DataTypeKey, TypedDataType> {
|
||||
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(
|
||||
|
|
Loading…
Reference in New Issue