h&R      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~                                                                                                                                                                                                                                       Safe-Inferred data-diverseConstrained Foldable for a specified type instead for all types. Safe-Inferred1s data-diverseConvert something v into r using handlers. This class is required in order to step through all the different types in a variant. Safe-Inferred01 data-diverseZips up xs and ys, which must be the same length data-diverse The typelist xs replaced by ys at the indices ns. ns and ys must be the same length. ns must be within bounds of xs data-diverse The type x replaced by an y if an n matches i.  data-diverse The typelist zs with the first xs replaced by ys. xs must be the same size as ys  data-diverse The typelist xs with the first x replaced by y. It is okay for x not to exist in xs  data-diverse The typelist xs with the type at Nat n replaced by y. n must be within bounds of xs  data-diverse The typelist xs without the type at Nat n. n must be within bounds of xs  data-diverse)Ensures two typelists are the same length data-diverseLabelled access into the list data-diverseIndexed access into the list data-diverseEnsures that the label in tagged label v only ever appears once in xs. data-diverse Ensures that x only ever appears once in xs data-diverseEnsures that the type list contain unique types. Not implemented as  (xs ~ Nub xs) for better type error messages. data-diverse&Errors if a label exists in a typelist data-diverse%Errors if a type exists in a typelist data-diverseSearches for y in ys if not found, than use y, and repeat search with next (y ': ys) in ctx else if found, then don't use y, then repeat search with next (y ': ys) in ctx data-diverse)Get the first index of a type from a list data-diverseGet the first position of a type (indexed by 1) Will return 0 if x doesn't exists in xs.   Safe-Inferred!/01"+ data-diverse'This is useful as a level function for k in  CaseFunc1 C stands for constraints. C0 is a type level function of Type -> Constraint data-diverse9Tests if all the types in a typelist satisfy a constraint  data-diverse(Returns a list of results from applying % to every type in the xs typelist and peeling off the  layer.! data-diverse"Throws a relevant type error if a  can not be used with  ." data-diverse*Throws a custom type error when the given  is stuck.0Based on the solution proposed in this article:  1https://kcsongor.github.io/report-stuck-families/.# data-diverse9A dummy type whose kind matches the one expected for any  used with  .$ data-diverse'Return a list of results from applying % to every type in the xs typelist.% data-diverseThe result from evaluating a Case with a type from a typelist.& data-diverseTakes two lists which must be the same length and returns a list of corresponding pairs.' data-diverse!Returns the typelist without the + type( data-diverse Returns a xs appended with ys) data-diverse-Set complement. Returns the set of things in xs that are not in ys.* data-diverse)Ensures two typelists are the same length, data-diverse Get the first type in a typelist- data-diverseGet the typelist without the , type. data-diverse The typelist xs replaced by ys at the indices ns. ns and ys must be the same length. ns must be within bounds of xs/ data-diverse The typelist xs without the type at Nat n replaced by y. n must be within bounds of xs0 data-diverse The typelist xs without the type at Nat n. n must be within bounds of xs1 data-diverse The typelist zs with the first xs replaced by ys. xs must be the same size as ys2 data-diverse The typelist xs with the first x replaced by y. It is okay for x not to exist in xs3 data-diverse The typelist xs without first x. It is okay for x not to exist in xs4 data-diverseGet the types with labels ls from xs5 data-diverse!Get the types at an list of index6 data-diverseIt's actually ok for the position to be zero, but if it's not zero then the types must match7 data-diverseGet the type at a label8 data-diverseGet the type at an index9 data-diverseGet the first index of a type (Indexed by 1) Will return 0 if x doesn't exists in xs.: data-diverseGet the first index of a type (Indexed by 0) Will result in type error if x doesn't exist in xs.; data-diverseEnsures that the label list all <s< data-diverseEnsures that the label in tagged label v only ever appears once in xs.= data-diverse Ensures that x only ever appears once in xs> data-diverse/Return the list of distinct types in a typelist? data-diverse/Ensures that the type list contain unique types@ data-diverse Ensures x is a unique member in xs iff it exists in ysA data-diverse For each y in ys, snocs them to end of xs if y doesn't already exist in xsB data-diverseSnoc x to end of xs if x doesn't already exist in xsC data-diverse Ensures that x is a member of xs at n if it exists, and that J can be used.D data-diverse Ensures that x is a member of xs at n , and that J can be used.E data-diverse Ensures that x is a unique member of xs if it exists, and that J can be used.F data-diverse Ensures that x is a unique member of xs , and that J can be used.G data-diverse Every x in xs is a `UniqueMember x ys`H data-diverse Ensures that x is a unique member of xs , and that J can be used.I data-diverseProduce a runtime  value corresponding to a  type. Based on  https://github.com/VinylRecords/Vinyl/blob/a5ffd10fbc747c5366ae9806e61bf45f78c3eb33/Data/Vinyl/TypeLevel.hs This is used instead of  because to avoid inefficient   1https://github.com/louispan/data-diverse/issues/8 AllowsAmbiguousTypes! Uses TypeApplication instead of Proxy3 !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJ3IJHGFEDCBA@?>=<;:9876543210/.-,+*)('&%$#"!  Safe-Inferred01#S data-diverseAllows iterating over the types in a typelist, whilst also incrementing an Nat indexT data-diverse&Return the next iteration without the , type x in (x ': xs)U data-diverse-Allows iterating over the types in a typelistV data-diverse&Return the next iteration without the , type x in (x ': xs)STUVUVST Safe-Inferred1%W data-diverse8This class allows defining handlers that can handle the , type in the xs typelist. In conjunction with , you can define handlers that can handle all the types in the xs typelist.See Data.Diverse.CaseFunc and Data.Diverse.Cases.X data-diverse3Return the handler/continuation when x is observed.WXWX Safe-Inferred/11 Y data-diverse A variant of Y0 for which the type of both containers is fixed.[ data-diverse A variant of _ with more constraints.] data-diverse A variant of _0 for which the type of both containers is fixed.let ps = Predicate @Int (> 5) ./ Predicate isLetter ./ Predicate id ./ nil;let ps' = cases $ afmap (CaseIxedCont_ @C0 getPredicate) ps4switch (pick @Int @'[Int, Bool, Char] 5) ps' :: BoolFalse5switch (pick @Char @'[Int, Bool, Char] 6) ps' :: BoolTrue7switch (pick @Char @'[Int, Bool, Char] '_') ps' :: BoolFalse6switch (pick @Int @'[Int, Bool, Char] 'a') ps' :: BoolTrue9switch (pick @Bool @'[Int, Bool, Char] False) ps' :: BoolFalse8switch (pick @Bool @'[Int, Bool, Char] True) ps' :: BoolTrue_ data-diverseThis handler stores a polymorphic function which maps containers to continuations.'This is especially useful for building  using  .a data-diverse A variant of c0 for which the type of both containers is fixed.c data-diverse A variant of g with more constraints.:let xs = (Just @Int 5) ./ Right @Int False ./ "XYZ" ./ nilatraverse (CaseIxedFuncM1 @C0 @Foldable @C0 @[] @Maybe $ Just . toList) xs%Just ([5] ./ [False] ./ "XYZ" ./ nil)e data-diverse A variant of g0 for which the type of both containers is fixed.g data-diverse A variant of o2 which maps containers within an additional layer.,let f (x :: f a) = Const @String @a $ show xlet xs = (Just @Int 5) ./ Right @Int False ./ "X" ./ (Left @Int @Bool 6) ./ nil9atraverse (CaseIxedFuncM @Show $ \x -> f x <$ print x) xsJust 5 Right False"X"Left 6Const "Just 5" ./ Const "Right False" ./ Const "\"X\"" ./ Const "Left 6" ./ nili data-diverse A variant of k0 for which the type of both containers is fixed.k data-diverse A variant of o with more constraints.let xs = (Just @Int 5) ./ Right @Int False ./ "X" ./ (Left @Int @Bool 6) ./ nil1afmap (CaseIxedFunc1 @C0 @Foldable @C0 toList) xs"[5] ./ [False] ./ "X" ./ [] ./ nil5atraverse (CaseIxedFunc1 @C0 @Foldable @C0 toList) xs[]:let ys = (Just @Int 5) ./ Right @Int False ./ "XYZ" ./ nil5atraverse (CaseIxedFunc1 @C0 @Foldable @C0 toList) ys[5 ./ False ./ 'X' ./ nil,5 ./ False ./ 'Y' ./ nil,5 ./ False ./ 'Z' ./ nil]m data-diverse A variant of o0 for which the type of both containers is fixed.o data-diverseThis handler stores a polymorphic function which changes the type of the containers.,let f (x :: f a) = Const @String @a $ show xlet xs = (Just @Int 5) ./ Right @Int False ./ "X" ./ (Left @Int @Bool 6) ./ nilafmap (CasedIxedFunc @Show f) xs :: Many '[Const String Int, Const String Bool, Const String Char, Const String Bool]Const "Just 5" ./ Const "Right False" ./ Const "\"X\"" ./ Const "Left 6" ./ nilatraverse (CasedIxedFunc @Show f) xs :: Const String (Many '[Int, Bool, Char, Bool])$Const "Just 5Right False\"X\"Left 6"YZ[\]^_`abcdefghijklmnopopmnklijghefcdab_`]^[\YZ Safe-Inferred/16W data-diverseA varation of $ that doesn't change the return type data-diverseThis handler stores a polymorphic function that work on higher kinds, eg  You may want to use C0 for k@ data-diverseThis handler stores a polymorphic function that doesn't change the type. let x = (5 :: Int)  (6 :: Int8)  (7 :: Int16)  (8 :: Int32)   y = (15 :: Int)  (16 :: Int8)  (17 :: Int16)  (18 :: Int32)     ( @ (+10)) x `shouldBe` y  data-diverseThis handler stores a polymorphic function that returns a different type. let y =  (5 :: Int) ::  '[Int, Bool]  y ( @. (show . typeRep . (pure @Proxy))) `shouldBe` Int let x = (5 :: Int)  False  'X'  Just 'O'  (6 :: Int)  Just 'A'    (:) [] ( ( @ (show . typeRep . (pure @Proxy))) x) `shouldBe` ["Int", "Bool", "Char", "Maybe Char", "Int", "Maybe Char"]    Safe-Inferred8? data-diverseGiven a 6 that transforms each type in the typelist within an  context m , convert a f xs to m (f (  c m xs)) , where (  c m xs) corresponds to ($ (c m) xs) with the m# layer peeled off from each result.(This is primarily meant to be used with  s from the Data.Diverse.CaseIxed module.  Safe-Inferred8 data-diverseGiven a 7 that transforms each type in the typelist, convert a f xs to f (CasesResults c xs) None)*/012w data-diverse avoids the following: Illegal type synonym family application in instance: Any data-diverse)A friendlier type constraint synomyn for  data-diverse)A friendlier type constraint synomyn for  data-diverse)A friendlier type constraint synomyn for  data-diverse)A friendlier type constraint synomyn for  data-diverse)A friendlier type constraint synomyn for  data-diverseFor each type x in larger, generate the (k, v) in smaller (if it exists) data-diverse)A friendlier type constraint synomyn for  data-diverse)A friendlier type constraint synomyn for  and  data-diverseA variation of  which uses S instead of U data-diverse)A friendlier type constraint synomyn for  and  data-diverseCollects the output from Xing each field in a . Uses U to prepare the W to accept the next type in the xs typelist.Internally, this holds the left-over [(k, v)] from the original  for the remaining typelist xs..That is, the first v in the (k, v) is of type x7, and the length of the list is equal to the length of xs. data-diverseA variation of  which uses  instead of W data-diverse Variation of  which uses  instead of W data-diverse3Return the handler/continuation when x is observed. data-diverseThis instance allows converting to and from Many There are instances for converting tuples of up to size 15. data-diverse8Many stored as a list. This is useful when folding over = efficienty so that the conversion to List is only done once data-diverseA Many is an anonymous product type (also know as polymorphic record), with no limit on the number of fields.The following functions are available can be used to manipulate unique fields getter/setter for single field:  and #getter/setter for multiple fields:  and folds:  or These functions are type specified. This means labels are not required because the types themselves can be used to access the 'Many. It is a compile error to use those functions for duplicate fields.For duplicate fields, Nat-indexed versions of the functions are available: getter/setter for single field:  and #getter/setter for multiple fields:  and folds:  or Encoding: The record is encoded as (S.Seq Any). This encoding should reasonabily efficient for any number of fields.The map Key is index + offset of the type in the typelist. The Offset is used to allow efficient cons . (Key = Index of type in typelist + OffsetThe constructor will guarantee the correct number and types of the elements. The constructor is only exported in the Data.Diverse.Many.Internal module data-diverse(Converts from a value (eg a tuple) to a , via a  wrapper data-diverseConverts from a Many to a value (eg a tuple), via a Tagged wrapper data-diverseEmpty . data-diverse0Create a Many from a single value. Analogous to  data-diverse1Add an element to the left of a Many. Not named cons to avoid conflict with  ! data-diverseInfix version of .)Mnemonic: Element on the left is smaller  than the larger  to the right. data-diverse1Add an element to the right of a Many Not named snoc to avoid conflict with  " data-diverseAdd an element to the right of a Many iff the field doesn't already exist. data-diverseInfix version of .Mnemonic: Many is larger  than the smaller element data-diverseInfix version of . Mnemonic:   with an extra slash (meaning  ) in front. data-diverseAppends two Manys together data-diverseSplit a non-empty Many into the first element, then the rest of the Many. Analogous to  data-diverseSplit a non-empty Many into initial part of Many, and the last element. Analogous to  data-diverseExtract the first element of a Many, which guaranteed to be non-empty. Analogous to  data-diverse Extract the  element of a Many, which guaranteed to be non-empty. Analogous to #$ data-diverseExtract the elements after the front of a Many, which guaranteed to be non-empty. Analogous to  data-diverse-Return all the elements of a Many except the 6 one, which guaranteed to be non-empty. Analogous to #% data-diverse/Getter by unique type. Get the field with type x. let x = (5 :: Int)  False  'X'  Just 'O'    @Int x `shouldBe` 5  data-diverse5Getter by label. Get the value of the field with tag label! which can be any type not just  KnownSymbol. let y = False  Tagged @Foo 'X'  Tagged @Hi True   # @Foo y `shouldBe` Tagged @Foo 'X'  @Hi y `shouldBe` Tagged @Hi True  data-diverse Variation of  of a Tagged field  that untags the field. data-diverseGetter by index. Get the value of the field at index type-level Nat n let x = (5 :: Int)  False  'X'  Just 'O'    @1 x `shouldBe` False  data-diverse/Setter by unique type. Set the field with type x. let x = (5 :: Int)  False  'X'  Just 'O'    @Int x 6 `shouldBe` (6 :: Int)  False  'X'  Just 'O'    data-diverse;Polymorphic setter by unique type. Set the field with type x, and replace with type y let x = (5 :: Int)  False  'X'  Just 'O'   ) @Int x (Just True) `shouldBe` Just True  False  'X'  Just 'O'    data-diverse1Setter by unique label. Set the field with label l. let y = (5 :: Int)  False  Tagged @Foo 'X'  Tagged @"Hello" (6 :: Int)   4 @Foo y (Tagged @Foo 'Y') `shouldBe` (5 :: Int)  False  Tagged @Foo 'Y'  Tagged @"Hello" (6 :: Int)   : @"Hello" y (Tagged @"Hello" 7) `shouldBe` (5 :: Int)  False  Tagged @Foo 'X'  Tagged @"Hello" (7 :: Int)    data-diverse;Polymorphic setter by unique type. Set the field with type x, and replace with type y let y = (5 :: Int)  False  Tagged @Foo 'X'  Tagged @"Hello" (6 :: Int)  # replaceL @Foo y (Tagged @Bar 'Y') shouldBe (5 :: Int)  False  Tagged Bar Y  Tagged Hello (6 :: Int)   replaceL @"Hello" y (Tagged @"Hello" False) `shouldBe` (5 :: Int)  False  Tagged @Foo 'X'  Tagged @"Hello" False    data-diverse Variation of  specialized to 2 that automatically tags the value to be replaced. data-diverse Variation of  specialized to 2 that automatically tags the value to be replaced. data-diverseSetter by index. Set the value of the field at index type-level Nat n let x = (5 :: Int)  False  'X'  Just 'O'    @0 x 7 shouldBe  data-diversePolymorphic version of  data-diverse3Internal function for construction - do not expose! data-diverse Folds any %, even with indistinct types. Given distinct handlers for the fields in  , create < of the results of running the handlers over the fields in . let x = (5 :: Int)  False  'X'  Just 'O'  (6 :: Int)  Just 'A'   y = show @Int  show @Char  show @(Maybe Char)  show @Bool    (:) [] ( ( & y) x) `shouldBe` ["5", "False", "'X'", "Just 'O'", "6", "Just 'A'"]  data-diverseThis is flip  let x = (5 :: Int)  False  'X'  Just 'O'  (6 :: Int)  Just 'A'   y = show @Int  show @Char  show @(Maybe Char)  show @Bool    (:) [] ( x ( & y)) `shouldBe` ["5", "False", "'X'", "Just 'O'", "6", "Just 'A'"]  data-diverse Folds any %, even with indistinct types. Given index handlers for the fields in  , create < of the results of running the handlers over the fields in . let x = (5 :: Int)  False  'X'  Just 'O'  (6 :: Int)  Just 'A'   y = show @Int  show @Bool  show @Char  show @(Maybe Char)  show @Int  show @(Maybe Char)    (:) [] ( ( ' y) x) `shouldBe` ["5", "False", "'X'", "Just 'O'", "6", "Just 'A'"]  data-diverseThis is flip  let x = (5 :: Int)  False  'X'  Just 'O'  (6 :: Int)  Just 'A'   y = show @Int  show @Bool  show @Char  show @(Maybe Char)  show @Int  show @(Maybe Char)    (:) [] ( x ( ' y)) `shouldBe` ["5", "False", "'X'", "Just 'O'", "6", "Just 'A'"]  data-diverse Construct a  with a smaller number of fields than the original. Analogous to  getter but for multiple fields.8This can also be used to reorder fields in the original . let x = (5 :: Int)  False  'X'  Just 'O'  (6 :: Int)  Just 'A'   # @'[Bool, Char] x `shouldBe` False  'X'    data-diverseA variation of  which selects by labels let x = False  Tagged @"Hi" (5 :: Int)  Tagged @Foo False  Tagged @Bar 'X'  Tagged @"Bye" O   - @'[Foo, Bar] x `shouldBe` Tagged @Foo False  Tagged @Bar 'X'   6 @'["Hi", "Bye"] x `shouldBe` Tagged @"Hi" (5 :: Int)  Tagged @"Bye" 'O'    data-diverseA variation of  which uses a Nat list n, to specify how to reorder the fields, where  indices[branch_idx] = tree_idx@ This variation allows smaller or larger: to contain indistinct since the mapping is specified by indicies. let x = (5 :: Int)  False  'X'  Just 'O'  (6 :: Int)  Just 'A'   # @'[5, 4, 0] x `shouldBe` Just 'A'  (6 :: Int)  (5 ::Int)    data-diverseSets the subset of  in the larger . Analogous to  setter but for multiple fields. let x = (5 :: Int)  False  'X'  Just 'O'   # @'[Int, Maybe Char] x ((6 :: Int)  Just 'P'  ) `shouldBe` (6 :: Int)  False  'X'  Just 'P'    data-diverseA variation of  which amends via labels. let x = False . Tagged @"Hi" (5 :: Int) . Tagged @Foo False . Tagged @Bar 'X' . Tagged @"Bye" 'O' ./  # @'[Foo, Bar] x (Tagged @Foo True . Tagged @Bar 'Y' . nil) shouldBe False . Tagged @"Hi" (5 :: Int) . Tagged @Foo True . Tagged @Bar 'Y' . Tagged @"Bye" 'O' ./  - @'["Hi", "Bye"] x (Tagged @"Hi" (6 :: Int) . Tagged @"Bye" 'P' . nil) shouldBe False . Tagged @"Hi" (6 :: Int) . Tagged @Foo False . Tagged @Bar 'X' . Tagged @"Bye" 'P' ./   data-diversePolymorphic version of . Analogous to  setter but for multiple fields. data-diverseA variation of  which amends via labels. let x = False  Tagged @"Hi" (5 :: Int)  Tagged @Foo False  Tagged @Bar X  Tagged @"Bye" 'O'    @'[Foo, Bar] x ('Y'  True  nil) `shouldBe` False  Tagged @"Hi" (5 :: Int)  'Y'  True  Tagged @"Bye" 'O'    @'["Hi", "Bye"] x (True  Tagged @"Changed" True  ) `shouldBe` False  True  Tagged @Foo False  Tagged @Bar 'X'  Tagged @"Changed" True    data-diverseA variation of  which uses a Nat list n, to specify how to reorder the fields, where  indices[branch_idx] = tree_idx@ This variation allows smaller or larger: to contain indistinct since the mapping is specified by indicies. let x = (5 :: Int)  False  'X'  Just 'O'  (6 :: Int)  Just 'A'    @'[5, 4, 0] x (Just 'B'  (8 :: Int)  (4 ::Int)  ) `shouldBe` (4 :: Int)  False  'X'  Just 'O'  (8 :: Int)  Just 'B'    data-diverseA polymorphic variation of  data-diverseA  instance encoded as the  value  with the  . The  and  metadata are not encoded. data-diverseA terminating  instance encoded as a . data-diverse  read "5 . False . X . Just O . nil" == (5 :: Int)  False  'X'  Just 'O'   data-diverse show (5 :: Int)  False  'X'  Just 'O'   == "5 . False . X . Just O . nil" == data-diverseTwo s are ordered by ing their fields in index order data-diverseTwo %s are equal if all their fields equal data-diverseGiven a 7 that transforms each type in the typelist, convert a Many xs to Many (CaseResults c xs) data-diverseRecursive AFunctor instance for non empty type list delegate afmap'ing the remainder to an instance of Collector' with one less type in the type list data-diverse1Terminating AFunctor instance for empty type list data-diverse-This single field instance is the reason for 0 wrapper. Otherwise this instance will overlap. data-diverse8These instances add about 7 seconds to the compile time! data-diverse nill case that doesn't even use , so that an instance of  CaseAny '[] is not needed. data-diverse nill case that doesn't even use caseAnyN, so that an instance of  CaseAnyN '[] is not needed. data-diverseFolds values by Ving Ws through the xs typelist. data-diverse nill case that doesn't even use X, so that an instance of Case '[] is not needed. data-diverseFolds values by Ving Emitters through the xs typelist. data-diverse nill case that doesn't even use X, so that an instance of Case '[] is not needed. data-diversefor each x in smaller1, convert it to a (k, v) to insert into the x in larger data-diversefor each x in smaller1, convert it to a (k, v) to insert into the x in larger data-diversefor each y in smaller1, convert it to a (k, v) to insert into the x in  Many larger data-diversefor each x in smaller1, convert it to a (k, v) to insert into the x in  Many larger data-diverseFor each type x in larger?, find the index in ys, and create an (incrementing key, value) data-diverseFor each type x in larger, find the index in ys, and create a (key, value)995555555 Safe-Inferredy488  Safe-Inferred/1` data-diverseA variation of  which uses  to get the handler by index. There may be different handlers for the same type, but the handlers must be in the same order as the input xs typelist. Use # to construct this safely ensuring n starts at 0. data-diverse Contains a 4 of handlers/continuations for all the types in the xs typelist. This uses / to get the unique handler for the type at the , of xs.Use  to construct this with *, constraint to reduce programming confusion. data-diverseCreate an instance of W for either handling ing a Which. let y =  (5 :: Int) ::  '[Int, Bool]  y (  (show @Bool  show @Int  nul)) `shouldBe` "5" Or for handling  from a . let x = (5 :: Int)  False  'X'  Just 'O'  (6 :: Int)  Just 'A'  nul y = show @Int  show @Char  show @(Maybe Char)  show @Bool  nul  (:) [] ( x ($ y)) `shouldBe` ["5", "False", "X ", "Just 'O'", "6", "Just 'A'"] !This function imposes additional  SameLength! constraints than when using the 5 constructor directly. It is better practice to use  to prevent programming confusion with dead code. However, the  constructor is still exported to allow creating a master-of-all-W. data-diverseA variation of  without the  SameLength. constraint to allow creating a master-of-all-W. data-diverseSafe Constructor for  ensuring that the n( Nat starts at 0. It is an instance of CaseN for either handling (ing a Which in index order. let y = )6 @0 Proxy (5 :: Int) :: Which '[Int, Bool, Bool, Int] ( y (  (show @Int  show @Bool  show @Bool  show @Int  nul)) `shouldBe` "5" Or for handling  from a . let x = (5 :: Int)  False  'X'  Just 'O'  (6 :: Int)  Just 'A'  nul y = show @Int  show @Bool  show @Char  show @(Maybe Char)  show @Int  show @(Maybe Char)  nul  (:) [] ( x ($ y)) `shouldBe` ["5", "False", "X ", "Just 'O'", "6", "Just 'A'"]  data-diverseA variation of  without the  SameLength. constraint to allow creating a master-of-all-W. data-diverseUndecidableInstances because fs appears more often. data-diverseUndecidableInstances because fs appears more often. None()*/01y data-diverseDo not export constructor Stores the right Any to be compared when the correct type is discovered data-diverseDo not export constructor Stores the right Any to be compared when the correct type is discovered data-diverseA switch/case statement for . This is equivalent to flip Use W instances like  * to apply a 5 of functions to a variant of values in index order. let y =  @0 (5 :: Int) ::  '[Int, Bool, Bool, Int]  y (  ' (show @Int  show @Bool  show @Bool  show @Int  )) `shouldBe` "5" +Or you may use your own custom instance of W. data-diverse is a variation of  which T!s through the possibilities in a , delegating work to CaseN, ensuring termination when  only contains one type. data-diverse$A friendlier constraint synonym for  reinterpretN. data-diverse is an instance of  for which V!s through the possibilities in a , delegating handling to W, ensuring termination when  only contains one type. data-diverse$A friendlier constraint synonym for  reinterpretN. data-diverse$A friendlier constraint synonym for . data-diverse$A friendlier constraint synonym for . data-diverse$A friendlier constraint synonym for . data-diverse$A friendlier constraint synonym for . data-diverse$A friendlier constraint synonym for . data-diverse$A friendlier constraint synonym for . data-diverse$A friendlier constraint synonym for . data-diverseA  is an anonymous sum type (also known as a polymorphic variant, or co-record) which can only contain one of the types in the typelist. This is essentially a typed version of +,.The following functions are available can be used to manipulate unique types in the typelist constructor:  destructor:  injection:  and catamorphism:  or These functions are type specified. This means labels are not required because the types themselves can be used to access the . It is a compile error to use those functions for duplicate fields.For duplicate types in the list of possible types, Nat-indexed version of the functions are available: constructor:  destructor:  inejction:  and  reinterpretNcatamorphism:  or Encoding: The variant contains a value whose type is at the given position in the type list. This is the same encoding as  https://github.com/haskus/haskus-utils/blob/master/src/lib/Haskus/Utils/Variant.hsHaskus.Util.Variant and  https://hackage.haskell.org/package/HList-0.4.1.0/docs/src/Data-HList-Variant.htmlData.Hlist.Variant.(The constructor is only exported in the Data.Diverse.Which.Internal module data-diversePattern synonym that makes pattern matching on Which possible. For example, this will return Just 5: let y = pick (5 :: Int) :: Which '[Bool, String, Int] in case y of W (i :: Int) -> Just i _ -> Nothing Keep in mind, GHC is not smart enough and will always throw a warning about incomplete pattern matches without a catch-all clause. data-diverse Analogous to  . Renamed  to avoid conflicts.Since 'Which '[]' values logically don't exist, this witnesses the logical reasoning tool of "ex falso quodlibet", ie "from falsehood, anything follows".A 'Which '[]' is a , with no alternatives, which may occur as a  -over from ing a  Which '[x]6 with one type. It is an uninhabited type, just like  data-diverseA  Which '[Void] is equivalent to  Which '[] A  Which '[Void] might occur if you lift a  into a Which with ). This allows you to convert it back to  or  Which '[] data-diverseLift a value into a  of possibly other types xs. xs can be inferred or specified with TypeApplications. NB. forall is used to specify xs3 first, so TypeApplications can be used to specify xs first  'A' @_ @'[Int, Bool, Char, Maybe String] :: Which '[Int, Bool, Char, Maybe String]  data-diverseA variation of  where x is specified via a label let y =  @Foo (Tagged (5 :: Int)) :: Which '[Bool, Tagged Foo Int, Tagged Bar Char] x =  @Foo y x shouldBe (Right (Tagged 5))  data-diverse Variation of  specialized to # that automatically tags the value. data-diverseA variation of  into a  of a single type.  'A' :: Which '[Char]  data-diverseA variation of  into a  where x is the first type. ! 'A' :: Which '[Char, Int, Bool]  data-diverseLift a value into a  of possibly other (possibley indistinct) types, where the value is the n -th type. < @4 (5 :: Int) :: Which '[Bool, Int, Char, Bool, Int, Char]  data-diverseIt is  what value is inside a  of one type. let x = pick' 'A' :: Which '[Char]  x `shouldBe` 'A'  data-diverse the n-th type of a  , and get  the  value or the -over possibilities. let x = - 'A' @_ @'[Int, Bool, Char, Maybe String] :: " '[Int, Bool, Char, Maybe String]  @1 x `shouldBe` Left ( 'A') ::  '[Int, Char, Maybe String]  data-diverse a type in a  and  get the  value or the -over possibilities. let x = * 'A' @'[Int, Bool, Char, Maybe String] :: " '[Int, Bool, Char, Maybe String]  @Char x `shouldBe` Right 'A'  @Int x `shouldBe` Left ( 'A') ::  '[Bool, Char, Maybe String]  data-diverseA variation of ! where x is specified via a label let y =  @Foo (Tagged (5 :: Int)) :: Which '[Bool, Tagged Foo Int, Tagged Bar Char] x =  @Foo Proxy y x shouldBe (Right (Tagged 5))  data-diverse Variation of  specialized to  which untags the field. data-diverse Variation of  which returns a Maybe data-diverse Variation of  which returns a Maybe data-diverse Variation of  which returns a Maybe data-diverse Variation of  specialized to  which untags the field. data-diverseA variation of a   which "s the first type in the type list. let x = * 'A' @'[Int, Bool, Char, Maybe String] :: " '[Int, Bool, Char, Maybe String]  x `shouldBe` Left ( 'A') ::  '[Bool, Char, Maybe String]  data-diverse Variation of  which returns a Maybe data-diverse Convert a  to another 1 that may include other possibilities. That is, branch is equal or is a subset of tree.This can also be used to rearrange the order of the types in the .It is a compile error if tree has duplicate types with branch.NB. Use TypeApplications with  _ to specify tree@. let a = pick' (5 :: Int) ::  '[Int] b =  @_ @[Int, Bool] a ::  '[Int, Bool] c =  @_ @[Bool, Int] b ::  '[Bool, Int]  data-diverseA simple version of 5 which add another type to the front of the typelist. data-diverseA restricted version of  which only rearranges the types data-diverseA variation of  where branch+is additionally specified by a labels list. let y =  (5 :: Tagged Bar Int) y' =  @'[Bar] y :: . '[Tagged Bar Int, Tagged Foo Bool] y'' =  @'[Bar, Foo] y' :: $ '[Tagged Foo Bool, Tagged Bar Int]  y'' ( @ (show . typeRep . (pure @Proxy))) `shouldBe` "Tagged * Bar Int"  data-diverseA variation of  which uses a Nat list indices, to specify how to reorder the fields, where indices[branch_idx] = tree_idx This variation allows tree! to contain duplicate types with branch$ since the mapping is specified by indicies. let y =  (5 :: Int) y' = # @'[0] @_ @[Int, Bool] y y'' =  @[1,0] @_ @[Bool, Int] y'  y'' ( @4 (show . typeRep . (pure @Proxy))) `shouldBe` "Int"  data-diverse Convert a  into possibly another 6 with a totally different typelist. Returns either a  with the  value, or a  with the over  compliment types.It is a compile error if branch or  compliment has duplicate types with tree.NB. forall used to specify branch3 first, so TypeApplications can be used to specify branch first.  let a = " @[Int, Char, Bool] (5 :: Int) :: ! '[Int, Char, Bool] let b =  ([String, Char] y b `shouldBe` Left ( (5 :: Int)) ::  '[Int, Bool] let c =  ([String, Int] a c `shouldBe` Right ( (5 :: Int)) ::  '[String, Int]  data-diverse Variation of  which returns a Maybe. data-diverseA variation of  where the branch. is additionally specified with a labels list. let y =  @[Tagged Bar Int, Tagged Foo Bool, Tagged Hi Char, Tagged Bye Bool] (5 :: Tagged Bar Int) y' =  @[Foo, Bar] y x =  @[Tagged Foo Bool, Tagged Bar Int] (5 :: Tagged Bar Int) y' `shouldBe` Right x  data-diverse Variation of  which returns a Maybe. data-diverseA limited variation of  which uses a Nat list n, to specify how to reorder the fields, where indices[branch_idx] = tree_idx This variation allows tree! to contain duplicate types with branch$ since the mapping is specified by indicies.However, unlike  reinterpert, in this variation, branch must be a subset of tree instead of any arbitrary Which. Also it returns a Maybe instead of Either.This is so that the same indices can be used in narrowN. data-diverseA switch/case statement for . This is equivalent to flip Use W instances like   to apply a % of functions to a variant of values. let y =  (5 :: Int) ::  '[Int, Bool]  y (  & (show @Bool  show @Int  )) `shouldBe` "5" Or  @2 to apply a polymorphic function that work on all Typeables. let y =  (5 :: Int) ::  '[Int, Bool]  y ( @. (show . typeRep . (pure @Proxy))) `shouldBe` Int +Or you may use your own custom instance of W. data-diverseCatamorphism for  . This is flip . data-diverseCatamorphism for . This is equivalent to flip . data-diversecoerce Which to another type without incrementing Int. THis is because $ instance already increments the int data-diverse&Succeed reading if the Int index match data-diverseRecursive AFunctor instance for non empty type list delegate afmap'ing the remainder to an instance of Collector' with one less type in the type list data-diverse1Terminating AFunctor instance for empty type list data-diverse ( zilch zilch) == EQ data-diverse (zilch == zilch ) == True data-diverseA  instance encoded as either the x value ( ) or the ed remaining 'Which xs'. The  and  metadata are not encoded. data-diverseA terminating $ instance for one type encoded with pick'. The  and  metadata are not encoded. data-diverseA terminating 6 instance for no types encoded as a 'Which '[]'. The  and  metadata are not encoded. data-diverseThe Unique x branch1 is important to get a compile error if the from branch doesn't have a unique x data-diverseAllow 'Which '[Void]' to be ed or ,ed into anything else This is safe because  Which '[Void] is uninhabited, and this is already something that can be done with  data-diverseAllow  to be ed or ,ed into anything else This is safe because Void is uninhabited, and this is already something that can be done with  data-diverseAllow 'Which '[]' to be ed or ,ed into anything else This is safe because  Which '[] is uninhabited, and this is already something that can be done with  data-diverse:Terminating case of the loop, ensuring that a instance of Case '[]) with an empty typelist is not required. data-diverse each type in a , and either handle the X with value discovered, or V( trying the next type in the type list. data-diverse:Terminating case of the loop, ensuring that a instance of Case '[]< with an empty typelist is not required. You can't reduce zilch data-diverse each type in a , and either handle the X with value discovered, or T( trying the next type in the type list. data-diverseTwo es are only equal iff they both contain the equivalnet value at the same type index. data-diverseA 9 with a type at smaller type index is considered smaller. data-diverse show (pick' 'A') == "pick 'A'" data-diverseThis  instance tries to read using the each type in the typelist, using the first successful type read.22 Safe-Inferredi11 Safe-InferredS !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJSTUVWX-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~                                                                                                                                *  &  '       (                        )                                                                                data-diverse-4.7.1.0-inplaceData.Diverse.AFoldableData.Diverse.ReduceData.Diverse.TypeLevel.InternalData.Diverse.TypeLevelData.Diverse.ReiterateData.Diverse.CaseData.Diverse.CaseIxedData.Diverse.CaseFuncData.Diverse.ATraversableData.Diverse.AFunctorData.Diverse.Many.InternalData.Diverse.CasesData.Diverse.Which.InternalCase atraverse Reiterate Data.DiverseCasesafmapData.Diverse.Many./nilData.Diverse.WhichpickWhichswitch Data.TypeableTypeablenulafoldrforMany Control.LensconssnocPreludelastinitcasescasesNswitchNpickNCasesNDataDynamic AFoldableafoldl'ReducereduceReducedZipImplReplacesIndexImplReplaceIfIndex ReplacesImpl ReplaceImplReplaceIndexImplRemoveIndexImplSameLengthImplKindAtLabelImplKindAtIndexImplUniqueLabelImpl UniqueImplIsDistinctImplIsUniqueLabelImpl IsUniqueImplNubImpl IndexOfImplPositionOfImplC6C5C4C3C2C0AllConstrainedTraverseResults'TraverseResultsIsTraversalCaseBreakNonTraversalCase TraversalCase CaseResults CaseResultZipInitAppend Complement SameLengthLastHeadTail ReplacesIndex ReplaceIndex RemoveIndexReplacesReplaceRemove KindsAtLabelsKindsAtIndicesKindAtPositionIs KindAtLabel KindAtIndex PositionOfIndexOf UniqueLabels UniqueLabelUniqueNub IsDistinctUniqueIfExists AppendUnique SnocUnique MaybeMemberAtMemberAtMaybeUniqueMemberUniqueLabelMember UniqueMembers UniqueMemberNatToIntnatToInt $fNatToIntn $fNatToInt0$fC0ka $fC2kc1c2a $fC3kc1c2c3a$fC4kc1c2c3c4a$fC5kc1c2c3c4c5a$fC6kc1c2c3c4c5c6a ReiterateN reiterateN reiteratecase'CaseIxedCont1_ CaseIxedCont1 CaseIxedCont_ CaseIxedContCaseIxedFuncM1_CaseIxedFuncM1CaseIxedFuncM_ CaseIxedFuncMCaseIxedFunc1_ CaseIxedFunc1 CaseIxedFunc_ CaseIxedFunc$fCaseCaseIxedFunc:$fReiterateCaseIxedFuncxs$fCaseCaseIxedFunc_:$fReiterateCaseIxedFunc_xs$fCaseCaseIxedFunc1:$fReiterateCaseIxedFunc1xs$fCaseCaseIxedFunc1_:$fReiterateCaseIxedFunc1_xs$fCaseCaseIxedFuncM:$fReiterateCaseIxedFuncMxs$fCaseCaseIxedFuncM_:$fReiterateCaseIxedFuncM_xs$fCaseCaseIxedFuncM1:$fReiterateCaseIxedFuncM1xs$fCaseCaseIxedFuncM1_:$fReiterateCaseIxedFuncM1_xs$fCaseCaseIxedCont:$fReiterateCaseIxedContxs$fCaseCaseIxedCont_:$fReiterateCaseIxedCont_xs$fCaseCaseIxedCont1:$fReiterateCaseIxedCont1xs$fCaseCaseIxedCont1_:$fReiterateCaseIxedCont1_xs CaseFunc1' CaseFunc1_ CaseFunc1 CaseFunc'CaseFunc$fCaseCaseFunc:$fReiterateCaseFuncxs$fCaseCaseFunc':$fReiterateCaseFunc'xs$fCaseCaseFunc1:$fReiterateCaseFunc1xs$fCaseCaseFunc1_:$fReiterateCaseFunc1_xs$fCaseCaseFunc1':$fReiterateCaseFunc1'xs ATraversableAFunctorAmendNAmendN'AmendAmend'SelectNSelectCollectN CollectorNCollect CollectorIsManytoManyfromManyManytoMany' fromMany'singleconsManysnocMany snocMany'\././appendviewfviewbfrontbackaftforegrabgrabLgrabTaggrabNreplace'replace replaceL'replaceL replaceTag' replaceTag replaceN'replaceNcollectforManyNcollectNselectselectLselectNamend'amendL'amendamendLamendN'amendN$fHashableMany $fNFDataMany $fNFDataMany0 $fGenericMany$fGenericMany0$fHashableMany0 $fReadMany $fReadMany_ $fReadMany_0 $fShowMany $fShowMany_ $fShowMany_0 $fMonoidMany $fMonoidMany_$fMonoidMany_0$fSemigroupMany$fSemigroupMany_$fSemigroupMany_0 $fOrdMany $fOrdMany_ $fOrdMany_0$fEqMany $fEqMany_ $fEqMany_0$fATraversableManycmas$fATraversableMany_cm:$fATraversableMany_cm[]$fAFunctorManycas$fAFunctorMany_c:$fAFunctorMany_c[]#$fIsManyTYPETagged:(,,,,,,,,,,,,,,)"$fIsManyTYPETagged:(,,,,,,,,,,,,,)!$fIsManyTYPETagged:(,,,,,,,,,,,,) $fIsManyTYPETagged:(,,,,,,,,,,,)$fIsManyTYPETagged:(,,,,,,,,,,)$fIsManyTYPETagged:(,,,,,,,,,)$fIsManyTYPETagged:(,,,,,,,,)$fIsManyTYPETagged:(,,,,,,,)$fIsManyTYPETagged:(,,,,,,)$fIsManyTYPETagged:(,,,,,)$fIsManyTYPETagged:(,,,,)$fIsManyTYPETagged:(,,,)$fIsManyTYPETagged:(,,)$fIsManyTYPETagged:(,)$fIsManyTYPETagged:a$fIsManyTYPETagged[]()$fAFoldableCollectorAnyr$fAFoldableCollectorAnyr0$fAFoldableCollectorAnyNr$fAFoldableCollectorAnyNr0$fAFoldableCollectorr$fAFoldableCollectorr0$fAFoldableCollectorNr$fAFoldableCollectorNr0$fReiterateCaseSelect:$fReiterateNCaseSelectNn:$fReiterateCaseAmend':$fReiterateCaseAmend:$fReiterateNCaseAmendN'n:$fReiterateNCaseAmendNn:$fCaseAnyCaseAmendN:$fCaseAnyCaseAmendN':$fCaseAnyCaseAmend:$fCaseAnyCaseAmend':$fCaseAnyCaseSelectN:$fCaseAnyCaseSelect:cases'casesN' $fCaseCasesxs$fReiterateCasesxs$fCaseCasesNxs$fReiterateNCasesNnxsSwitchN SwitcherNSwitchSwitcher ReinterpretN' ReinterpretL' ReinterpretL Reinterpret' Reinterpret DiversifyN DiversifyL DiversifyW impossible impossible'pickLpickTagpickOnlypick0obvioustrialNtrialtrialLtrialTagtrialN'trial'trialL' trialTag'trial0trial0' diversify diversify0 diversify' diversifyL diversifyN reinterpret reinterpret' reinterpretL reinterpretL' reinterpretN'whichwhichN$fATraversableWhichcm:$fATraversableWhichcm[]$fAFunctorWhichc:$fAFunctorWhichc[] $fNFDataWhich $fShowWhich $fOrdWhich $fEqWhich$fSemigroupWhich$fGenericWhich$fGenericWhich0$fGenericWhich1$fCaseCaseDiversify:$fReiterateCaseDiversifybranch'$fCaseCaseDiversifyN:"$fReiterateNCaseDiversifyNnbranch'$fCaseCaseReinterpret:$fReiterateCaseReinterprettree'$fCaseCaseReinterpret': $fReiterateCaseReinterpret'tree'$fCaseCaseReinterpretN':#$fReiterateNCaseReinterpretN'ntree'$fNFDataWhich0$fReduceWhichSwitcher$fReduceVoidSwitcher$fReduceWhichSwitcher0$fReduceWhichSwitcher1$fReduceWhichSwitcher2$fReduceWhichSwitcherN$fReduceWhichSwitcherN0$fSwitchN[]Whichcrnxs$fCaseCaseEqWhich:$fReiterateCaseEqWhich: $fEqWhich0$fCaseCaseOrdWhich:$fReiterateCaseOrdWhich: $fOrdWhich0$fCaseCaseShowWhich:$fReiterateCaseShowWhich: $fShowWhich0 $fReadWhich$fWhichReadWhich$fWhichReadWhich0baseGHC.Base Applicativeghc-prim GHC.TypesInt GHC.TypeNatsNatKnownNat ghc-bignumGHC.Num.IntegerIntegerFunctorGHC.NumNum WrappedAny CaseSelect CollectorAnyNCaseAny CollectorAnycaseAnyMany_5tagged-0.8.7-94fd9402717f1c2eea02954222b36a4c6953f8b9 Data.TaggedTaggedcontainers-0.6.5.1Data.Sequence.Internal singletonviewlviewrGHC.Listheadtail fromList' GHC.GenericsGeneric:*:C1S1 GHC.Classescompare CaseOrdWhich CaseEqWhich Data.Voidabsurd Data.EitherLeftVoidEitherRightcoerceReadWhich WhichRead readWhich:+:GHC.ReadRead