P<n      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~      !"#$%&'()*+,-./0123456789:;<=>?@ABC D E F G H I J K L M N O P Q R S T U V W X Y Z [ \ ] ^ _ ` a b c d e f g h i j k l m XXX  experimental +Stephanie Weirich <sweirich@cis.upenn.edu> 6A name with a hidden (existentially quantified) sort. 9s are things that get bound. This type is intentionally  abstract; to create a  you can use  or  ". The type parameter is a tag, or sort, which tells B us what sorts of things this name may stand for. The sort must  be an instance of the n type class.  Get the integer index of a . Get the string part of a . Get the integer index of an . Get the string part of an .  Create a  from an op.  Create a  from a q. Convenient synonym for .  Create a  from a String and an Integer index. Determine the sort of a . Change the sort of a name    portable experimental*Stephanie Weirich <sweirich@cis.upenn.edu>rs >Compose two permutations. The right-hand permutation will be  applied first. !'isid -- do all keys map to themselves? "@Join two permutation. Fail if the two permutations map the same " name to two different variables. #$% mkPerm l1 l2" creates a permutation that sends l1 to l2. B Fail if there is no such permutation, either because the lists B have different lengths or because they are inconsistent (which  can only happen if l1 or l2 have repeated elements). tuv  !"#$%  #!"$%  !"#$%{&'('9 supports recursive patterns --- that is, patterns where @ any variables anywhere in the pattern are bound in the pattern & itself. Useful for lectrec (and Agda's dot notation). ()>Rebinding is for telescopes --- i.e. to support patterns that ' also bind variables that appear later *+8Shift the scope of an embedded term one level outwards. ,-An annotation is a hole in a pattern where variables > can be used, but not bound. For example patterns may include A type annotations, and those annotations can reference variables  without binding them. D Annotations do nothing special when they appear elsewhere in terms ./9Type of a binding. Morally, the type a should be in the  class Pattern' and the type b should be in the class Q. 7 The Pattern class contains the constructor and a safe  destructor for these types.  We can Bind an a object in a b object if we  can create fresh a objects, and Names can be  swapped in b objects. Often a is Name  but that need not be the case. 0123456789:;<=>?Locally fresh monad  This is the class of D monads that support freshness in an (implicit) local scope. Names D drawn are fresh for this particular scope, but not globally fresh. < This class has a basic instance based on the reader monad. @@pick a new name that is fresh for the current (implicit) scope. A9avoid these names when freshening in the subcomputation. BA monad m supports the fresh operation if it " can generate a new unique names. CDA monad m* supports the nextInteger operation if it ! can generate new fresh integers EFGHIJKLMNOPQ:The Alpha class is for all terms that may contain binders  The w) class constraint means that we can only 2 make instances of this class for types that have 5 generic representations. (Derive these using TH and  RepLib.) RS5swap everything, including bound and free variables,  parts in annots, etc. T The method swaps' applys a compound permutation U+calculate the free variables (aka support) V2list the binding variables in a pattern, in order WMatch'- compares two data structures and produces a 9 permutation of their free variables that will make them  alpha-equivalent to eachother. XAn object of type a can be freshened if a new  copy of a% can be produced where all old Names  in a, are replaced with new fresh Names, and the 9 permutation reports which names were swapped by others. YSee v ZMany of the operations in the Q class take an Z: D stored information about the iteration as it progresses. This type I is abstract, as classes that override these operations should just pass  the context on. [\]^_`abcdefghiSmart constructor for binders j7A destructor for binders that does not guarantee fresh  names for the binders. k$Constructor for binding in patterns l4destructor for binding patterns, the external names  should have already  been freshen'4ed. We swap the internal names so that they use the  external names mnop)calculate the free variables of the term q(List the binding variables in a pattern r@Set of variables that occur freely in annotations (not binding) s The method swaps, applys a permutation to all free variables  in the term. t;Apply a permutation to the binding variables in a pattern. 5 Embedded terms are left alone by the permutation. u=Apply a permutation to the annotations in a pattern. Binding * names are left alone by the permutation. vLocally freshen an object wA pattern of type b can be freshened if a new  copy of b/ can be produced where all old *binding* Names  in b, are replaced with new fresh Names, and the 9 permutation reports which Names were swapped by others. x>Match compares two data structures and produces a permutation 8 of their Names that will make them alpha-equivalent to C eachother. (Names that appear in annotations must match exactly.) > Also note that two terms are alpha-equivalent when the empty  permutation is returned. yACompare two patterns, ignoring the names of binders, and produce B a permutation of their annotations to make them alpha-equivalent  to eachother. Return x" if no such renaming is possible. z?Compare two patterns for equality and produce a permutation of  their binding Names- to make them alpha-equivalent to each other  (9s that appear in annotations must match exactly). Return  x" if no such renaming is possible. {|}~7Unbind is the destructor of a binding. It ensures that ' the names in the binding b are fresh. >Destruct two bindings simultanously, if they match, using the  same list of fresh names (Destruct a binding in the LFresh monad. @Capture-avoiding substitution, in a monad so that we can rename 2 variables at binding locations and avoid capture y1Reader monad instance for local freshness class. &'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~z{|}~z&21/0-.+,)*'(hgfedcba`_^]ijklmnopqrstuvwxyzZ\[{|}~QRSTUVWXYGHIJKLMNOPDEFBC?@A;<=>789:3654z&'(()**+,,-../00123654456789:89:;<=><=>?@A@ABCCDEFEFG HIJKLMNOPHIJKLMNOPQRSTUVWXYRSTUVWXYZ\[[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ non-portable (-XKitchenSink)  experimental +Stephanie Weirich <sweirich@cis.upenn.edu> J ')+-./;<=>?@ABCDEFQRSTUVWXYZ]_acegijklmnopqrsvwxJ/-.)'+ QRSTUVWXYsxqrpoijBCwDEF?@Avklmn;<=>Zegac_]&A simple representation of multisets. >Collections are foldable types that support empty, singleton, = union, and map operations. The result of a free variable B calculation may be any collection. Instances are provided for  lists and sets. 'Combine a list of containers into one. -Create a collection from a list of elements.  Remove the Nothings from a collection. ASets are containers under union, which preserve only occurrence, ! not multiplicity or ordering. =Multisets are containers which preserve multiplicity but not  ordering. :Lists are containers under concatenation. Lists preserve * ordering and multiplicity of elements. XXX  experimental +Stephanie Weirich <sweirich@cis.upenn.edu> #9s are things that get bound. This type is intentionally  abstract; to create a  you can use  or  ". The type parameter is a tag, or sort, which tells B us what sorts of things this name may stand for. The sort must  be an instance of the n type class. 6A name with a hidden (existentially quantified) sort. Get the integer index of a . Get the string part of a . Get the integer index of an . Get the string part of an .  Create a  from an op.  Create a  from a q. Convenient synonym for .  Create a  from a String and an Integer index. Determine the sort of a . Change the sort of a name ###unportable (GHC 7 only)  experimental %Brent Yorgey <byorgey@cis.upenn.edu> +A convenient monad which is an instance of  . It keeps D track of a set of names to avoid, and when asked for a fresh one 0 will choose the first unused numerical name. @The LFresh monad transformer. Keeps track of a set of names to D avoid, and when asked for a fresh one will choose the first unused  numerical name. 9This is the class of monads that support freshness in an F (implicit) local scope. Generated names are fresh for the current ( local scope, but not globally fresh. @Pick a new name that is fresh for the current (implicit) scope. =Avoid the given names when freshening in the subcomputation. +A convenient monad which is an instance of  . It keeps E track of a global index used for generating fresh names, which is  incremented every time  is called. The FreshM5 monad transformer. Keeps track of the lowest index D still globally unused, and increments the index every time it is  asked for a fresh name. =Type class for monads which can generate new globally unique  s based on a given . Run a + computation starting in an empty context. Run a 3 computation given a starting index for fresh name  generation. .Run a FreshM computation in an empty context. 1Run a FreshM computation given a starting index. Run an " computation in an empty context. Run an , computation given a set of names to avoid. .Get the set of names currently being avoided. /Run a LFreshM computation in an empty context. 9Run a LFreshM computation given a set of names to avoid. #A simple reader monad instance for . 8Shift the scope of an embedded term one level outwards. An annotation is a "hole"% in a pattern where variables can be ? used, but not bound. For example, patterns may include type > annotations, and those annotations can reference variables C without binding them. Annotations do nothing special when they  appear elsewhere in terms.  is a standalone variant of  -- that is, if p is a  pattern type then TRec p& is a term type. It is isomorphic to  Bind (Rec p) (). 9 supports recursive patterns --- that is, patterns where @ any variables anywhere in the pattern are bound in the pattern & itself. Useful for lectrec (and Agda's dot notation).  supports " telescopes" --- that is, patterns where 0 bound variables appear in multiple subterms. The type of a binding. We can  an a object in a b  object if we can create "fresh" a objects, and a objects  can occur unbound in b objects. Often a is  but that  need not be the case. Like , + is also abstract. You can create bindings  using bind and take them apart with unbind and friends. 4P=Class constraint hackery to allow us to override the default % definitions for certain classes.  is essentially a  reified dictionary for the  class. >A mode is basically a flag that tells us whether we should be C looking at the names in the term, or if we are in a pattern and  should only1 be looking at the names in the annotations. The  standard mode is to use %; many functions do this by default. Many of the operations in the  class take an : D stored information about the iteration as it progresses. This type I is abstract, as classes that override these operations should just pass  the context on.    @A continuation which takes the remaining index and searches for D that location in a pattern, yielding a name or a remaining index 3 if the end of the pattern was reached too soon.   The result of an   operation. We haven't yet reached the  required index; this is the # index into the remainder of the " pattern (which decreases as we  traverse the pattern). The name found at the given  index. The result of a ! operation. We haven't found the name " (yet), but have seen this many  others while looking for it !The (first) index of the name we  sought The 7 type class is for types which may contain names. The  w: constraint means that we can only make instances of this C class for types that have generic representations (which can be % automatically derived by RepLib.) Note that the methods of " should never be called directly! @ Instead, use other methods provided by this module which are  defined in terms of $ methods. (The only reason they are A exported is to make them available to automatically-generated  code.) @Most of the time, the default definitions of these methods will E suffice, so you can make an instance for your data type by simply  declaring  instance Alpha MyType See swaps. See fv. See lfreshen. See freshen. See aeq. #Replace free names by bound names. #Replace bound names by free names. See acompare. isPat x dynamically checks whether x can be used as a valid * pattern. The default instance returns True if at all  possible. isTerm x dynamically checks whether x can be used as a , valid term. The default instance returns True if at all  possible. isEmbed0 is needed internally for the implementation of  isPat. isEmbed is true for terms wrapped in Embed and zero  or more occurrences of Shift. The default implementation  simply returns False.    p n looks up the nth name in the pattern p B (zero-indexed), returning the number of names encountered if not  found. !9Find the (first) index of the name in the pattern if one = exists; otherwise, return the number of names encountered  instead. "AFind the (first) index of the name in the pattern, if it exists. #<If we see a name, check whether the index is 0: if it is, we've  found the name we'*re looking for, otherwise continue with a  decremented index. $$ b n looks up up the nth name in the pattern b C (zero-indexed). PRECONDITION: the number of names in the pattern  must be at least n. %&'()*%Open a term using the given pattern. + openP p1 p2 opens the pattern p2 using the pattern p1. ,&Close a term using the given pattern. - closeP p1 p2 closes the pattern p2 using the pattern p1. ./0123456789:;<=>?@ABNthCont, forms a monoid: function composition which * short-circuits once a result is found.  FindResult0 forms a monoid which combines information from  several ! operations. mappend takes the leftmost  :, and combines the number of names seen to the left of it 1 so we can correctly compute its global index. N      !"#$%&'()*+,-./0123456789:;<=>?@ABN !"   #$  %&'()*+,-./0123456789:;<=>?@ABN           ! !"#$%&'()*+,-./0123456789:;<=>?@AB CReified class dictionary for H. DEFGHThe H2 class governs capture-avoiding substitution. To D derive this class, you only need to indicate where the variables 2 are in the data type, by overriding the method I. I>If the argument is a variable, return its name wrapped in the  ML constructor. Return x for non-variable 9 arguments. The default implementation always returns  x. JJ nm sub tm substitutes sub for nm in tm. K,Perform several simultaneous substitutions. LSee I. MNOPCDEFGHIJKLMNOPLMHIJKCDEFGNOPCDEFGDEFGHIJKIJKLMMNOP Q9A smart constructor for binders, also sometimes known as  "close". R#A destructor for binders that does not guarantee fresh  names for the binders. S%Constructor for binding in patterns. TDestructor for *. It does not need a monadic context for ! generating fresh names, since  can only occur in the  pattern of a ; hence a previous call to  must have . already freshened the names at this point. UVWXYZ&Determine alpha-equivalence of terms. [BDetermine (alpha-)equivalence of patterns. Do they bind the same / variables and have alpha-equal annotations? \<An alpha-respecting total order on terms involving binders. ]@Calculate the free variables (of any sort) contained in a term. ^ACalculate the free variables of a particular sort contained in a  term. _?Calculate the variables (of any sort) that occur freely within ; pattern annotations (but are not bound by the pattern). `BCalculate the variables of a particular sort that occur freely in ; pattern annotations (but are not bound by the pattern). a<Calculate the binding variables (of any sort) in a pattern. b<Calculate the binding variables (of a particular sort) in a  pattern. cApply a permutation to a term. d;Apply a permutation to the binding variables in a pattern. 3 Embedded terms are left alone by the permutation. e=Apply a permutation to the annotations in a pattern. Binding * names are left alone by the permutation. f"Locally"4 freshen a pattern replacing all binding names with D new names that have not already been used. The second argument is E a continuation, which takes the renamed term and a permutation that - specifies how the pattern has been renamed. g'Freshen a pattern by replacing all old binding  s with new  fresh !s, returning a new pattern and a    specifying how s were replaced. hUnbind (also known as "open") is the destructor for ? bindings. It ensures that the names in the binding are fresh. i9Unbind two terms with the same fresh names, provided the 6 binders have the same number of binding variables. j;Unbind three terms with the same fresh names, provided the 6 binders have the same number of binding variables. kDestruct a binding in an  monad. l9Unbind two terms with the same fresh names, provided the 6 binders have the same number of binding variables. m;Unbind three terms with the same fresh names, provided the 6 binders have the same number of binding variables. Compare for alpha-equality. QRSTUVWXYZ[\]^_`abcdefghijklmQRSTUVWXYZ[\]^_`abcdefghijklmQRSTUVWXYZ[\]^_`abcdefghijklm non-portable (-XKitchenSink)  experimental +Stephanie Weirich <sweirich@cis.upenn.edu> j !HIJKLMQRSTUVWXYZ[\]^_`abcdefghijklmj !cedZ[\^]`_baQRghijfklmSTUVWXYHIJKLM   !"#$%&'()*+,-./0123345667789:;<=>?@@ABCDEFGHIJKLMNOOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~2:;  lm !"#$%&'GHIJK6677334589dfhjnOORSVWPbcaX[\`_Y @ @ A B C D   p q r t u v w y x z { | } ~ (2     egiko  ! unbound-0.2Unbound.Nominal.Name Unbound.PermMUnbound.Nominal.Internal Unbound.UtilUnbound.LocallyNameless.NameUnbound.LocallyNameless.FreshUnbound.LocallyNameless.TypesUnbound.LocallyNameless.AlphaUnbound.LocallyNameless.SubstUnbound.LocallyNameless.OpsUnbound.NominalUnbound.LocallyNamelessAnyNameNameNmrAnyName rAnyName1name1name2name3name4name5name6name7name8name9name10name11 name2Integer name2StringanyName2IntegeranyName2String toSortedName integer2Name string2Names2nmakeNamegetR translatePermapplysingleemptycomposeisidjoinsupportrestrictmkPerm<>RecRebindRShiftEmbedBindBrRrR1ExpLAVSubstDsubstDsubstsDSubstisvarlsubstlsubstsLFreshlfreshavoidFreshfreshHasNext nextInteger resetNextAlphaDaeqDswapallDswapsDfvDbindersDmatchDfreshenD lfreshenDAlphaaeq'swapall'swaps'fv'binders'match'freshen' lfreshen'AlphaCtxPatTermrShiftrShift1rRecrRec1rRebindrRebind1rEmbedrEmbed1rNamerName1rBindrBind1bind unsafeUnbindrebindreopenrecunrecaeqfvbinderspatfvswaps swapsBinders swapsEmbedslfreshenfreshenmatch matchEmbeds matchBindersinitialpattermmodeaeqR1aeq1swapsR1 swapallR1fvR1fv1 bindersR1binders1matchR1match1 freshenR1freshenL lfreshenR1 lfreshenLunbindunbind2unbind3lunbindlunbind2lunbind3substsubstssubstR1substsR1rExprExp1nameAnameBnameCassertdo_testsemptyNEmkbigMultiset CollectionemptyC singletonunioncmapunionsfromListfilterCBnisBoundisFreeLFreshMLFreshMT unLFreshMTFreshMFreshMT unFreshMT runFreshMT contFreshMT runFreshM contFreshM runLFreshMT contLFreshMT getAvoids runLFreshM contLFreshMTRecisPatDisTermDisEmbedDcloseDopenDfindpatDnthpatD acompareDModeAClevelNthCont runNthCont NthResultCurIndexFound FindResult NamesSeenIndexcloseopen acompare'isPatisTermisEmbed nthpatrec findpatrecfindpatnthNamenthpatincrdecropenTopenPcloseTclosePcloseR1openR1 findpatR1findpatLnthpatR1nthpatLcombineisPatR1isTermR1 acompareR1lexord compareTupMisvarD SubstName substDefaultunrebindtrecuntrecluntrec aeqBindersacomparefvAnypatfvAny bindersAny RepLib-0.4.0Generics.RepLib.RRepInteger integer-gmpGHC.Integer.TypebaseGHC.BaseStringseteqGenerics.RepLib.R1Rep1 Data.MaybeNothing$fLFreshReaderTpermnaeqa10aa10ba10ca10d tests_aeqtests_fv tests_substbig1big2 tests_big$fCollectionSet$fCollectionMultiset$fCollection[]$fLFreshReaderT0$fMonoidNthCont$fMonoidFindResult $fEqRebind