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

Merge IOHK fork #89

Open
wants to merge 124 commits into
base: master
Choose a base branch
from
Open

Merge IOHK fork #89

wants to merge 124 commits into from

Conversation

peterbecich
Copy link
Contributor

@peterbecich peterbecich commented Sep 25, 2023

#63

  • CodeGenSwitches no longer used
  • Proxy no longer used
  • Printer uses Leijen.Text instead of Text
  • genericShow PureScript instance
  • some unit tests replaced with IOHK's tests
  • all printer imports are combined into one function instanceToImportLines instead of being divided between two modules
  • excellent RoundTrip tests implemented by IOHK
    • greatly improves test coverage for both Argonaut and json-helpers and exposes issues

TODO


The 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 on master 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.

shmish111 and others added 30 commits May 8, 2019 16:17
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.
@peterbecich peterbecich force-pushed the merge-iohk-3 branch 3 times, most recently from ec99e1b to 28053d1 Compare February 25, 2024 22:55
@peterbecich
Copy link
Contributor Author

TODO Enum and Ord peterbecich#1 (comment)

@flip111
Copy link

flip111 commented Feb 26, 2024

@peterbecich did you look at the problem of Enum and Ord? Can you confirm or otherwise comment whether the findings here are correct #89 (comment) ?

peterbecich added a commit to peterbecich/purescript-bridge that referenced this pull request Mar 31, 2024
@peterbecich
Copy link
Contributor Author

@flip111 , in progress, thanks

@flip111
Copy link

flip111 commented Apr 2, 2024

@peterbecich thanks. Need any more help?

@peterbecich
Copy link
Contributor Author

Once purescript/spago#1310 is merged and Spago is updated via nix flake update, the test suite should be closer to working. Right now, cabal test fails because Spago cannot find the workspace at the root of the project.

@flip111
Copy link

flip111 commented Feb 17, 2025

@kindaro @peterbecich do you also find that for newer GHC releases import GHC.Tuple.Prim (Tuple2) is being used instead of import Data.Tuple (Tuple)? I'm using LTS 23.9 for ghc-9.8.4

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

Successfully merging this pull request may close these issues.

7 participants