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

Simplify Dict.keys/values >> List.fold #308

Open
jfmengels opened this issue Apr 30, 2024 · 0 comments
Open

Simplify Dict.keys/values >> List.fold #308

jfmengels opened this issue Apr 30, 2024 · 0 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@jfmengels
Copy link
Owner

Similar to changes like the one introduced in #76, but for Dict.

The reason why we have this for Set and Array but not for Dict, is because the fold functions for Dict take an additional argument, which requires changes potentially far away. This is however easily resolvable when the fold function is an anonymous function:

When using Dict.keys:

dict
        |> Dict.keys
        |> List.foldl (\key acc -> ...) x
-->
dict
        |> Dict.foldl (\key _ acc -> ...) x

When using Dict.values:

dict
        |> Dict.values
        |> List.foldl (\value acc -> ...) x
-->
dict
        |> Dict.foldl (\_ value acc -> ...) x

(if List.foldr is used, then we would use Dict.foldr instead)

@jfmengels jfmengels added enhancement New feature or request help wanted Extra attention is needed labels Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant