Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make bots happy #651

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from
Draft

make bots happy #651

wants to merge 9 commits into from

Conversation

chenyan-dfinity
Copy link
Contributor

No description provided.

@@ -160,6 +160,12 @@ module {
};
return null
};
public func exists<X>(array : [X], predicate : X -> Bool) : Bool {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is called some in Trie.mo and List.mo. I'd hate to introduce inconsistency. Does the bot insist one this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also would need doc and some tests, ideally.

public func exists<X>(array : [X], predicate : X -> Bool) : Bool {
Option.isSome(find(array, predicate))
};
public func forall<X>(array : [X], predicate : X -> Bool) : Bool {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is called all in Trie.mo and List.mo. Also would need doc and tests.

@@ -207,6 +213,10 @@ module {
sortInPlace(temp, compare);
freeze(temp)
};
public func sortByLessThanOrEqual<X>(array : [X], isLessThanOrEqual : (X, X) -> Bool) : [X] {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this still an isse with the revised prompt? The bot was having trouble with defining functions returning Order.order because the prompt was actually misleadingly broken.

Maybe we could call lessThanOrEqual totalOrder?

/// Slice buffer from [start, end).
public func slice<X>(buffer : Buffer<X>, start : Nat, end : Nat) : Buffer<X> {
let size = buffer.size();
if (start < 0 or start > size or end < 0 or end > size or start > end) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (start < 0 or start > size or end < 0 or end > size or start > end) {
if (start > size or end > size or start > end) {

Nat's are never < 0, right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs better doc and test.

@@ -26,6 +26,7 @@ module {
public func abs(x : Int) : Nat {
Prim.abs(x)
};
public func fromNat(n : Nat) : Int = n;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs doc .
Maybe we could add a deprecation warning to say its not really necessary (due to subtyping)

@@ -26,6 +28,10 @@ module {
/// Nat.toText 1234 // => "1234"
/// ```
public func toText(n : Nat) : Text = Int.toText n;
public func hash(n : Nat) : Hash.Hash = Hash.hash(n);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hash.hash is suboptimal. Do we really want to spread it's use?

@@ -26,6 +28,10 @@ module {
/// Nat.toText 1234 // => "1234"
/// ```
public func toText(n : Nat) : Text = Int.toText n;
public func hash(n : Nat) : Hash.Hash = Hash.hash(n);
public func abs(n : Int) : Nat = Int.abs n;
public func fromInt(n : Int) : Nat = Int.abs n;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fromInt should trap on negative?

@@ -29,6 +30,7 @@ module {
/// Nat32.toNat(123); // => 123 : Nat
/// ```
public let toNat : Nat32 -> Nat = Prim.nat32ToNat;
public func hash(n : Nat32) : Hash.Hash = Hash.hash(toNat n);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same argument about Hash.hash

@@ -42,5 +42,17 @@ module {
case _ { false }
}
};

public func lteToOrder<X>(isLessThanOrEqual : (X, X) -> Bool) : (X, X) -> Order {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if there is a better name for this...

totalOrderToComparer

or

lessThanOrEqualToCompare

or
compareBy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants