Construct a type with the same shape as the one you wish to
instantiate, but with only linear fields. Strictness annotations
and UNPACK pragmas are irrelevant here.
Instantiate Generics.Linear.Generic1 for the lookalike using
deriveGeneric1 and follow the same procedure
as above (but with Rep1 T, of course) to get a metadata-stripped
representation.
For either
To avoid confusion, replace at least the package and module names in the
representation with Any. Wrap MP1 around any nonlinear/representation
polymorphic fields, just under the S1 type constructor. The first type
argument of MP1 will indicate the multiplicity.
FixupMetaData a g copies the metadata from the
GHC.Generics.Generic representation of a to the
representation g. It also checks that the structure of Rep a is the
same as g, except that g may have MP1 applications under some S1
constructors.
Example
instance Generic (Prelude.Linear.Ur a) where
type Rep (Ur a) = FixupMetaData (Ur a)
(D1 Any
(C1 Any
(S1 Any
(MP1 'Many (Rec0 a)))))
FixupMetaData1 f g copies the metadata from the
GHC.Generics.Generic representation of f Any
to the representation g. It also checks that the overall structure of
Rep (f Any) is the same as g, but does not check that their fields
match.
Example
instance Generic1Prelude.Linear.Ur where
type Rep1 Ur = FixupMetaData1 Ur
(D1 Any
(C1 Any
(S1 Any
(MP1 'Many Par1))))