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

[feat] allow deriving via Generically #169

Closed
wants to merge 2 commits into from

Conversation

MangoIV
Copy link

@MangoIV MangoIV commented Aug 30, 2023

@MangoIV MangoIV force-pushed the mangoiv/generically branch 2 times, most recently from 9682c92 to ca4db4e Compare August 30, 2023 23:05
@MangoIV MangoIV marked this pull request as ready for review August 30, 2023 23:13
@MangoIV
Copy link
Author

MangoIV commented Aug 31, 2023

Somewhat unfortunately, datatypeInfo has the wrong type for being able to derive it via Generically:

class Generic a => HasDatatypeInfo a where
  -- | Type-level datatype info
  type DatatypeInfoOf a :: T.DatatypeInfo
  type DatatypeInfoOf a = GDatatypeInfoOf a

  -- | Term-level datatype info; by default, the term-level datatype info is produced
  -- from the type-level info.
  --
  datatypeInfo         :: proxy a -> DatatypeInfo (Code a)
  default datatypeInfo :: (GDatatypeInfo a, GCode a ~ Code a) => proxy a -> DatatypeInfo (Code a)
  datatypeInfo = gdatatypeInfo

The issue here is that because proxy is a type variable, we cannot assume that its parameter is representational or phantom, there are three solutions, all of which are breaking changes, the obvious one being specializing to Proxy or Proxy# which both have type role phantom on their parameter. Another option would be to specify a quantified Coercible constraint which would have the advantage to not fix the type but the disadvantage that it's basically incompatible with all ghc versions.

@MangoIV
Copy link
Author

MangoIV commented Aug 31, 2023

another possibility without specifying the type and without quantified constraints is to directly have
Coercible (proxy a) (proxy (Generically a)) which would hold for all the proxy types without role nominal and allow deriving via Generically, but this would nonetheless be a breaking change for people using proxies with a nominal parameter.

@MangoIV
Copy link
Author

MangoIV commented Sep 1, 2023

oups, this is a duplicate of #159 ... perhaps we can merge these

@MangoIV MangoIV closed this Jul 14, 2024
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.

1. Implement SOP.Generic (GHC.Generically a) and 2. export SOP.Generically
1 participant