-
Notifications
You must be signed in to change notification settings - Fork 49
Merge IOHK fork #89
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
base: master
Are you sure you want to change the base?
Merge IOHK fork #89
Conversation
For generic decoding, `Decode (Foo a)` needs a `Decode a` constraint, but it *doesn't* need a `Generic a` constraint. Adding in this unnecessary constraint creates needless problems like, "there isn't an instance for `Generic String _`."
PureScript isn't happy with eta-reduced typeclass instances on recursive types. We have to make the function application explicit.
…y (Container A)`. The generated code will include an `Eq a =>` constraint.
* Sum types where every constructor has zero arguments. Aeson has special handling for these.
For generic decoding, `Decode (Foo a)` needs a `Decode a` constraint, but it *doesn't* need a `Generic a` constraint. Adding in this unnecessary constraint creates needless problems like, "there isn't an instance for `Generic String _`."
…xy (Container A)`. The generated code will include an `Ord a =>` constraint.
It turns out you can't eta-reduce typeclass instances for recursively-defined typeclasses in PureScript. That is: `show = genericShow` ...has to be replaced with: `show x = genericShow` ...to work reliably. See: purescript/purescript#2975
That is, `(genericShow <*> mkSumType) (Proxy @(Foo A))` will generate: ``` instance showFoo :: Show a => Show (Foo a) where show = genericShow ``` ...whereas before it would have missed out the `Show a` constraint.
Once purescript/spago#1310 is merged and Spago is updated via |
@kindaro @peterbecich do you also find that for newer GHC releases |
d9881a0
to
bd6a996
Compare
get Spago 0.93.44 use ghc 9.8 update spago.lock
replace Magic Nix Cache with https://github.com/nix-community/cache-nix-action
|
@eskimor , @flip111 , @kindaro , please review This branch is in a working state. Test and example coverage is excellent. This PR should not be a regression. The library is easier to iterate and test now. For any issues that still exist, it should be easier for myself and others to follow up on them. |
#63
CodeGenSwitches
no longer usedProxy
no longer usedPrinter
usesLeijen.Text
instead ofText
genericShow
PureScript instanceShow
#85instanceToImportLines
instead of being divided between two modulesRoundTrip
tests implemented by IOHKjson-helpers
and exposes issuesTODO
check that derivedGeneric
instances are correctfixRoundTrip
testsome other broken testsThe PR supports https://github.com/input-output-hk/purescript-bridge-json-helpers and the existing library https://github.com/coot/purescript-argonaut-aeson-generic
The issues with
purescript-argonaut-aeson-generic
are documented in the readme. Importantly, these issues exist onmaster
right now without the PR, so I think it should not block merging. Discussion purescript-contrib/purescript-argonaut-codecs#115 (comment)The other library https://github.com/paf31/purescript-foreign-generic continues to be supported, but the test coverage is much less than the other two.