и      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ (c) Artem ChirkinBSD3chirkin@arch.ethz.chNone%&*,9;ABDEOQRTf QBring an instance of certain class or constaint satisfaction evidence into scope.@A constraint family that makes sure all subdimensions are known.jThis class gives the int associated with a type-level natural. Valid known dim must be not less than 0. &Get value of type-level dim at runtime TSame as SomeNat, but for Dimensions: Hide all information about Dimensions inside Known natural number BUnknown natural number, known to be not smaller than the given Nat6Either known or unknown at compile-time natural number A variant of   that gets  as an argument. Similar to  from   , but returns . Similar to , but for a single dimension8This function does GHC's magic to convert user-supplied   function to create an instance of KnownDim typeclass at runtime. The trick is taken from Edward Kmett's reflection library explained in Chttps://www.schoolofhaskell.com/user/thoughtpolice/using-reflection4  !"#$%&'()*+,-./0123459   .   !"#$%&'()*+,-./0123454(c) Artem ChirkinBSD3chirkin@arch.ethz.chNone%&*+,9:;<=?ABDEOQRTf,Another data type to make Reverse injective.A special data type that can have either a single element, or more than two. This feature is not enforced in the type system - this is just a way to make injective Snoc.6sPattern-matching on the constructor of this type brings an evidence that the type-level parameter list is finite7]Pattern-matching on the constructor of this type brings an evidence that `as ++ bs ~ asbs`8|Type-level list that is known to be finite. Basically, provides means to get its length and term-level rep (via TypeList)9)Length of a type-level list at type level:)Length of a type-level list at term level;Get type-level constructed list<8Type level list, used together with FiniteList typeclass?@Represent a triple of lists forming a relation `as ++ bs ~ asbs`M$Synonym for an empty type-level listN&Reverse a type-level list (injective!)O&Prefix-style synonym for concatenationPList concatenationQPrefix-style synonym for snocR*Synonym for a type-level snoc (injective!)SPrefix-style synonym for consTeSynonym for a type-level cons (injective, since this is just a synonym for the list constructor)U.Length of a finite list is known and equal to : of the listV#Tail of the list is also known listW'Infer that concatenation is also finiteX Infer that prefix is also finiteY Infer that suffix is also finiteZ Make snoc almost as good as cons[#Init of the list is also known list\,Take KnownDim of the list is also known list],Drop KnownDim of the list is also known list^&Reverse of the list is also known list_uAny two type-level lists can be concatenated, so we just fool the compiler by unsafeCoercing proxy-like data type.`as being prefix of asbsx is enough to infer some concatenation relations so we just fool the compiler by unsafeCoercing proxy-like data type.abs being suffix of asbsx is enough to infer some concatenation relations so we just fool the compiler by unsafeCoercing proxy-like data type.;6789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcde,6789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`a,PTRMSQFEDCONLKJIHG?@AB89:;<=>_`a76UVWXYZ[\]^/6789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdeP5R5T5(c) Artem ChirkinBSD3chirkin@arch.ethz.chNone%&*+,9:;<=ABDEOQRTf.f(Various evidence for the Snoc operation.g(Various evidence for the Snoc operation.hSynonym for (+:) that treats Nat values 0 and 1 in a special way: it preserves the property that all dimensions are greater than 1.iSynonym for (:+) that treats Nat values 0 and 1 in a special way: it preserves the property that all dimensions are greater than 1.j(WrapNat tries not to inspect content of xn# and construct it based only on nE when it is possible. This means it does not check if `XN m <= n`.k*FixedXDim tries not to inspect content of xns# and construct it based only on nsE when it is possible. This means it does not check if `XN m <= n`.l)FixedDim tries not to inspect content of ns# and construct it based only on xnsE when it is possible. This means it does not check if `XN m <= n`.mgConstraint on kinds; makes sure that the second argument kind is Nat if the first is a list of Nats.nyUnify usage of XNat and Nat. This is useful in function and type definitions. Mainly used in the definition of Dim.o%Treat Dims or XDims uniformly as Dimsp&Treat Dims or XDims uniformly as XDimsqMap XDims onto Dims (injective)rMap Dims onto XDims (injective)tDimensionality of our spaceuTSame as SomeNat, but for Dimensions: Hide all information about Dimensions insidewRSame as SomeNat, but for Dimension: Hide all information about Dimension insideyType-level dimensionalityz!Zero-rank dimensionality - scalar{]List-like concatenation of dimensionality. NatKind constraint is needed here to infer that|Proxy-like constructor}8Nat known at runtime packed into existential constructor~IGet runtime-known dim and make sure it is not smaller than the given Nat.ZGet value of type-level dim at runtime. Gives a product of all dimensions if is a list.Product of all dimension sizes. Similar to , but for a single dimension>Convert a list of ints into unknown type-level Dimensions listdWe either get evidence that this function was instantiated with the same type-level Dimensions, or .Compare dimensions by their size in lexicorgaphic order from the last dimension to the first dimension (the last dimension is the most significant one). Similar to  or  asProxyTypeOf.; to be used on such implicit functions as t, dimMax, etc. Similar to  asProxyTypeOfH, Give a hint to type checker to fix the type of a function argument.Infer s, given that the list is KnownDims and finites implies s implies 8'Infer that tail list is also Dimensions+Infer that concatenation is also Dimensions$Infer that prefix is also Dimensions$Infer that suffix is also Dimensions Make snoc almost as good as consUInit of the dimension list is also Dimensions, and the last dimension is KnownDim.UTail of the dimension list is also Dimensions, and the head dimension is KnownDim.#Init of the list is also Dimensions,Take KnownDim of the list is also Dimensions,Drop KnownDim of the list is also Dimensions&Reverse of the list is also DimensionsLUse the given `Dim ds` to create an instance of `Dimensions ds` dynamically.8This function does GHC's magic to convert user-supplied   function to create an instance of KnownDim typeclass at runtime. The trick is taken from Edward Kmett's reflection library explained in Chttps://www.schoolofhaskell.com/user/thoughtpolice/using-reflection@fghijklmnopqrstuvwxyz{|}~7 fghijklmnopqrstuvwxyz{|}~7 yz{|}~uvwxst rqponmlkjihgf8fghijklmnopqrstuvwxyz{|}~h6i6{5(c) Artem ChirkinBSD3chirkin@arch.ethz.chNone%&*+,9:;<=ABDOQRTf @Type-level dimensional indexing with arbitrary Int values inside!Zero-rank dimensionality - scalar"List-like concatenation of indices3Convert zero-based offset into Idx in a given space&Get zero-based offset of current index9Offset difference of two indices (first idx - second idx) )Step dimension index by an Integer offsetAppend index dimension6Split index into prefix and suffix dimensioned indicesrWith this instance we can slightly reduce indexing expressions e.g. x ! (1 :! 2 :! 4) == x ! (1 :! 2 :! 4 :! Z)          5(c) Artem ChirkinBSD3chirkin@arch.ethz.chNone %&,BDTfgh >Traverse over all dimensions keeping track of index and offset:Fold over all dimensions keeping track of index and offsetKFold over all dimensions in reverse order keeping track of index and offset*Same as overDim#, but with no return value5Traverse over all dimensions keeping track of indices,Fold all dimensions keeping track of indices=Fold all dimensions in reverse order keeping track of indicesKTraverse over all dimensions keeping track of indices, with no return value:Traverse over all dimensions keeping track of total offset6Fold over all dimensions keeping track of total offsetQTraverse over all dimensions keeping track of total offset, with not return valueTraverse from the first index to the second index in each dimension. Indices must be within Dim range, which is not checked. You can combine positive and negative traversal directions along different dimensions.#function to map over each dimensionInitial offset offset step#function to map over each dimensionInitial offset offset step#function to map over each dimensionInitial offset-offset step (substracted from initial offset)#function to map over each dimensionInitial offset offset step#function to map over each dimensionInitial offset offset step#function to map over each dimensionInitial offset offset step#function to map over each dimensionInitial offset offset step#function to map over each dimensionInitial offset offset step#function to map over each dimensionInitial offset#function to map over each dimensionInitial offset#function to map over each dimensionInitial offset#function to map over each dimensionInitial offset#function to map over each dimensionInitial offset (c) Artem ChirkinBSD3chirkin@arch.ethz.chNone,BDT>Traverse over all dimensions keeping track of index and offset5Traverse over all dimensions keeping track of indices:Traverse over all dimensions keeping track of total offset*Same as overDim#, but with no return valueKTraverse over all dimensions keeping track of indices, with no return valueQTraverse over all dimensions keeping track of total offset, with not return valueTraverse from the first index to the second index in each dimension. Indices must be within Dim range, which is not checked. You can combine positive and negative traversal directions along different dimensions. #function to map over each dimensionInitial offset offset step#function to map over each dimensionInitial offset offset step#function to map over each dimensionInitial offset offset step#function to map over each dimensionInitial offset offset step#function to map over each dimensionInitial offset offset step (c) Artem ChirkinBSD3chirkin@arch.ethz.chNone,BDT>Traverse over all dimensions keeping track of index and offset5Traverse over all dimensions keeping track of indices:Traverse over all dimensions keeping track of total offset*Same as overDim#, but with no return valueKTraverse over all dimensions keeping track of indices, with no return valueQTraverse over all dimensions keeping track of total offset, with not return valueTraverse from the first index to the second index in each dimension. Indices must be within Dim range, which is not checked. You can combine positive and negative traversal directions along different dimensions. #function to map over each dimensionInitial offset offset step#function to map over each dimensionInitial offset offset step#function to map over each dimensionInitial offset offset step#function to map over each dimensionInitial offset offset step#function to map over each dimensionInitial offset offset step (c) Artem ChirkinBSD3chirkin@arch.ethz.chNone%&*+,9:;<=ABDEOQRTfSimilar to SomeNat, hide some dimensions under an existential constructor. In contrast to SomeDim, it preserves the order of dimensions, and it can keep some of the dimensions in the list static while making other dimensions known only at runtime.5Loose compile-time information about dimensionalities#Construct dimensionality at runtime   (c) Artem ChirkinBSD3chirkin@arch.ethz.chNonem 6789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`afghijklmnopqrstuvwxyz{|}~    !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~       )dimensions-0.3.2.0-4kEGTueUWNbCc5yzdbtOW4Numeric.TypeLitsNumeric.Dimensions.DimNumeric.Dimensions.ListNumeric.Dimensions.IdxNumeric.Dimensions.TraverseNumeric.Dimensions.Traverse.IONumeric.Dimensions.Traverse.STNumeric.Dimensions.XDimGHCTypeLitsNumeric.Dimensionsghc-primGHC.Primproxy# GHC.TypesNatProxy#base Data.ProxyProxyEvidence KnownDimsKnownDimdimVal' SomeIntNatNXNXNatdimVal# intNatVal someIntNatValreifyDimsumEvs+!+ withEvidenceinferPlusKnownDiminferMinusKnownDiminferMinusKnownDimMinferTimesKnownDim$fReadSomeIntNat$fShowSomeIntNat$fOrdSomeIntNat$fEqSomeIntNat $fKnownDim20 $fKnownDim19 $fKnownDim18 $fKnownDim17 $fKnownDim16 $fKnownDim15 $fKnownDim14 $fKnownDim13 $fKnownDim12 $fKnownDim11 $fKnownDim10 $fKnownDim9 $fKnownDim8 $fKnownDim7 $fKnownDim6 $fKnownDim5 $fKnownDim4 $fKnownDim3 $fKnownDim2 $fKnownDim1 $fKnownDim0 $fKnownDimnFiniteListEvidenceConcatEvidence FiniteListLengthordertListTypeListTLEmptyTLCons ConcatListtlPrefixtlSuffixtlConcatLastInitTailHeadIsSuffixIsPrefixPrefixSuffixDropTakeEmptyReverseConcat++Snoc+:Cons:+inferKnownLengthinferTailFiniteListinferConcatFiniteListinferPrefixFiniteListinferSuffixFiniteListinferSnocFiniteListinferInitFiniteListinferTakeNFiniteListinferDropNFiniteListinferReverseFiniteList inferConcat inferSuffix inferPrefix$fFiniteListk:$fFiniteListk[]$fShowTypeList$fConcatListkasbsasbsConsDimensionsSnocDimensions>::<WrapNat FixedXDimFixedDimNatKindConsDim UnwrapDimsWrapDimsAsDimsAsXDims DimensionsdimSomeDimsSomeDimDimD:*DnDxfromIntdimValtotalDim someDimVal someDimsValsameDim compareDim inSpaceOf asSpaceOfinferDimensionsinferDimKnownDimsinferDimFiniteListinferTailDimensionsinferConcatDimensionsinferPrefixDimensionsinferSuffixDimensionsinferSnocDimensionsinferUnSnocDimensionsinferUnConsDimensionsinferInitDimensionsinferTakeNDimensionsinferDropNDimensionsinferReverseDimensionsreifyDimensions $fBoundedDim $fDimensions:$fDimensions[] $fOrdSomeDims$fOrdDim $fEqSomeDims$fEqDim$fShowSomeDims $fShowDimIdxZ:! appendIdxsplitIdx $fEnumIdx $fIsListIdx $fBoundedIdx$fOrdIdx$fNumIdx$fEqIdx $fShowIdxoverDim#foldDimfoldDimReverse overDim_# overDimIdx# foldDimIdxfoldDimReverseIdx overDimIdx_# overDimOff# foldDimOff overDimOff_# overDimPart#overDim overDimIdx overDimOffoverDim_ overDimIdx_ overDimOff_ overDimPart XDimensionswrapDimXDimxdimxDimVal $fOrdXDim$fEqXDim $fShowXDim$fXDimensions:$fXDimensions:0$fXDimensions[] GHC.TypeLitsnatValInt someNatValMagicDimmkKDEvKnownNat KnownSymbolSymbol+*^<=?- CmpSymbolCmpNat TypeError sameSymbolsameNat someSymbolVal symbolVal'natVal' symbolValSomeNat SomeSymbol<= ErrorMessageText:<>::$$:ShowType ReversingSnocing DoReverseReversedREmptyGetSnocDoSnocSSingleunsafeEqEvidenceGHC.BaseNothingconst reifyDims MagicDimsdimListunsafeSnocDims'unsafeConsDims'toIdxfromIdxdiffIdxstepIdx idxToList idxFromListsuccIdxpredIdx overDim'#foldDim'foldDimReverse' overDim_'# overDimPart'#fst#fst'#