Skip to content

Support configuring which keys are used for tag & values #12

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

Merged
merged 2 commits into from
Nov 9, 2018
Merged

Support configuring which keys are used for tag & values #12

merged 2 commits into from
Nov 9, 2018

Conversation

LiamGoodacre
Copy link
Member

Depends on #11
Not tied to the names, feel free to suggest better ones.

@thomashoneyman thomashoneyman self-assigned this Nov 9, 2018
@thomashoneyman
Copy link
Contributor

@LiamGoodacre Would you mind explaining a little about the motivation behind this change?

I understand this allows for choosing what keys to use for tag / values, but I'm not sure what new flexibility that opens up.

@thomashoneyman thomashoneyman merged commit c9c7609 into purescript-contrib:master Nov 9, 2018
@thomashoneyman
Copy link
Contributor

I inadvertently merged this as I thought I was looking at the simple dependency update. It's been merged and then reverted in master. I'd like to continue this conversation briefly before merging officially, if you don't mind. Sorry about that!

@thomashoneyman
Copy link
Contributor

This can be cherry-picked into master when ready. Thanks!

@LiamGoodacre
Copy link
Member Author

No problem! My motivation for this is to interoperate with an existing (fixed) JSON structure that uses different keys than tag and values. I didn't want to reimplement all of this just with different keys.

@thomashoneyman
Copy link
Contributor

What do you think of supporting both options -- continue allowing a default that uses tag and values, in a type class member decodeRep, which relies on the other type class member, decodeRepWith? That would allow current users to continue using their code as-is in a new version without having to update everything with new explicit encodings.

class DecodeRep r where
  decodeRep :: Json -> Either String r
  decodeRepWith :: Encoding -> Json -> Either String r

decodeRep = decodeRepWith defaultEncoding

@LiamGoodacre
Copy link
Member Author

Happy to also have decodeRep - but I'm wondering if we should export it separately without it being a type class member?

@thomashoneyman
Copy link
Contributor

Thanks for re-opening the PR. I was thinking the same thing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants