p      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdef g h i j k l m n o :(c) 2011 Edwin Westbrook, Nicolas Frisby, and Paul BraunerBSD3 emw4@rice.edu experimentalGHCNonepp NoneINqqq :(c) 2014 Edwin Westbrook, Nicolas Frisby, and Paul BraunerBSD3 emw4@rice.edu experimentalGHCNone  The type Cl a" represents a closed term of type a , i.e., an expression of type am with no free (Haskell) variables. Since this cannot be checked directly in the Haskell type system, the Clf data type is hidden, and the user can only create closed terms using Template Haskell, through the cl operator.rrr(c) 2016 Edwin WestbrookBSD3westbrook@galois.com experimentalGHCNone !"(=>IKLNA type-class which ensures that ctx is a valid context, i.e., has | the form (RNil :> t1 :> ... :> tn) for some types t1 through tnA  MapRList f r. is a vector with exactly one element of type f a for each type a in the type  r.An Append ctx1 ctx2 ctx is a "proof" that  ctx = ctx1  ctx2. A  Member ctx a is a "proof" that the type a is in the type list ctx, meaning that ctx equals # t0 ':>' a ':>' t1 ':>' ... ':>' tnfor some types  t0,t1,...,tn.Create an empty  vector.Create a singleton  vector.Look up an element of a  vector using a   proof.$Map a function on all elements of a  vector.6Map a binary function on all pairs of elements of two  vectors. Append two  vectors.Make an  proof from any / vector for the second argument of the append. A version of  that takes in a s argument.The inverse of , that builds an  from an  Split an o vector into two pieces. The first argument is a phantom argument that gives the form of the first list piece. ,Create a vector of proofs that each type in c is a   of c.!Convert an MapRList to a list$  !"#$tu  !" $  !#"   !"#$tu :(c) 2014 Edwin Westbrook, Nicolas Frisby, and Paul BraunerBSD3westbrook@kestrel.edu experimentalGHCNone !"+35KL%A Name a. is a bound name that is associated with type a.& cmpName n m compares names n and m of types Name a and Name b', respectively. When they are equal, Some e is returned for e a proof of type a :~: b( that their types are equal. Otherwise, None is returned. For example: nu $ \n -> nu $ \m -> cmpName n n == nu $ \n -> nu $ \m -> Some Refl nu $ \n -> nu $ \m -> cmpName n m == nu $ \n -> nu $ \m -> Nonevwxy%z&{|}~ vwxy%z&{|}~ vwxy%z&{|}~:(c) 2014 Edwin Westbrook, Nicolas Frisby, and Paul BraunerBSD3westbrook@kestrel.edu experimentalGHCNone !"+IN'dThis type states that it is possible to replace free names with fresh names in an object of type a.. This type essentially just captures a representation of the type a as either a Name type, a multi-binding, a function type, or a (G)ADT. In order to be sure that only the "right" proofs are used for (G)ADTs, however, this type is hidden from the user, and can only be constructed with  mkNuMatching.(An Mb ctx b; is a multi-binding that binds one name for each type in ctx, where ctx has the form   t1  ...  tnh. Internally, multi-bindings are represented either as "fresh functions", which are functions that quantify over all fresh names that have not been used before and map them to the body of the binding, or as "fresh pairs", which are pairs of a list of names that are guaranteed to be fresh along with a body. Note that fresh pairs must come with an 'a for the body type, to ensure that the names given in the pair can be relaced by fresher names. The call mapNamesPf data ns ns' a. replaces each occurrence of a free name in a which is listed in ns' by the corresponding name listed in ns'j. This is similar to the name-swapping of Nominal Logic, except that the swapping does not go both ways.3Ensures a multi-binding is in "fresh function" form/Ensures a multi-binding is in "fresh pair" form '( '('(:(c) 2011 Edwin Westbrook, Nicolas Frisby, and Paul BraunerBSD3 emw4@rice.edu experimentalGHCNone  !"(35KL)A Binding. is simply a multi-binding that binds one name*nu f, creates a binding which binds a fresh name n# and whose body is the result of f n.+The expression  nuMulti p fU creates a multi-binding of zero or more names, one for each element of the vector p,. The bound names are passed the names to f?, which returns the body of the multi-binding. The argument p , of type  f ctxB, acts as a "phantom" argument, used to reify the list of types ctxD at the term level; thus it is unimportant what the type function f is.,  nus = nuMulti-8Checks if a name is bound in a multi-binding, returning Left mem! when the name is bound, where memc is a proof that the type of the name is in the type list for the multi-binding, and returning Right n# when the name is not bound, where n is the name. For example: nu $ \n -> mbNameBoundP (nu $ \m -> m) == nu $ \n -> Left Member_Base nu $ \n -> mbNameBoundP (nu $ \m -> n) == nu $ \n -> Right n.cCompares two names inside bindings, taking alpha-equivalence into account; i.e., if both are the ith name, or both are the same name not bound in their respective multi-bindings, then they compare as equal. The return values are the same as for & , so that  Some Refl* is returned when the names are equal and Nothing! is returned when they are not./,Creates an empty binding that binds 0 names.0=Eliminates an empty binding, returning its body. Note that  elimEmptyMb is the inverse of emptyMb.1@Combines a binding inside another binding into a single binding.2LSeparates a binding into two nested bindings. The first argument, of type  any c28, is a "phantom" argument to indicate how the context c should be split.3<Returns a proxy object that enumerates all the types in ctx.4dTake a multi-binding inside another multi-binding and move the outer binding inside the ineer one.5xApplies a function in a multi-binding to an argument in a multi-binding that binds the same number and types of names.6The expression nuWithElimMulti args f takes a sequence args0 of zero or more multi-bindings, each of type  Mb ctx ai for the same type context ctx of bound names, and a function f and does the following:)Creates a multi-binding that binds names  n1,...,nn , one name for each type in ctx;Substitutes the names  n1,...,nn1 for the names bound by each argument in the args& sequence, yielding the bodies of the args (using the new name n ); and thenPasses the sequence  n1,...,nn0 along with the result of substituting into args to the function fA, which then returns the value for the newly created binding.Note that the types in args must each have a  NuMatching* instance; this is represented with the NuMatchingList type class.Here are some examples: (<*>) :: Mb ctx (a -> b) -> Mb ctx a -> Mb ctx b (<*>) f a = nuWithElimMulti ('MNil' :>: f :>: a) (\_ ('MNil' :>: 'Identity' f' :>: 'Identity' a') -> f' a')7 Similar to 6 but binds only one name.8 Similar to 6 but takes only one argument9 Similar to 68 but takes only one argument that binds a single name.)*+,-./0123456789%&()*+,-./0123456789%)(*+,/&-.0123456789)*+,-./0123456789:(c) 2014 Edwin Westbrook, Nicolas Frisby, and Paul BraunerBSD3 emw4@rice.edu experimentalGHCNone :  Closed = Cl;clJ is used with Template Haskell quotations to create closed terms of type G. A quoted expression is closed if all of the names occuring in it areL1) bound globally or 2) bound within the quotation or 3) also of type .<2Closed terms are closed (sorry) under application.8Closed multi-bindings are also closed under application.= noClosedNamesJ encodes the hobbits guarantee that no name can escape its multi-binding.>  mkClosed = cl? unClosed = unCl:;<=>?:;<=>? ;<=>:?:;<=>?:(c) 2014 Edwin Westbrook, Nicolas Frisby, and Paul BraunerBSD3westbrook@kestrel.edu experimentalGHCNone !"(345>IKLNDInstances of the D aI class allow pattern-matching on multi-bindings whose bodies have type a$, i.e., on multi-bindings of type ( ctx aD. The structure of this class is mostly hidden from the user; see F) to see how to create instances of the  NuMatching class. Just like $, except uses the NuMatching class. FTemplate Haskell function for creating NuMatching instances for (G)ADTs. Typical usage is to include the following line in the source file for (G)ADT T+ (here assumed to have two type arguments): )$(mkNuMatching [t| forall a b . T a b |])The F5 call here will create an instance declaration for D (T a b)_. It is also possible to include a context in the forall type; for example, if we define the ID data type as follows: data ID a = ID athen we can create a D instance for it like this: ,$( mkNuMatching [t| NuMatching a => ID a |])INote that, when a context is included, the Haskell parser will add the forall a for you.#@ABCDEF'@ABCDEFDEFBC@A'@ABCDEF:(c) 2011 Edwin Westbrook, Nicolas Frisby, and Paul BraunerBSD3 emw4@rice.edu experimentalGHCNone4 A WrapKite specifies a transformation to be applied to variables | in a Template Haskell patterns, as follows:_varView gives an expression for a function to be applied, as a view pattern, to variables before matching them, including to variables bound by @ patterns;_asXform^ gives a function to transform the bodies of @ patterns, i.e., this function is applied to p in pattern x@p; _topXform; gives a function to transform the whole pattern after _varView and/or _asXform? have been applied to sub-patterns; as the first argument,  _topXform` also takes a flag indicating whether any transformations have been applied to sub-patterns.<Helper function to apply an expression to multiple arguments8Helper function to apply the (.) operator on expressions patQQ str pat builds a quasi-quoter named str that parses | patterns with pat9Combine two WrapKits, composing the individual componentsApply a  to a pattern%Parse a pattern from a string, using JA helper function used to ensure two multi-bindings have the same contexts Builds a & for parsing patterns that match over ((. | Takes two fresh names as arguments.G*Quasi-quoter for patterns that match over ( Builds a & for parsing patterns that match over H*Quasi-quoter for patterns that match over , built using I*Quasi-quoter for patterhs that match over  (( ctx a)GHIGHIGHI GHI(c) 2014 Edwin WestbrookBSD3 emw4@rice.edu experimentalGHCNone  !"(35KLJ The class  Liftable aE gives a "lifting function" for a, which can take any data of type a out of a multi-binding of type ( ctx a.L9Lift a list (but not its elements) out of a multi-binding JKLMNOPQRSTJKL JKTSRQPLONM JKLMNOPQRST:(c) 2011 Edwin Westbrook, Nicolas Frisby, and Paul BraunerBSD3 emw4@rice.edu experimentalGHCNoneKLZs  !%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKL:(c) 2011 Edwin Westbrook, Nicolas Frisby, and Paul BraunerBSD3 emw4@rice.edu experimentalGHCNone  !"(=>IN"UVWXYZ[\]^_`abcdeUVWXYZ[\]^_`abcdeZYUVWXeabcd^_`[\]UVWXYZ[\]^_`abcde :(c) 2011 Edwin Westbrook, Nicolas Frisby, and Paul BraunerBSD3 emw4@rice.edu experimentalGHCNonefghijklmfghijklmfghijklmfghijklm :(c) 2011 Edwin Westbrook, Nicolas Frisby, and Paul BraunerBSD3 emw4@rice.edu experimentalGHCNone  !"(>KL Create a s object for the type list of a  vector.'noUVWXYZ[\]^_`abcdenonono   !"#$%&'()*+,-./01234 5 6789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstu v w x y z { | } ~                                    hobbi_6SZBWcEdIMEKdLfd9AScUk"Data.Binding.Hobbits.PatternParserData.Binding.Hobbits.ClosedData.Type.RListData.Binding.Hobbits.MbData.Binding.Hobbits.NuMatchingData.Binding.Hobbits.QQData.Binding.Hobbits.Liftable1Data.Binding.Hobbits.Examples.LambdaLifting.Terms4Data.Binding.Hobbits.Examples.LambdaLifting.Examples+Data.Binding.Hobbits.Examples.LambdaLifting'Data.Binding.Hobbits.Internal.Utilities$Data.Binding.Hobbits.Internal.Closed"Data.Binding.Hobbits.Internal.Name Data.Binding.Hobbits.Internal.MbData.Binding.Hobbits parsePatternClunClTypeCtxtypeCtxProxiesMapRListMNil:>:Append Append_Base Append_StepMember Member_Base Member_Step:++:RListRNil:> proxyConsshowsPrecMember weakenMemberL membersEqempty singletonmapRListLookup mapMapRList mapMapRList2appendMapRListmkAppend mkMonoAppendproxiesFromAppend splitMapRListmembersmapRListToList $fTypeCtx:> $fTypeCtxRNil $fShowMemberNamecmpName MbTypeReprMbBindingnunuMultinus mbNameBoundP mbCmpNameemptyMb elimEmptyMb mbCombine mbSeparate mbToProxymbSwapmbApplynuMultiWithElim nuWithElimnuMultiWithElim1 nuWithElim1ClosedclclApply noClosedNamesmkClosedunClosed NuMatching1nuMatchingProof1NuMatchingListnuMatchingListProof NuMatchingnuMatchingProof mkNuMatchingnuPclPclNuPLiftablembLiftmbList $fLiftable(,) $fLiftable() $fLiftable[]$fLiftableMember $fLiftableCl$fLiftableInteger $fLiftableInt$fLiftableCharTermVarLamAppDLDecls Decls_Base Decls_ConsDeclDecl_One Decl_ConsDTermTVarTDVarTApplamex1ex2ex3ex4ex5ex6ex7exP lambdaLift mbLambdaLiftparsePatternExtensionseverywhereButMbase Data.ProxyProxyTFCo:R::++:r1:>TFCo:R::++:rRNilExProxyExMemberMkName memberFromLen unsafeLookupC proxyFromLencounter fresh_name$fShowMapRList $fShowName mapNamesPfensureFreshFunensureFreshPairMbTypeReprDataMkMbTypeReprDataMbTypeReprName MbTypeReprMb MbTypeReprFunMkMbFunMkMbPairfreshFunctionProxies$fApplicativeMb $fFunctorMb$fShowMb clMbApplymapNames CxtStateQNames NuMatchingObjnatsFromfst3snd3thd3 mapNamesTypemkMkMbTypeReprDataOld$fNuMatchingMapRList$fNuMatchingList:>$fNuMatchingListRNil$fNuMatchingMember$fNuMatching[]$fNuMatchingEither$fNuMatching(,,,)$fNuMatching(,,)$fNuMatching(,)$fNuMatching()$fNuMatchingChar$fNuMatchingInteger$fNuMatchingInt$fNuMatchingMb$fNuMatching(->)$fNuMatchingCl$fNuMatchingNameWrapKit appEMulticomposepatQQcombineWrapKitswrapVars parseHeresame_ctxnuKitclKit_varView_asXform _topXform asProxyTypeOfKProxyData.Type.Equalityouterinnerapply gcastWithcastWithtranssymRefl:~: testEquality TestEquality==StringF unStringFtpretty $fShowTerm$fNuMatchingTerm$fNuMatchingDTerm$fNuMatchingDeclprettympretty mprettyName decls_pretty mdecls_pretty mdecl_pretty $fShowDecls $fShowDTerm$fNuMatchingDeclsproxyOfMapRList LLBodyRetSepRetFVSTermSTermSWeakenSVarSDVarSApp FVUnionRetFVListMbLNameSubCPeelRet AddArrowsLCLType peelLambdas peelLambdasH boundParams freeParamsfvUnionelemMC skelSubstskelAppMultiNames fvSSepLTVars fvSSepLTVarsH raiseAppNamellBodyTFCo:R:AddArrows:>bTFCo:R:AddArrowsRNilb