Skip to content

1. Add instance GenericK instance for the new Generically, 2. Add your own Generically name to instances defined by GenericK

This is largely a repeat of my message to generics-sop.

  1. Add GenericK instances to GHC.Generically and GHC.Generically1:

    instance GHC.Generic a => Kind.GenericK @Type (GHC.Generically a) LoT0 where
      type CodeK (GHC.Generically a) = DataType Type
      fromK = toKindGenericsS . GHC.from
      toK   = GHC.to . toKindGenericsS
    
    instance GHC.Generic1 f => Kind.GenericK @(k->Type) (GHC.Generically1 f) (a :&&: LoT0) where
      type CodeK (GHC.Generically1 @k f) = DataType (k->Type)
      fromK = toKindGenericsS . GHC.from1
      to    = GHC.to1 . toKindGenericsS
  2. Export your own Kind.Generically newtypes, always used qualified. Frankly the types here go over my head, maybe it's best to export one for each argument

    -- Generics.Kind
    newtype Generically      a     = Generically       a
    newtype Generically1 f   a     = Generically1 (f   a)
    newtype Generically2 bi  a b   = Generically2 (bi  a b)
    newtype Generically3 tri a b c = Generically3 (tri a b c)

    or make it kind-generic

    -- Generics.Kind
    type    GenericallyK :: k -> LoT k -> Type
    newtype GenericallyK f args = GenericallyK (f :@@: args)
    
    type Generically      a     = GenericallyK a   LoT0
    type Generically1 f   a     = GenericallyK f   (a :&&: LoT0)
    type Generically2 bi  a b   = GenericallyK bi  (a :&&: b :&&: LoT0)
    type Generically3 tri a b c = GenericallyK tri (a :&&: b :&&: c :&&: LoT0)
Edited by Baldur Blöndal
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information