Illustrate new failing scenario with multi-arg function identifiers

As far as I could tell, this behavior is only observed when the arity
  of the function is higher than 1. It's fine for single-arg functions
  somehow.
This commit is contained in:
KtorZ
2024-08-06 17:00:13 +02:00
committed by microproofs
parent 59bc9e04ad
commit 6e4a16d8e0
3 changed files with 60 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
use aiken/builtin
pub fn reduce(xs: List<a>, zero: b, do: fn(a, b) -> b) -> b {
when xs is {
[] -> zero
[head, ..tail] -> do(head, reduce(tail, zero, do))
}
}
pub fn inspect_1(self: Data, result: result) -> result {
builtin.choose_data(
self,
fail,
fail,
reduce(builtin.un_list_data(self), result, fn(a, b) { inspect_1(a, b) }),
{
trace @"int"
result
},
fail,
)
}
test as_lambda() {
inspect_1([14, 42], True)
}
pub fn inspect_2(self: Data, result: result) -> result {
builtin.choose_data(
self,
fail,
fail,
reduce(builtin.un_list_data(self), result, inspect_2),
{
trace @"int"
result
},
fail,
)
}
test as_identifier() {
inspect_2([14, 42], True)
}