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

Restrict the type of findFailFn #1500

Open
ag-eitilt opened this issue Jan 2, 2024 · 0 comments
Open

Restrict the type of findFailFn #1500

ag-eitilt opened this issue Jan 2, 2024 · 0 comments
Labels
breaking-change discussion required Scope and/or response need a narrower definition

Comments

@ag-eitilt
Copy link
Collaborator

Currently findFailFn isn't particularly helpful, essentially just being a serialized version of map _ xs | findFail (which itself might actually be desirable in certain niche circumstances) and those semantics don't match its name pattern as a variant of findFail. I'd like to propose we change its signature from (a => Result b c) => List a => Result (List b) c into (a => Result b c) => List a => Result (List a) c -- note the final List.

Effectively, that means it wouldn't perform the unwrapping of each list element that findFail does, but instead allows for nondestructive checking by returning the original list ("for every String in the list, ensure it's a key in this map without replacing the String with the associated value"1), or for validating complex types along the lines of Pair a (Result b c) but where the Result can't be easily promoted out, or in cases where some evaluation needs to be done to ensure the value's valid but where the result of that evaluation isn't important.

This would obviously be a breaking change and require concerted migration of old code before we could roll it out, but that's a hole which we currently would have to awkwardly code around if it were to ever come up, and would give findFailFn a distinct purpose rather than its current limbo.

Footnotes

  1. Ignore the fact that that can currently be done with findFailFn (\str if mcontains str registry then Pass str else failWithError "...") and imagine that it's easier to write findFailFn (mlookup _ registry | getOrFail "...".makeError); I just don't have a better example offhand.

@ag-eitilt ag-eitilt added discussion required Scope and/or response need a narrower definition breaking-change labels Jan 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change discussion required Scope and/or response need a narrower definition
Projects
None yet
Development

No branches or pull requests

1 participant