-
Notifications
You must be signed in to change notification settings - Fork 48
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
1. Implement SOP.Generic (GHC.Generically a)
and 2. export SOP.Generically
#153
Comments
Thanks! In principle, I'm in support of both, although regarding part 2, I'm somewhat afraid that the presence of the type will go mostly unnoticed, because the library itself has hardly any generic functions, so it would basically be a type without instances. |
For 1. I think this pragma should work #if MIN_VERSION_base(4,17,0)
#define HAS_GENERICALLY
#endif And then this is a backwards compatible definition for #ifdef HAS_GENERICALLY
instance .. => SOP.Generic (GHC.Generically a) where
..
#endif For 2. I share the concern, I was thinking that it would mostly be up to other libraries that depend on generics-sop to specify instances without having to depend on another library. generics-sop can add instances for the base classes with time. Maybe it belongs in basic-sop instead? It already has a generics-sop |
For 1. you can use the generically compatibility package. I think ¹ What name should be chosen? import Generics.SOP hiding (Generically(..))
import qualified Generics.SOP as SOP (Generically) |
There is already a name clash in |
So you're fine with exporting this as |
It's up to @kosmikus |
Yes, as long as we don't rename the @Icelandjack do you want to submit a PR? Otherwise, I'll try to do this whenever I next get around to making changes on the library. |
I made a PR #159 and updated some of the documentation. I didn't build the project so there may be some errors. |
Here are 2 suggestions once we get
GHC.Generically
andGHC.Generically1
in base 4.17.Those are simply newtypes, if you have a definition in terms of
GHC.Generic
orGHC.Generic1
then you give it an instance.SOP.Generic
has an implementation in terms ofGHC.Generic
, thus I propose the following instance:This way an instance of
SOP.Generic T
can be derived:deriving SOP.Generic via GHC.Generically T
.I also propose defining a newtype with the same name as
Generically
, to be imported qualified withSOP.Generically
, it will serve the same purpose but forSOP.Generic
definitions. I think every data-type generic library should export a name like that. If I can implementBinary
in terms ofSOP.Generic
I defineinstance (SOP.Generic a, ..) => Binary (SOP.Generically a)
:A newtype like
SOP.Generically
can be combined with a library like generic-override that overrides the generic representation of an instance, so we decouple a generic implementation from modifying the generic implementation:The text was updated successfully, but these errors were encountered: