h$#       !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmn o p q r s t u v w x y z { | } ~                         None>large-genericsRepresentation of some record aThe f parameter describes which functor has been applied to all fields of the record; in other words Rep I$ is isomorphic to the record itself.large-generics Strict mapmap' f x is strict in x: if x is undefined, map f x" will also be undefined, even if f never needs any values from x.!large-genericsConvert  to list"large-genericsConvert list to >Does not check that the list has the right number of elements.#large-genericsConvert list to Does not check that the list has the right number of elements, nor the types of those elements.$large-generics'Avoid potential segfault with ghc < 9.0See  1https://gitlab.haskell.org/ghc/ghc/-/issues/16893. I haven't actually seen this fail in large-records, but we saw it fail in the compact representation branch of sop-core, and what we do here is not so different, so better to play it safe.  !"#$ "# !$None '(/>? @6large-genericsConstraints a c means "all fields of a satisfy c"7large-genericsType-level metadataNOTE: using type-level lists without resulting in quadratic core code is extremely difficult. Any use of this type-level metadata therefore needs delibrate consideration. Some examples: o Within the large-generics library, 7! is used in the definition of  HasNormalForm. This constraint is carefully defined to avoid quadratic code, as described in the presentation "Avoiding Quadratic Blow-up During Compilation"  https://skillsmatter.com/skillscasts/17262-avoiding-quadratic-blow-up-during-compilation o The  large-records library uses it to provide a compatibility layer between it and sop-core; this is however only for testing purposes, and the quadratic code here is simply accepted.8large-generics#Translate to generic representation9large-generics%Translate from generic representation:large-genericsConstruct vector of dictionaries, one for each field of the record;large-genericsMetadata4 '()*+,-./01234567:89;<4567:89;/01234,-.<*+)(' None- Dlarge-genericsMap with indexThis is an important building block in this module. Crucially, mapWithIndex f a is lazy in a, reading elements from a only if and when f demands them.Glarge-genericsHigher-order version of  *Lazy in the second argument. >?@ABCDEFGHIJKLMNOPHIJKNMLPO EFG>?@ABCDNone zQlarge-genericsTypes with a lower boundQRSQRSNone#$ YZYZNone #$'(/}]large-genericsGHC generics metadataTODO: Currently we provide metadata only for the record fields, not the constructor or type name`large-generics&Route from GHC generics to LR genericsSuppose a function such as allEqualTo :: Eq a => a -> [a] -> Bool allEqualTo x = all (== x)is instead written as allEqualTo :: (GHC.Generic a, GHC.GEq' (GHC.Rep a)) => a -> [a] -> Bool allEqualTo x = all (GHC.geqdefault x)where instead of using an indirection through an auxiliary type class , it directly assumes  GHC.Generics and uses a concrete generic implementation. Such design is arguably questionable, but for example  beam-core contains many such deeply ingrained assumptions of the availability of  GHC.Generics.>In order to be able to call such a function on a large record Foo,  largeRecord will generate an instance instance GHC.Generic Foo where type Rep Foo = ThroughLRGenerics Foo from = WrapThroughLRGenerics to = unwrapThroughLRGenericsFor our running example, this instance makes it possible to call  allEqualTo& provided we then provide an instance instance ( LR.Generic a , LR.Constraints a Eq ) => GHC.GEq' (ThroughLRGenerics a) where geq' = LR.geq `on` unwrapThroughLRGenerics Effectively, ` can be used to redirect a function that uses GHC generics to a function that uses LR generics. [\]^_`abc `ab]^_[\cNoneHdlarge-genericsGeneric equality functionTypical usage:  instance Eq T where (==) = geq2TODO: Should we worry about short-circuiting here?dedeNone'(-/2>?jlarge-genericsTranslate constraints When using i%, if you start with something of type Rep f a!you end up with something of type NP (Field f) (MetadataOf a)When doing so, j can translate Constraints a (Compose c f)5(which is useful over the original representation) to (All (Compose c (Field f)) (MetadataOf a)2which is useful for the translated representation.fghijkfghijk None#$nlarge-genericsGeneric definition of (, compatible with the GHC generated one.Typical usage: .instance Show T where showsPrec = gshowsPrecnn None-./9>?e{large-genericsConstruct normal formTODO: Documentation.opqrstuvwxyz{|}~xvwyzuts{|rq}~op None'(>? glarge-genericsLens into a regular recordSee large-genericsRegular record fieldsFor a higher-kinded record tbl f", parameterized over some functor f, we say that the fields are regular iff every field has the form f x for some x.large-generics Proof that x is a regular fieldSee large-genericsLens for higher-kinded recordSee  for details.large-generics-Construct lenses for each field in the recordNOTE: This is of limited use since we cannot pattern match on the resulting  in any meaningful way. It is possible to go through the SOP adapter, but if we do, we incur quadratic cost again.We can do better for higher-kinded records, and better still for regular higher-kinded records. See  and .large-generics Lenses for higher-kinded recordsNOTE: The lenses constructed by this function are primarily intended for further processing, either by 5 or using application specific logic. Details below.Suppose we have a record tbl f which is indexed by a functor f(, and we want to construct lenses from tbl f) to each field in the record. Using the  Transform( infrastructure, we can construct a lens tbl f ~~> Rep I (tbl f) ~~> Rep (Interpret (d f)) (tbl Uninterpreted)Using  we can construct a lens of type ?Rep (Interpret (d f)) (tbl Uninterpreted) ~~> Interpret (d f) xfor every field of type x,. Putting these two together gives us a lens tbl f ~~> Interpret (d f) xfor every field in tbl Uninterpreted. We cannot simplify this, because we do not know anything about the shape of x*; specifically, it might not be equal to Uninterpreted x' for some x', and hence we cannot simplify the target type of the lens. We can do better for records with regular fields; see .large-generics5Lenses into higher-kinded records with regular fields We can use  to construct a  of lenses into a higher-kinded record. If in addition the record is regular, we can use the record type itself to store all the lenses.   !"#$%&'&(&)**+,-./01234567789:;;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdeffgghijklmnoopqr^st u v w x y z { | } } ~                               -large-generics-0.2.0.0-6p3oGyvgacw2v6kGLXr3dTData.Record.Generic Data.Record.Generic.Rep.InternalData.Record.Generic.RepData.Record.Generic.LowerBoundData.Record.Generic.JSONData.Record.Generic.GHCData.Record.Generic.EqData.Record.Generic.SOPData.Record.Generic.ShowData.Record.Generic.TransformData.Record.Generic.Lens.VLbase Data.ProxyProxy'sop-core-0.5.0.2-JiJuIvMQflQ495Q0ZwTtHX Data.SOP.DictDictData.SOP.BasicFunctors:.:CompIKunKunIunCompmapIImapIKmapKImapKKmapIIImapIIKmapIKImapIKKmapKIImapKIKmapKKImapKKKData.SOP.Classes-.->FnapFnRepmap' sequenceAcollapse toListAnyunsafeFromListunsafeFromListAnynoInlineUnsafeCo$fEqRep $fShowRepIsField FieldType FieldName FieldMetadataFieldStrictness FieldStrict FieldLazyMetadata recordNamerecordConstructor recordSizerecordFieldMetadataGeneric Constraints MetadataOffromtodictmetadatarecordFieldNames$fIsFieldfieldIndex indexToInt getAtIndex putAtIndex updateAtIndex allIndices mapWithIndexpurecpureapmapmapMcmapcmapMzipWithMzipWithzip czipWithMczipWith LowerBound lowerBound glowerBound$fLowerBound[]$fLowerBound()$fLowerBoundChar$fLowerBoundBool$fLowerBoundWordgtoJSON gparseJSONGhcFieldMetadata GhcMetadataghcMetadataFieldsThroughLRGenericsWrapThroughLRGenericsunwrapThroughLRGenerics ghcMetadatageqgcompareFieldfromSOPtoSOP toDictAll $fEqField $fShowField gshowsPrecStandardInterpretationstandardInterpretationDefaultInterpretation UninterpretedIfEqual InterpretTo HasNormalForm Interpret InterpretedliftInterpretedliftInterpretedA2 normalize denormalize normalize1 denormalize1toStandardInterpretationfromStandardInterpretation6$fStandardInterpretationTYPETYPEDefaultInterpretationfRepLensRegularRecordLensIsRegularFieldisRegularField RegularField HKRecordLensSimpleRecordLenslensesForSimpleRecordlensesForHKRecordlensesForRegularRecord repLenses genericLensnormalForm1LensinterpretedLensstandardInterpretationLens$fIsRegularFieldffghc-prim GHC.ClassesEqGHC.Show showsPrec