Allow to trace expressions (and not only string literals)

This however enforces that the argument unifies to a `String`. So this
  is more flexible than the previous form, but does fundamentally the
  same thing.

  Fixes #378.
This commit is contained in:
KtorZ
2023-02-15 18:46:07 +01:00
parent 4e51e49fe6
commit 7abd76b6ad
10 changed files with 185 additions and 42 deletions

View File

@@ -1,9 +1,19 @@
use aiken/builtin
fn concat(left: String, right: String) -> String {
builtin.append_bytearray(
builtin.encode_utf8(left),
builtin.encode_utf8(right),
)
|> builtin.decode_utf8
}
fn is_negative(i: Int) -> Bool {
if i < 0 {
trace("is negative")
True
} else {
trace("is non-negative")
trace(concat("is", concat(" ", "non-negative")))
False
}
}