úÎþôSo      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmn 5Copyright (c) , Patrick Perry <patperry@stanford.edu>BSD3%Patrick Perry <patperry@stanford.edu> experimentalNone 368;HMopqrstuvwxyz{|}~€oqtuvwxyz{|}~€opqrstuvwxyz{|}~€ 5Copyright (c) , Patrick Perry <patperry@stanford.edu>BSD3%Patrick Perry <patperry@stanford.edu> experimentalNone 368;HM5A mutable permutation that can be manipulated in the ‚ monad. The type argument s( is the state variable argument for the ‚ type.HThe immutable permutation data type. Internally, a permutation of size n is stored as an 0-based array of n ƒ=s. The permutation represents a reordering of the integers  0, ..., (n-1)-. The permutation sents the value p[i] to i.  Get the size of the permutation.'Get a list of the permutation elements.„…†‡ˆ‰Š‹ŒŽ‘’“„…†‡ˆ‰Š‹ŒŽ„…†‡ˆ‰Š‹ŒŽ‘’“ 5Copyright (c) , Patrick Perry <patperry@stanford.edu>BSD3%Patrick Perry <patperry@stanford.edu> experimentalNone 368;HM5A mutable permutation that can be manipulated in the ” monad. •–—˜™š›œžŸ  •–—˜™š›œžŸ  •–—˜™š›œžŸ 5Copyright (c) , Patrick Perry <patperry@stanford.edu>BSD3%Patrick Perry <patperry@stanford.edu> experimentalNone 368;HM fClass for representing a mutable permutation. The type is parameterized over the type of the monad, m8, in which the mutable permutation will be manipulated.Get the size of a permutation.8Create a new permutation initialized to be the identity. 4Allocate a new permutation but do not initialize it. ˆGet a lazy list of the permutation elements. The laziness makes this function slightly dangerous if you are modifying the permutation.<Set all the values of a permutation from a list of elements.4Construct a permutation from a list of elements. newListPermute n is creates a permutation of size n with the ith element equal to is !! i.. For the permutation to be valid, the list is must have length n and contain the indices 0..(n-1) exactly once each./Construct a permutation from a list of swaps. newSwapsPermute n ss creates a permutation of size n! given a sequence of swaps. If ss is  [(i0,j0), (i1,j1), ..., (ik,jk)], the sequence of swaps is  i0 <-> j0 , then  i1 <-> j1, and so on until  ik <-> jk.9Construct a permutation from a list of disjoint cycles. newCyclesPermute n cs creates a permutation of size n) which is the composition of the cycles cs./Construct a new permutation by copying another.copyPermute dst src( copies the elements of the permutation src into the permutation dst1. The two permutations must have the same size."Set a permutation to the identity. getElem p i gets the value of the ith element of the permutation p . The index i must be in the range 0..(n-1), where n! is the size of the permutation.getIndexOf p x returns i sutch that  getElem p i equals x$. This is a linear-time operation. setElem p i x sets the value of the ith element of the permutation p . The index i must be in the range 0..(n-1), where n! is the size of the permutation.swapElems p i j exchanges the ith and j!th elements of the permutation p.SReturns whether or not the permutation is valid. For it to be valid, the numbers  0,...,(n-1)4 must all appear exactly once in the stored values p[0],...,p[n-1].'Compute the inverse of a permutation. 5Set one permutation to be the inverse of another. copyInverse inv p computes the inverse of p and stores it in inv0. The two permutations must have the same size.!PAdvance a permutation to the next permutation in lexicogrphic order and return True4. If no further permutaitons are available, return Falsei and leave the permutation unmodified. Starting with the idendity permutation and repeatedly calling setNext9 will iterate through all permutations of a given size."NStep backwards to the previous permutation in lexicographic order and return True/. If there is no previous permutation, return False' and leave the permutation unmodified.#FGet a lazy list of swaps equivalent to the permutation. A result of "[ (i0,j0), (i1,j1), ..., (ik,jk) ] means swap  i0 <-> j0 , then  i1 <-> j1, and so on until  ik <-> jk]. The laziness makes this function slightly dangerous if you are modifying the permutation.$DGet a lazy list of swaps equivalent to the inverse of a permutation.%getCycleFrom p i* gets the list of elements reachable from i by repeated application of p.& getCycles p' returns the list of disjoin cycles in p.'CWhether or not the permutation is made from an even number of swaps( getPeriod p - The first power of p! that is the identity permutation)2Convert a mutable permutation to an immutable one.*2Convert an immutable permutation to a mutable one.+ getSort n xs sorts the first n elements of xs. and returns a permutation which transforms xs3 into sorted order. The results are undefined if n is greater than the length of xs. This is a special case of ,.- getOrder n xs2 returns a permutation which rearranges the first n elements of xs4 into ascending order. The results are undefined if n! is greater than the length of xs. This is a special case of ../ getRank n xsC eturns a permutation, the inverse of which rearranges the first n elements of xs3 into ascending order. The returned permutation, p, has the property that p[i] is the rank of the ith element of xs!. The results are undefined if n is greater than the length of xs. This is a special case of 0. 2 ¡¢£ !"¤#$¥%&'()*+,-./0¦§+  !"#$%&'()*+,-./0+ '( !"#$%&+,-./0)*'  ¡¢£ !"¤#$¥%&'()*+,-./0¦§5Copyright (c) , Patrick Perry <patperry@stanford.edu>BSD3%Patrick Perry <patperry@stanford.edu> experimentalNone 368;HM1ÿA safe way to create and work with a mutable permutation before returning an immutable one for later perusal. This function avoids copying the permutation before returning it - it uses unsafeFreeze internally, but this wrapper is a safe interface to that function. 1-  !"#$%&'()*+,-./01115Copyright (c) , Patrick Perry <patperry@stanford.edu>BSD3%Patrick Perry <patperry@stanford.edu> experimentalNone 368;HM,  !"#$%&'()*+,-./05Copyright (c) , Patrick Perry <patperry@stanford.edu>BSD3%Patrick Perry <patperry@stanford.edu> experimentalNone 368;HM24Construct an identity permutation of the given size.34Construct a permutation from a list of elements. listPermute n is creates a permutation of size n with the ith element equal to is !! i.. For the permutation to be valid, the list is must have length n and contain the indices 0..(n-1) exactly once each.4/Construct a permutation from a list of swaps. swapsPermute n ss creats a permutation of size n$ given by a sequence of swaps. If ss is  [(i0,j0), (i1,j1), ..., (ik,jk)], the sequence of swaps is  i0 <-> j0 , then  i1 <-> j1, and so on until  ik <-> jk.59Construct a permutation from a list of disjoint cycles. cyclesPermute n cs creates a permutation of size n) which is the composition of the cycles cs.6at p i gets the value of the ith element of the permutation p . The index i must be in the range 0..(n-1), where n! is the size of the permutation.7 indexOf p x gets an index i such that at p i equals x.8!Get the inverse of a permutation.97Return the next permutation in lexicographic order, or Nothing® if there are no further permutations. Starting with the identity permutation and repeatedly calling this function will iterate through all permutations of a given order.:;Return the previous permutation in lexicographic order, or Nothing if no such permutation exists.;AGet a list of swaps equivalent to the permutation. A result of "[ (i0,j0), (i1,j1), ..., (ik,jk) ] means swap  i0 <-> j0 , then  i1 <-> j1, and so on until  ik <-> jk.<=Get a list of swaps equivalent to the inverse of permutation.= cycleFrom p i* gets the list of elements reachable from i by repeated application of p.>cycles p' returns the list of disjoin cycles in p.?CWhether or not the permutation is made from an even number of swaps@period p - The first power of p! that is the identity permutationA sort n xs sorts the first n elements of xs. and returns a permutation which transforms xs3 into sorted order. The results are undefined if n is greater than the length of xs. This is a special case of B.C order n xs2 returns a permutation which rearranges the first n elements of xs4 into ascending order. The results are undefined if n! is greater than the length of xs. This is a special case of D.E rank n xsC eturns a permutation, the inverse of which rearranges the first n elements of xs3 into ascending order. The returned permutation, p, has the property that p[i] is the rank of the ith element of xs!. The results are undefined if n is greater than the length of xs. This is a special case of F. 23456789:¨;<=>?@ABCDEF23456789:;<=>?@ABCDEF234567?@89:;<=>ABCDEF23456789:¨;<=>?@ABCDEF 5Copyright (c) , Patrick Perry <patperry@stanford.edu>BSD3%Patrick Perry <patperry@stanford.edu> experimentalNone 368;HMG5A mutable combination that can be manipulated in the ‚ monad. The type argument s( is the state variable argument for the ‚ type.H<The immutable combination data type. A way of representing k unordered outcomes from nA possiblities. The possibilites are represented as the indices  0, ..., n-12, and the outcomes are given as a subset of size k=. The subset is stored with the indices in ascending order.JGet the number of outcomes, k.K!Get the number of possibilities, n.LGet a list of the k outcomes.G©HªIJKL«¬­®¯°±²³´µ¶·¸¹G©HªIJKL«¬­®¯°±²³´µ¶G©HªIJKL«¬­®¯°±²³´µ¶·¸¹ 5Copyright (c) , Patrick Perry <patperry@stanford.edu>BSD3%Patrick Perry <patperry@stanford.edu> experimentalNone 368;HMM5A mutable combination that can be manipulated in the ” monad.Mº»¼½¾¿ÀÁÂÃÄÅÆMº»¼½¾¿ÀÁÂÃÄÅÆ Mº»¼½¾¿ÀÁÂÃÄÅÆ5Copyright (c) , Patrick Perry <patperry@stanford.edu>BSD3%Patrick Perry <patperry@stanford.edu> experimentalNone 368;HMNfClass for representing a mutable combination. The type is parameterized over the type of the monad, m8, in which the mutable combination will be manipulated.O!Get the number of possibilities, n in the combination.PGet the number of outcomes, k in the combination.Q newChoose n k creates a new combination of k outcomes from n* possibilites initialized to the subset { 0, ..., k-1 }.R newChoose n k allocates a new combination of k outcomes from n* possibilities but does not initialize it.UˆGet a lazy list of the combination elements. The laziness makes this function slightly dangerous if you are modifying the combination.V<Set all the values of a combination from a list of elements.Y4Construct a combination from a list of elements. newListChoose n k is creates a combination of k outcomes from n( possibilities initialized to have the ith element equal to is !! i‰. For the combination to be valid, the elements must all be unique, they must be in sorted order, and they all must be in the range 0 .. n-1.[/Construct a new combination by copying another.\copyChoose dst src( copies the elements of the combination src into the combination dst1. The two combinations must have the same size.]5Set a combination to be the first subset of its size.^ getElem c i gets the value of the ith element of the combination c . The index i must be in the range 0..k-1, where n! is the size of the combination._ setElem c i x sets the value of the ith element of the combination c . The index i must be in the range 0..k-1, where k! is the size of the combination.`©Returns whether or not the combination is valid. For it to be valid, the elements must all be unique, they must be in sorted order, and they all must be in the range 0 .. n-1, where n3 is the number of possibilies in the combination.a'Compute the complement of a combinationbjReturn a lazy list of the elements in the complement of a combination. If the combination is a subset of k outcomes from nE possibilities, then the returned list will be sorted and of length n-kt. Due to the laziness, you should be careful when using this function if you are also modifying the combination.cCAdvance a combination to the next in lexicogrphic order and return True6. If no further combinations are available, return False8 and leave the combination unmodified. Starting with  [ 0 .. k-1 ] and repeatedly calling setNext* will iterate through all subsets of size k.dNStep backwards to the previous combination in lexicographic order and return True/. If there is no previous combination, return False' and leave the combination unmodified.e2Convert a mutable combination to an immutable one.f2Convert an immutable combination to a mutable one.NOPQRSTUVWXYZ[\]^_`abcdefÇÈNOPQRSTUVWXYZ[\]^_`abcdefNOPQRSTUVWXY[\]^_`abcdefZN OPQRSTUVWXYZ[\]^_`abcdefÇÈ5Copyright (c) , Patrick Perry <patperry@stanford.edu>BSD3%Patrick Perry <patperry@stanford.edu> experimentalNone 368;HMgÿA safe way to create and work with a mutable combination before returning an immutable one for later perusal. This function avoids copying the combination before returning it - it uses unsafeFreeze internally, but this wrapper is a safe interface to that function. gGNOPQRSTUVWXYZ[\]^_`abcdefgGgg5Copyright (c) , Patrick Perry <patperry@stanford.edu>BSD3%Patrick Perry <patperry@stanford.edu> experimentalNone 368;HMMNOPQRSTUVWXYZ[\]^_`abcdefM5Copyright (c) , Patrick Perry <patperry@stanford.edu>BSD3%Patrick Perry <patperry@stanford.edu> experimentalNone 368;HMh choose n k" returns the first combination of k outcomes from n" possibilites, namely the subset { 0, ..., k-1 }.i4Construct a combination from a list of elements. listChoose n k is creates a combination of k outcomes from n( possibilities initialized to have the ith element equal to is !! i‰. For the combination to be valid, the elements must all be unique, they must be in sorted order, and they all must be in the range 0 .. n-1.jat c i gets the value of the ith element of the combination c . The index i must be in the range 0..(k-1), where k! is the size of the combination.k Get the inverse of a combinationlbGet a list of the elements in the complement of a combination. If the combination is a subset of k outcomes from nE possibilities, then the returned list will be sorted and of length n-k. m7Return the next combination in lexicographic order, or Nothing« if there are no further combinations. Starting with the first combination and repeatedly calling this function will iterate through all combinations of a given order.n;Return the previous combination in lexicographic order, or Nothing if such combination exists.hijklmnÉ HIJKLhijklmn HhijIKJLklmnhijklmnÉÊ       !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRST U V   W  XYZ[\]^_`a(*,bc/078defDghGH i i j j k l   m n o p q r s t u  vwxyz{   | } ~  € ‚ ƒ „ … † ‡ ˆ ‰yzŠ  ‹ Œ Ž ‘ ’ “ ” •–—˜™š›œ U V ž Ÿ   ¡ ¢ £ ¤ ¥ ¦ § ¨ © ª « ¬ X ­ ® ¯ ° ± ² ³ ´ µ ¶ · ¸¹º»permutation-0.5.0Data.Permute.ST Data.PermuteData.Permute.IOData.Permute.MPermuteData.Choose.ST Data.ChooseData.Choose.IOData.Choose.MChoose Data.IntArrayData.Permute.BaseData.Permute.IOBaseData.Choose.BaseData.Choose.IOBase STPermutePermuteunsafeAtsizeelems IOPermuteMPermutegetSize newPermute newPermute_ unsafeGetElem unsafeSetElemunsafeSwapElemsgetElemssetElems unsafeFreeze unsafeThawnewListPermuteunsafeNewListPermutenewSwapsPermuteunsafeNewSwapsPermutenewCyclesPermuteunsafeNewCyclesPermutenewCopyPermute copyPermute setIdentitygetElem getIndexOfsetElem swapElemsisValid getInverse copyInversesetNextsetPrevgetSwaps getInvSwaps getCycleFrom getCycles getIsEven getPeriodfreezethawgetSort getSortBygetOrder getOrderBygetRank getRankBy runSTPermutepermute listPermute swapsPermute cyclesPermuteatindexOfinversenextprevswapsinvSwaps cycleFromcyclesisEvenperiodsortsortByorderorderByrankrankBySTChooseChoosepossibleIOChooseMChoose getPossible newChoose newChoose_ newListChooseunsafeNewListChoose newCopyChoose copyChoosesetFirst getComplement getComplElems runSTChoosechoose listChoose complement complElems STIntArrayIntArrayisTrue numElements newArray_sameSTIntArraynumElementsSTIntArraygetNumElements unsafeRead unsafeWrite unsafeSwap readElems writeElemsbaseGHC.STSTghc-prim GHC.TypesIntgetSizeSTPermute sizeSTPermute newSTPermute newSTPermute_unsafeGetElemSTPermuteunsafeSetElemSTPermuteunsafeSwapElemsSTPermutegetElemsSTPermutesetElemsSTPermuteunsafeFreezeSTPermuteunsafeThawSTPermute $fEqSTPermute $fEqPermute $fShowPermuteIO newIOPermute newIOPermute_getSizeIOPermute sizeIOPermuteunsafeGetElemIOPermuteunsafeSetElemIOPermuteunsafeSwapElemsIOPermutegetElemsIOPermutesetElemsIOPermuteunsafeFreezeIOPermuteunsafeThawIOPermuteunsafeInterleaveMnewSwapsPermuteHelp cycleToSwaps setNextBy getSwapsHelp$fMPermuteIOPermuteIO$fMPermuteSTPermuteST nextPrevHelpgetSizeSTChoose sizeSTChoosegetPossibleSTChoosepossibleSTChoose newSTChoose newSTChoose_unsafeGetElemSTChooseunsafeSetElemSTChoosegetElemsSTChoosesetElemsSTChooseunsafeFreezeSTChooseunsafeThawSTChoose $fEqSTChoose $fEqChoose $fShowChoose newIOChoose newIOChoose_getPossibleIOChoosepossibleIOChoosegetSizeIOChoose sizeIOChooseunsafeGetElemIOChooseunsafeSetElemIOChoosegetElemsIOChoosesetElemsIOChooseunsafeFreezeIOChooseunsafeThawIOChoose$fMChooseIOChooseIO$fMChooseSTChooseST