Ξυ³h&%D"˜      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefg h i j k l m n o p q r s t u v w x y z { | } ~  €  ‚ ƒ „ … † ‡ ˆ ‰ Š ‹ Œ  Ž   ‘ ’ “ ” • – —  Safe-InferredΑΓΝΧΩΪά΄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.  !"#$ "# !$ Safe-Inferred )*1ΑΒΓΜΩΪ \6large-genericsConstraints a c means "all fields of a satisfy c"7large-genericsType-level metadata»NOTE: 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-genericsΒConstruct vector of dictionaries, one for each field of the record;large-genericsMetadata4 '()*+,-./01234567:89;<4567:89;/01234,-.<*+)('  Safe-Inferred/ΧΩΪάο %Dlarge-genericsMap with indexΐThis 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>?@ABCD Safe-Inferredο ήQlarge-genericsGeneric rnf functionTypical usage: $instance NFData T where rnf = grnfQQ Safe-Inferredο5Rlarge-genericsTypes with a lower boundRSTRST Safe-Inferred%&ΩΪάοlZ[Z[ Safe-Inferred %&)*1ΜΧΩΪάοJ^large-genericsGHC generics metadataαTODO: Currently we provide metadata only for the record fields, not the constructor or type namealarge-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 = unwrapThroughLRGenericsΑFor 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, aΰ can be used to redirect a function that uses GHC generics to a function that uses LR generics. \]^_`abcd abc^_`\]d Safe-Inferredοelarge-genericsGeneric equality functionTypical usage:  instance Eq T where (==) = geq2TODO: Should we worry about short-circuiting here?efef  Safe-Inferred)*/15ΑΒΓΔΕΜΩΪάοτώklarge-genericsTranslate constraints When using j%, 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, k 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.ghijklghijkl  Safe-Inferred%&άοΦolarge-genericsGeneric definition of ™(, compatible with the GHC generated one.Typical usage: .instance Show T where showsPrec = gshowsPrecoo  Safe-Inferred/01<ΑΒΓΔΕΜΩΪάο\|large-genericsConstruct normal formTODO: Documentation.pqrstuvwxyz{|}~€ywxz{vut|}sr~pq€  Safe-Inferred)*ΑΒΓΔΕΜΧΩΪάοτ!Β…large-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ΐThe standard van Laarhoven representation for a monomorphic lenslarge-generics-Construct lenses for each field in the recordΝNOTE: 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 recordsθNOTE: 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.ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–Ž‹Œ…†‘‰Š‡ˆƒ„’“”•–›   !"#$%&'(')'*++,-./01234567889:;<<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghhiijklmnop q q r s t ` u v w x y z { | } ~   €  ‚ ƒ „ … † ‡ ˆ ‰ Š Š ‹ ‹ Œ  Ž Ž     ‘ ’ “ ” • – — ˜ ™š›œ ž Ÿ +large-generics-0.2.1-7k7ToTkC9kFJZ2Nh0mytSSData.Record.Generic Data.Record.Generic.Rep.InternalData.Record.Generic.RepData.Record.Generic.NFDataData.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-8cmRYB37llUAjnR98I5kI0 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 czipWithMczipWithgrnf 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 showsPrecLens'