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

feat: Add a few more Std.Collections.Seq functions #4867

Merged
merged 1 commit into from
Dec 11, 2023

Conversation

robin-aws
Copy link
Member

Description

These are functions I got used to having around in THIS "standard library" and didn't spot they weren't in OUR standard library until now. :)

Also removed Std.Strings.Concat (already covered more generically with Std.Collections.Seq.Flatten) and moved Std.Strings.Join to Std.Collections.Seq: these were only referenced by tests and their existence contradicted the documentation on the purpose of the Strings library.

Also commented out the remaining print statements in JSONTests.dfy to keep the testing output cleaner.

How has this been tested?

DafnyStandardLibraries tests.

By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.


/* Returns Some(i), if an element satisfying p occurs at least once in a sequence, and i is
the index of the first such occurrence. Otherwise the return is None. */
function {:opaque} IndexByOption<T(==)>(xs: seq<T>, p: T -> bool): (o: Option<nat>)
Copy link
Member Author

Choose a reason for hiding this comment

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

I'd also be happy with IndexWithOption as a naming scheme.

@robin-aws robin-aws requested a review from atomb December 11, 2023 21:14
Copy link
Member

@atomb atomb left a comment

Choose a reason for hiding this comment

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

This is a nice improvement! I like having those functions generic to seq<T> rather than specialized to string.

@@ -8,7 +8,8 @@ DOO_FILE_TARGET=binaries/DafnyStandardLibraries.doo
all: check-binary test check-format check-examples

verify:
$(DAFNY) verify src/DafnyStdLibs/dfyconfig.toml
Copy link
Member

Choose a reason for hiding this comment

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

Was this just missed in the DafnyStdLibs -> Std renaming?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yup, forgot to call it out in the PR description

@robin-aws robin-aws merged commit f735fd9 into dafny-lang:master Dec 11, 2023
20 checks passed
@robin-aws robin-aws deleted the more-seq-stdlib-functions branch December 11, 2023 23:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants