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

Add GenericBinary wrapper that can be used with DerivingVia #173

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

vapourismo
Copy link

I think the examples highlight what this wrapper is supposed to accomplish.

-- Simple usage with DerivingVia:
data Foo = Foo Int String
    deriving Generic
    deriving Binary via GenericBinary Foo

-- When chaining multiple augmentations:
data Foo = Foo Int String
    deriving Generic
    deriving Binary via Augmentation1 (Augmentation2 (GenericBinary Foo))

I am conflicted on the name. Should it be GBinary or would that indicate it is supposed to be a class that implements Binary in terms of Generic?

@vapourismo
Copy link
Author

@kolmodin ping

@kolmodin
Copy link
Member

I haven't used deriving via. So there's not a common pattern for how to name the additional newtype?
Did I get it right that the first "simple usage" can just be done with deriving Binary and where it's useful is actually when chaining augmentations?

@vapourismo
Copy link
Author

I haven't dealt with that many deriving-via patterns to call myself a pattern name expert, but I am more torn on whether it fits into the library.

Your observation is correct. The first pattern is trivial enough to be achievable using a simple deriving Binary when DeriveAnyClass is enabled.
The second one is where the utility starts. The scenario being that one wants to enhance the generic anyclass Binary instance for Foo.

@Icelandjack
Copy link

If/when we get Generically it can serve as a common type of generic instances

type Foo :: Type
data Foo = Foo [Int] String
  deriving
   stock Generic
  deriving (Semigroup, Monoid, Binary, ..)
   via Generically Foo

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.

3 participants