Closed coot closed 5 years ago
Thank you for the heads up!
I'll take a look into this.
@coot awesome! :-)
Hi,
I think we will need this very soon (PureScript 0.12 will remove the compiler support for purescript-generics
see Release notes)
Is it ok with you if I have a look at this?
as far as I can tell this will probably be the only road-block for this going straight into purs 0.12
- all the other dependencies (including purescript-profunctor-lenses
seem to be already ported to 0.12)
@CarstenKoenig that would be awesome! Thanks for the link, I currently don't have any Purescript projects, so I am not really up 2 date what's going on in PS land.
Nevertheless, I still feel responsible for this library so I try to check any PRs whether they make sense and don't have any bad effects, therefore I would highly appreciate explanations for changes and why they are necessary together with links to resources with further details. E.g. library release notes, ...
The easier it is for me to check a PR, the faster it will be merged ;-)
I can of course understand this
so the question is how to move forward. From what I understand the purescript-generics
is in there so that the library can work with purescript-argonaut
right?
I just had a look and it seem this one will drop the dependencies to both generics libraries (here is the future .bower file).
So maybe the simples way forward to 0.12 would be to drop the code generation for the generic-derives for now.
I've opened a separate issue for that: https://github.com/eskimor/purescript-bridge/issues/44
If you drop the generic-derives you no longer get automatic aeson compatible JSON encodings. purescript-argonaut-codecs seem to have abandoned generic JSON encoding - at least I can't find it in the current code base.
I think they moved it to here: https://pursuit.purescript.org/packages/purescript-argonaut-generic/1.2.0
But this one is not ready for 0.12 either
No matter what, the deriving of purescript-generic
will be gone with 0.12 and it's moved to generic-rep
But didn't you reimplement the generic argonaut stuff here in the first place? I thought the only questions was if we want to replace or update this.
But didn't you reimplement the generic argonaut stuff here in the first place? I thought the only questions was if we want to replace or update this.
Right - you pointed to purescript-argonaut, so I just looked what they did for 0.12. The library we would need to update/replace is of course that one.
I looked into it some more - turns out (at least as far as I can tell) that generics-rep
will not work as well - Justin Woo pointed me to RowToList
as a replacement, which apparently he used for simple-json
So I guess we should either try and see if we could use that lib or adapt those changes
I'm gonna try doing this but it will probably take me a few days - but I would love to hear your take on it
Well, as far as I understood Generics.Rep work similar to Haskell Generics. That means: Fundamentally different than the old PS Generics. It would definitely not be a drop in replacement. For example, in order to override the generic JSON encoding one would no longer use userEncoding, but simply would provide handwritten instances forToJSON
, FromJSON
for the type in question.
The most fundamental difference is that with Haskell Generics you don't recursively walk the data type, but simply provide a ToJSON
implementation for the current data type in question, by leveraging ToJSON
instances already existing for data types "contained" in your data type.
In PS Generics you would simple walk the entire data type including all predefined data types used in your type and produce JSON as you go.
Example:
data MyType = MyType SomeOtherType
With Haskell generics, you would simply use the ToJSON
instance of SomeOtherType
for implementing a Generic
ToJSON
instance for MyType
. In PS, the ToJSON
instance fo SomeOtherType
is completely irrelevant.
Having a glimpse at RowToList
it seems, it made make some things easier when dealing with records.
yes it does - and I think I can just add this to get the missing parts from Generics.Rep
(they dropped the Record and Row-List field representations)
Btw: thanks for the explanation
btw: I was able to get a combination of both working here: https://github.com/CarstenKoenig/purescript-argonaut-generic/tree/RowToList
I filed a WIP-PR there and if this is merged I would recommend we just derive the generic-rep
here and use this for purescript-servant
someone's a fast typer ... :-)
@CarstenKoenig can this be closed now?
I think so yes
It appears the Generics Rep library has been deprecated; moved to Prelude: https://github.com/purescript-deprecated/purescript-generics-rep
Purescript's
Generic
will not be derivable inpurscript-0.12
(it isn't in the master already). The alternative is to useData.Generic.Rep
instead.