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

Decoder k -> Decoder v -> Decoder (List ( k, v )) #24

Open
Herteby opened this issue May 17, 2019 · 2 comments
Open

Decoder k -> Decoder v -> Decoder (List ( k, v )) #24

Herteby opened this issue May 17, 2019 · 2 comments

Comments

@Herteby
Copy link

Herteby commented May 17, 2019

Would be nice to have a key-value decoder that allowed you to specify the key decoder, instead of it always being String 🙂

Useful when using wrapped types like type ID = ID String

@lydell
Copy link

lydell commented Oct 20, 2019

Like dict2, but keyValuePairs2?

If so, wouldn’t (String -> Decoder k) -> Decoder v -> Decoder (List ( k, v )) make more sense? I’m thinking it is strange to ask for a decoder for the keys when we know that only Json.Decode.string would ever succeed (since object keys are always strings). See also: #22 (comment)

@Herteby
Copy link
Author

Herteby commented Nov 8, 2019

@lydell True, String -> Decoder k would work, although it looks a bit odd I think.
How about String -> Maybe k or String -> Result String k ?

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

No branches or pull requests

2 participants