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

De/Encode instance for Data.Map #40

Open
rubenpieters opened this issue Dec 5, 2017 · 2 comments
Open

De/Encode instance for Data.Map #40

rubenpieters opened this issue Dec 5, 2017 · 2 comments

Comments

@rubenpieters
Copy link

rubenpieters commented Dec 5, 2017

I'm wondering what the preferred way of writing a de/encode instance for Data.Map would be?

I have an initial implementation in a fork here ( rubenpieters@e2f24ed ).

Some choices I made:

  • Convert the Data.Map from/to a Data.StrMap, then encode/decode it similarly to Data.StrMap's instance
  • All keys are first converted to Strings, so I introduced an EncodeKey/DecodeKey class which can encode or decode keys to/from String respectively

Also in the initial implementation only the first decoding error is reported, I think the current StrMap doesn't report all decoding errors either. But that can definitely be fixed.

There are a lot of possibilities, so maybe it would be interesting to discuss the preferred way of doing it first.

@peterbecich
Copy link

peterbecich commented Feb 22, 2021

The referenced instance for StrMap: #28

Earlier attempt at instance for Map: #29

@peterbecich
Copy link

peterbecich commented Feb 22, 2021

It appears the instance for StrMap was replaced with an instance for Object (https://pursuit.purescript.org/packages/purescript-foreign-object/2.0.3/docs/Foreign.Object#t:Object): 54b26dc#diff-71732b478b4808898d86c8591ad7ab46d8122c1e4facec4a9151ac49efba905dR105

Perhaps there should be instances for https://github.com/purescript/purescript-ordered-collections (Data.Map, as you've said?)

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