rename 'constr_{fields,index}' to 'unconstr_{field,index}'
Better match the conventions so far used across the existing builtins.
This commit is contained in:
parent
977e24c725
commit
67bf64967b
|
@ -4,9 +4,11 @@
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
- **aiken**: Generate a default 'placeholder' validator when using `aiken new`. See [#1061](https://github.com/aiken-lang/aiken/pull/1061) @Waalge
|
- **aiken**: Generate a default _'placeholder.ak'_ validator when using `aiken new`. See [#1061](https://github.com/aiken-lang/aiken/pull/1061) @Waalge
|
||||||
- **aiken-lang**: New builtins 'constr_fields' and 'constr_index'. @Microproofs
|
- **aiken-lang**: New builtins [`unconstr_fields`](https://aiken-lang.github.io/prelude/aiken/builtin.html#unconstr_fields) and [`unconstr_index`](https://aiken-lang.github.io/prelude/aiken/builtin.html#unconstr_index). @Microproofs
|
||||||
- **aiken-lang**: New builtins from Chang2 hardfork (except for writeBits). @Microproofs, @KtorZ
|
- **aiken-lang**: Added builtins from Chang2 hardfork (except for writeBits). @Microproofs, @KtorZ
|
||||||
|
- [Bitwise operations](https://aiken-lang.github.io/prelude/aiken/builtin.html#Bitwise)
|
||||||
|
- [Ripemd-160 hashing](https://aiken-lang.github.io/prelude/aiken/builtin.html#ripemd_160)
|
||||||
- **aiken-projects**: The generated documentation may now include maths typesetting rendered using [KaTex](https://katex.org/). See [#1070](https://github.com/aiken-lang/aiken/pull/1070) @adrian052.
|
- **aiken-projects**: The generated documentation may now include maths typesetting rendered using [KaTex](https://katex.org/). See [#1070](https://github.com/aiken-lang/aiken/pull/1070) @adrian052.
|
||||||
- Both inline (delimited by single `$` symbols) and blocks (delimited by doubled `$$` symbols) are now parsed and rendered as SVG upon generating documentation. For example:
|
- Both inline (delimited by single `$` symbols) and blocks (delimited by doubled `$$` symbols) are now parsed and rendered as SVG upon generating documentation. For example:
|
||||||
|
|
||||||
|
|
|
@ -519,11 +519,11 @@ pub fn plutus(id_gen: &IdGenerator) -> TypeInfo {
|
||||||
|
|
||||||
let index_tipo = Type::function(vec![Type::data()], Type::int());
|
let index_tipo = Type::function(vec![Type::data()], Type::int());
|
||||||
plutus.values.insert(
|
plutus.values.insert(
|
||||||
"constr_index".to_string(),
|
"unconstr_index".to_string(),
|
||||||
ValueConstructor::public(
|
ValueConstructor::public(
|
||||||
index_tipo,
|
index_tipo,
|
||||||
ValueConstructorVariant::ModuleFn {
|
ValueConstructorVariant::ModuleFn {
|
||||||
name: "constr_index".to_string(),
|
name: "unconstr_index".to_string(),
|
||||||
field_map: None,
|
field_map: None,
|
||||||
module: "aiken/builtin".to_string(),
|
module: "aiken/builtin".to_string(),
|
||||||
arity: 1,
|
arity: 1,
|
||||||
|
@ -535,11 +535,11 @@ pub fn plutus(id_gen: &IdGenerator) -> TypeInfo {
|
||||||
|
|
||||||
let fields_tipo = Type::function(vec![Type::data()], Type::list(Type::data()));
|
let fields_tipo = Type::function(vec![Type::data()], Type::list(Type::data()));
|
||||||
plutus.values.insert(
|
plutus.values.insert(
|
||||||
"constr_fields".to_string(),
|
"unconstr_fields".to_string(),
|
||||||
ValueConstructor::public(
|
ValueConstructor::public(
|
||||||
fields_tipo,
|
fields_tipo,
|
||||||
ValueConstructorVariant::ModuleFn {
|
ValueConstructorVariant::ModuleFn {
|
||||||
name: "constr_fields".to_string(),
|
name: "unconstr_fields".to_string(),
|
||||||
field_map: None,
|
field_map: None,
|
||||||
module: "aiken/builtin".to_string(),
|
module: "aiken/builtin".to_string(),
|
||||||
arity: 1,
|
arity: 1,
|
||||||
|
@ -1043,7 +1043,7 @@ pub fn prelude_functions(
|
||||||
) -> IndexMap<FunctionAccessKey, TypedFunction> {
|
) -> IndexMap<FunctionAccessKey, TypedFunction> {
|
||||||
let mut functions = IndexMap::new();
|
let mut functions = IndexMap::new();
|
||||||
|
|
||||||
let constr_index_body = TypedExpr::Call {
|
let unconstr_index_body = TypedExpr::Call {
|
||||||
location: Span::empty(),
|
location: Span::empty(),
|
||||||
tipo: Type::int(),
|
tipo: Type::int(),
|
||||||
fun: TypedExpr::local_var(
|
fun: TypedExpr::local_var(
|
||||||
|
@ -1069,7 +1069,7 @@ pub fn prelude_functions(
|
||||||
}],
|
}],
|
||||||
};
|
};
|
||||||
|
|
||||||
let constr_index_func = Function {
|
let unconstr_index_func = Function {
|
||||||
arguments: vec![TypedArg {
|
arguments: vec![TypedArg {
|
||||||
arg_name: ArgName::Named {
|
arg_name: ArgName::Named {
|
||||||
name: "constr".to_string(),
|
name: "constr".to_string(),
|
||||||
|
@ -1091,23 +1091,23 @@ pub fn prelude_functions(
|
||||||
}.to_string()
|
}.to_string()
|
||||||
),
|
),
|
||||||
location: Span::empty(),
|
location: Span::empty(),
|
||||||
name: "constr_index".to_string(),
|
name: "unconstr_index".to_string(),
|
||||||
public: true,
|
public: true,
|
||||||
return_annotation: None,
|
return_annotation: None,
|
||||||
return_type: Type::int(),
|
return_type: Type::int(),
|
||||||
end_position: 0,
|
end_position: 0,
|
||||||
body: constr_index_body,
|
body: unconstr_index_body,
|
||||||
};
|
};
|
||||||
|
|
||||||
functions.insert(
|
functions.insert(
|
||||||
FunctionAccessKey {
|
FunctionAccessKey {
|
||||||
module_name: "aiken/builtin".to_string(),
|
module_name: "aiken/builtin".to_string(),
|
||||||
function_name: "constr_index".to_string(),
|
function_name: "unconstr_index".to_string(),
|
||||||
},
|
},
|
||||||
constr_index_func,
|
unconstr_index_func,
|
||||||
);
|
);
|
||||||
|
|
||||||
let constr_fields_body = TypedExpr::Call {
|
let unconstr_fields_body = TypedExpr::Call {
|
||||||
location: Span::empty(),
|
location: Span::empty(),
|
||||||
tipo: Type::list(Type::data()),
|
tipo: Type::list(Type::data()),
|
||||||
fun: TypedExpr::local_var(
|
fun: TypedExpr::local_var(
|
||||||
|
@ -1133,7 +1133,7 @@ pub fn prelude_functions(
|
||||||
}],
|
}],
|
||||||
};
|
};
|
||||||
|
|
||||||
let constr_fields_func = Function {
|
let unconstr_fields_func = Function {
|
||||||
arguments: vec![TypedArg {
|
arguments: vec![TypedArg {
|
||||||
arg_name: ArgName::Named {
|
arg_name: ArgName::Named {
|
||||||
name: "constr".to_string(),
|
name: "constr".to_string(),
|
||||||
|
@ -1155,20 +1155,20 @@ pub fn prelude_functions(
|
||||||
}.to_string()
|
}.to_string()
|
||||||
),
|
),
|
||||||
location: Span::empty(),
|
location: Span::empty(),
|
||||||
name: "constr_fields".to_string(),
|
name: "unconstr_fields".to_string(),
|
||||||
public: true,
|
public: true,
|
||||||
return_annotation: None,
|
return_annotation: None,
|
||||||
return_type: Type::list(Type::data()),
|
return_type: Type::list(Type::data()),
|
||||||
end_position: 0,
|
end_position: 0,
|
||||||
body: constr_fields_body,
|
body: unconstr_fields_body,
|
||||||
};
|
};
|
||||||
|
|
||||||
functions.insert(
|
functions.insert(
|
||||||
FunctionAccessKey {
|
FunctionAccessKey {
|
||||||
module_name: "aiken/builtin".to_string(),
|
module_name: "aiken/builtin".to_string(),
|
||||||
function_name: "constr_fields".to_string(),
|
function_name: "unconstr_fields".to_string(),
|
||||||
},
|
},
|
||||||
constr_fields_func,
|
unconstr_fields_func,
|
||||||
);
|
);
|
||||||
|
|
||||||
// /// Negate the argument. Useful for map/fold and pipelines.
|
// /// Negate the argument. Useful for map/fold and pipelines.
|
||||||
|
|
|
@ -1,12 +1,23 @@
|
||||||
use aiken/builtin.{constr_index}
|
use aiken/builtin.{unconstr_fields, unconstr_index}
|
||||||
|
|
||||||
test baz() {
|
test bar() {
|
||||||
let x = Some("bar")
|
let x = Some("bar")
|
||||||
|
|
||||||
expect [bar] = x |> builtin.constr_fields
|
expect [bar] = x |> builtin.unconstr_fields
|
||||||
|
|
||||||
and {
|
and {
|
||||||
constr_index(x) == 0,
|
unconstr_index(x) == 0,
|
||||||
builtin.un_b_data(bar) == "bar",
|
builtin.un_b_data(bar) == "bar",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test baz() {
|
||||||
|
let x = Some("baz")
|
||||||
|
|
||||||
|
expect [baz] = x |> unconstr_fields
|
||||||
|
|
||||||
|
and {
|
||||||
|
builtin.unconstr_index(x) == 0,
|
||||||
|
builtin.un_b_data(baz) == "baz",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue