-
Notifications
You must be signed in to change notification settings - Fork 99
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
base: master
Are you sure you want to change the base?
make bots happy #651
Conversation
@@ -160,6 +160,12 @@ module { | |||
}; | |||
return null | |||
}; | |||
public func exists<X>(array : [X], predicate : X -> Bool) : Bool { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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] { |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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
No description provided.