HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Modulelinear-generics-0.2.3Haskell2010

Generics.Linear.Unsafe.ViaGHCGenerics

DerivingVia targets to instantiate Generic and Generic1, both using GHC.Generics.Generic.

Caution
  • 2 types
newtypenewtype GHCGenerically a
#

When a is an instance of GHC.Generics.Generic, GHCGenerically a is an instance of Generic.

Warnings

GHCGenerically is intended for use as a DerivingVia target. Most other uses of its Generic instance will be quite wrong.

GHCGenerically must not be used with datatypes that have nonlinear or linearity-polymorphic fields. Doing so will produce completely bogus results, breaking the linearity rules.

GHCGenerically is otherwise safe to use with derived GHC.Generics.Generic instances, which are linear. If you choose to use it with a hand-written instance, you should check that the underlying instance is linear.

Example
data Foo a = Bar a (Either Int a) | Baz (Maybe a) Int
  deriving stock (Show, GHC.Generics.Generic)
  deriving Generic via GHCGenerically (Foo a)
Instances2Generic, Rep
newtypenewtype GHCGenerically1 (f :: k -> Type) (a :: k)
#

When f a is an instance of GHC.Generics.Generic for all a, GHCGenerically1 f is an instance of Generic1.

Warning

GHCGenerically1 is intended for use as a DerivingVia target. Most other uses of its Generic1 instance will be quite wrong.

GHCGenerically1 must not be used with datatypes that have nonlinear or linearity-polymorphic fields. Doing so will produce completely bogus results, breaking the linearity rules.

GHCGenerically1 is otherwise safe to use with derived GHC.Generics.Generic instances, which are linear. If you choose to use it with a hand-written instance, you should check that the underlying instance is linear.

Example
data Foo a = Bar a (Either Int a) | Baz (Maybe a) Int
  deriving stock (Show, GHC.Generics.Generic)
  deriving Generic1 via GHCGenerically1 Foo
Instances2Generic1, Rep1
  • (forall (a :: k). Generic (f a), CheckValid f) => Generic1 (GHCGenerically1 f)Defined in linear-generics-0.2.3 · Generics.Linear.Unsafe.ViaGHCGenerics
  • type Rep1 (GHCGenerically1 f) = MakeRep1 (MarkedRep f)Defined in linear-generics-0.2.3 · Generics.Linear.Unsafe.ViaGHCGenerics