Enforce newline after assignment / clause.
This leads to more consistent formatting across entire Aiken programs. Before that commit, only long expressions would be formatted on a newline, causing non-consistent formatting and additional reading barrier when looking at source code. Programs also now take more vertical space, which is better for more friendly diffing in version control systems (especially git).
This commit is contained in:
@@ -37,7 +37,8 @@ fn do_union_with(
|
||||
with: fn(ByteArray, value, value) -> Option<value>,
|
||||
) -> List<(ByteArray, value)> {
|
||||
when left is {
|
||||
[] -> right
|
||||
[] ->
|
||||
right
|
||||
[(k, v), ..rest] ->
|
||||
do_union_with(rest, do_insert_with(right, k, v, with), with)
|
||||
}
|
||||
@@ -50,12 +51,15 @@ fn do_insert_with(
|
||||
with: fn(ByteArray, value, value) -> Option<value>,
|
||||
) -> List<(ByteArray, value)> {
|
||||
when self is {
|
||||
[] -> [(k, v)]
|
||||
[] ->
|
||||
[(k, v)]
|
||||
[(k2, v2), ..rest] ->
|
||||
if k == k2 {
|
||||
when with(k, v, v2) is {
|
||||
Some(combined) -> [(k, combined), ..rest]
|
||||
None -> rest
|
||||
Some(combined) ->
|
||||
[(k, combined), ..rest]
|
||||
None ->
|
||||
rest
|
||||
}
|
||||
} else {
|
||||
[(k2, v2), ..do_insert_with(rest, k, v, with)]
|
||||
|
||||
@@ -16,9 +16,9 @@ pub fn from_asset(
|
||||
) -> Value {
|
||||
let asset =
|
||||
dict.new()
|
||||
|> dict.insert(asset_name, quantity)
|
||||
|> dict.insert(asset_name, quantity)
|
||||
dict.new()
|
||||
|> dict.insert(policy_id, asset)
|
||||
|> dict.insert(policy_id, asset)
|
||||
}
|
||||
|
||||
pub fn from_lovelace(quantity: Int) -> Value {
|
||||
@@ -35,7 +35,8 @@ pub fn add(left v0: Value, right v1: Value) -> Value {
|
||||
a0,
|
||||
a1,
|
||||
fn(_, q0, q1) {
|
||||
let q = q0 + q1
|
||||
let q =
|
||||
q0 + q1
|
||||
if q == 0 {
|
||||
None
|
||||
} else {
|
||||
@@ -45,15 +46,19 @@ pub fn add(left v0: Value, right v1: Value) -> Value {
|
||||
)
|
||||
|
||||
when dict.toList(asset) is {
|
||||
[] -> None
|
||||
_ -> Some(asset)
|
||||
[] ->
|
||||
None
|
||||
_ ->
|
||||
Some(asset)
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
test add_1() {
|
||||
let v1 = from_lovelace(1)
|
||||
let v2 = from_lovelace(-1)
|
||||
let v1 =
|
||||
from_lovelace(1)
|
||||
let v2 =
|
||||
from_lovelace(-1)
|
||||
add(v1, v2) == dict.new()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user