Skip to content
This repository was archived by the owner on Mar 25, 2021. It is now read-only.

Conversation

shmish111
Copy link

I am trying to encode/decode data to JSON and I have some types with Either, I need a Generic instance to use Foreign.Generic to do this.

@garyb
Copy link
Member

garyb commented May 8, 2019

I'm surprised there wasn't an instance for this already!

Anyone know of a reason not to add it?

@kritzcreek
Copy link

I think it's because we need to depend on Maybe from here to implement the Enum instance, so the dependency has to be this way around. The instance for Either should live in purescript-either instead, and should be derivable.

@shmish111
Copy link
Author

I suppose it could be Either way round 👅 can @garyb and @kritzcreek come to a consensus on this and let me know, happy to switch it. Is it more likely that you will one day want to use either in generics-rep or visa versa? I would suggest that Either is more fundamental than Generic but then again Generic is built into the compiler...

@shmish111
Copy link
Author

I'm looking to get this merged and released asap since I hope to finish upgrading my project to PS 0.12 next week, would you like me to move this instance to purescript-either or can you merge and release this PR? Thanks 👍

@hdgarrood
Copy link
Contributor

Please don’t hurry us, there’s lots going on across the compiler and core libraries and we simply can’t look at everything in the timescale you seem to be expecting. I think this is the kind of change which warrants a bit more care as pretty much the whole ecosystem depends on one or both of the libraries in question. In fact I’d prefer to consider all of the data types across the core libraries and come up with a uniform approach for making sure all of the types which should have a Generic instance do.

If you want to ship now you can define a newtype over Either with the instances you need eg ReadForeign and WriteForeign.

@paulyoung
Copy link

#34 (comment) says:

The instance for Either should live in purescript-either instead, and should be derivable.

So I did that in purescript/purescript-either#57

@JordanMartinez
Copy link
Contributor

This instance has been added in purescript-either. Closing

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

Successfully merging this pull request may close these issues.

6 participants