Skip to content

Conversation

Icelandjack
Copy link

@Icelandjack Icelandjack commented Nov 24, 2022

For #153, this adds:

  • generically (package) as a dependency, to support versions before GHC.Generically was added (base 4.17).
  • An SOP.Generic (GHC.Generically a) instance.
    instance (GHC.Generic a, GFrom a, GTo a, All SListI (GCode a)) => Generic (GHC.Generically a) where
      type Code (GHC.Generically a) = GCode a
    
      from :: GHC.Generically a -> Rep (GHC.Generically a)
      from (GHC.Generically a) = gfrom a
    
      to :: Rep (GHC.Generically a) -> GHC.Generically a
      to rep = GHC.Generically (gto rep)
  • An SOP.HasDatatypeInfo (GHC.Generically a) instance.
  • A SOP Generically newtype for attaching generic SOP definitions:
    newtype Generically a = Generically a

All in all deriving SOP.Generic can be done GHC.Generically and deriving SOP instances can be done SOP.Generically:

data Ok = Ok Int Int Int
  deriving
  stock GHC.Generic

  deriving (SOP.Generic, HasDatatypeInfo)
  via GHC.Generically
  
  deriving (Eq, NFData, ..)      -- assuming we have instances of SOP.Generically
  via SOP.Generically

The next step should be writing SOP generic instances for SOP.Generically, for type classes in base.

@Icelandjack
Copy link
Author

Ping on this

@MangoIV MangoIV mentioned this pull request Sep 1, 2023
3 tasks
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 participant