diff --git a/priv/stdlib/BLS12_381.aes b/priv/stdlib/BLS12_381.aes index 4bc27ff..21eee16 100644 --- a/priv/stdlib/BLS12_381.aes +++ b/priv/stdlib/BLS12_381.aes @@ -7,13 +7,13 @@ namespace BLS12_381 = record gt = { x1 : fp, x2 : fp, x3 : fp, x4 : fp, x5 : fp, x6 : fp, x7 : fp, x8 : fp, x9 : fp, x10 : fp, x11 : fp, x12 : fp } - function pairing_check(xs : list(g1), ys : list(g2)) = - switch((xs, ys)) + function pairing_check(us : list(g1), vs : list(g2)) = + switch((us, vs)) ([], []) => true (x :: xs, y :: ys) => pairing_check_(pairing(x, y), xs, ys) - function pairing_check_(acc : gt, xs : list(g1), ys : list(g2)) = - switch((xs, ys)) + function pairing_check_(acc : gt, us : list(g1), vs : list(g2)) = + switch((us, vs)) ([], []) => gt_is_one(acc) (x :: xs, y :: ys) => pairing_check_(gt_mul(acc, pairing(x, y)), xs, ys) diff --git a/priv/stdlib/Bitwise.aes b/priv/stdlib/Bitwise.aes index 63be770..cc273f0 100644 --- a/priv/stdlib/Bitwise.aes +++ b/priv/stdlib/Bitwise.aes @@ -116,16 +116,6 @@ namespace Bitwise = 1 => ubxor__(a / 2, b / 2, val * 2, acc + val) _ => ubxor__(a / 2, b / 2, val * 2, acc) - // Bitwise combined 'and' and 'not' of second argument for positive integers - // x 'bnand' y = x 'band' ('bnot' y) - // The tricky bit is that after negation the second argument has an infinite number of 1's - // use as many as needed! - // - // NOTE: this function is not symmetric! - private function ubnand(a, b) = - require(a >= 0 && b >= 0, "ubxor is only defined for non-negative integers") - ubnand__(a, b, 1, 0) - private function ubnand_(a, b) = ubnand__(a, b, 1, 0) private function diff --git a/priv/stdlib/List.aes b/priv/stdlib/List.aes index cf9670e..e0201d0 100644 --- a/priv/stdlib/List.aes +++ b/priv/stdlib/List.aes @@ -173,7 +173,7 @@ namespace List = if (n == 0) l else switch(l) [] => [] - h::t => drop_(n-1, t) + _::t => drop_(n-1, t) /** Get the longest prefix of a list in which every element * matches predicate `p` @@ -191,7 +191,7 @@ namespace List = /** Splits list into two lists of elements that respectively * match and don't match predicate `p` */ - function partition(p : 'a => bool, l : list('a)) : (list('a) * list('a)) = switch(l) + function partition(p : 'a => bool, lst : list('a)) : (list('a) * list('a)) = switch(lst) [] => ([], []) h::t => let (l, r) = partition(p, t) @@ -313,4 +313,4 @@ namespace List = function enumerate(l : list('a)) : list(int * 'a) = enumerate_(l, 0) private function enumerate_(l : list('a), n : int) : list(int * 'a) = switch(l) [] => [] - h::t => (n, h)::enumerate_(t, n + 1) \ No newline at end of file + h::t => (n, h)::enumerate_(t, n + 1) diff --git a/priv/stdlib/ListInternal.aes b/priv/stdlib/ListInternal.aes index 7d6773a..3909283 100644 --- a/priv/stdlib/ListInternal.aes +++ b/priv/stdlib/ListInternal.aes @@ -2,8 +2,8 @@ namespace ListInternal = // -- Flatmap ---------------------------------------------------------------- - function flat_map(f : 'a => list('b), xs : list('a)) : list('b) = - switch(xs) + function flat_map(f : 'a => list('b), lst : list('a)) : list('b) = + switch(lst) [] => [] x :: xs => f(x) ++ flat_map(f, xs) diff --git a/priv/stdlib/String.aes b/priv/stdlib/String.aes index 36c54ba..33f813b 100644 --- a/priv/stdlib/String.aes +++ b/priv/stdlib/String.aes @@ -53,21 +53,21 @@ namespace String = // Converts a decimal ("123", "-253") or a hexadecimal ("0xa2f", "-0xBBB") string // into an integer. If the string doesn't contain a valid number `None` is returned. - function to_int(s : string) : option(int) = - let s = StringInternal.to_list(s) - switch(is_prefix(['-'], s)) - None => to_int_pos(s) + function to_int(str : string) : option(int) = + let lst = StringInternal.to_list(str) + switch(is_prefix(['-'], lst)) + None => to_int_pos(lst) Some(s) => switch(to_int_pos(s)) None => None Some(x) => Some(-x) // Private helper functions below - private function to_int_pos(s : list(char)) = - switch(is_prefix(['0', 'x'], s)) + private function to_int_pos(chs : list(char)) = + switch(is_prefix(['0', 'x'], chs)) None => - to_int_(s, ch_to_int_10, 0, 10) - Some(s) => - to_int_(s, ch_to_int_16, 0, 16) + to_int_(chs, ch_to_int_10, 0, 10) + Some(str) => + to_int_(str, ch_to_int_16, 0, 16) private function tokens_(_, [], acc) = [StringInternal.from_list(List.reverse(acc))] @@ -84,8 +84,8 @@ namespace String = contains_(ix, str, substr) = switch(is_prefix(substr, str)) None => - let _ :: str = str - contains_(ix + 1, str, substr) + let _ :: tailstr = str + contains_(ix + 1, tailstr, substr) Some(_) => Some(ix) @@ -101,15 +101,15 @@ namespace String = to_int_(i :: is, value, x, b) = switch(value(i)) None => None - Some(i) => to_int_(is, value, x * b + i, b) + Some(n) => to_int_(is, value, x * b + n, b) - private function ch_to_int_10(c) = - let c = Char.to_int(c) + private function ch_to_int_10(ch) = + let c = Char.to_int(ch) if(c >= 48 && c =< 57) Some(c - 48) else None - private function ch_to_int_16(c) = - let c = Char.to_int(c) + private function ch_to_int_16(ch) = + let c = Char.to_int(ch) if(c >= 48 && c =< 57) Some(c - 48) elif(c >= 65 && c =< 70) Some(c - 55) elif(c >= 97 && c =< 102) Some(c - 87)