)-       !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~       !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqr s t u v!w!x!y!z!{!|"}#~########$$$%&&&&&&&&&&&&&&&&&&''''''(((((((((((((((((((((((((((((((((((((((((((((((((((())))))))))))))))))))))***********************8None!"(*12346=HJKM The last Name< of a rule is the name of the syntactic type of the result.None!"(*12346=HJKMThe result type name A single-dim () caseCWe have a multi-tape grammar, but the stack contains a mixture of ArgTys. We have a multi-tape grammar with a stack of just terminals. We normally can ignore the contents in the functions above, but keep them anyway. pWe have just a single-tape grammar and as such just a single-dimensional terminal. We call this term, because  StackedTerms will be rewritten to just Term! This SynVarI spans the full column of tapes; i.e. it is a normal syntactic variable. Type for backtracking functions.-Not too interesting, mostly to keep track of choice.eThe ADP-established product operation. Returns a vector of results, along the lines of what the ADP f *** b provides. Backtracking products of f and b . Choice in fD needs to be reduced to a scalar value. It is then compared to the fst values in b. From those, choice b selects.?Creates instances for all products given a signature data type. Returns the  of the monad variable. Returns the ]s of the objective function variables, as well as the name of the objective function itself.'The left algebra type. Assumes that in choice :: Stream m x -> m r we have that x ~ r.2Here, we do not set any restrictions on the types m and r._Build up the type for backtracking. We want laziness in the right return type. Hence, we have AppT ListT (VarT xR)- ; i.e. we want to return results in a list._Build up the type for backtracking. We want laziness in the right return type. Hence, we have AppT ListT (VarT xR).^Build up attribute and choice function. Here, we actually bind the left and right algebra to l and r.6Simple wrapper for creating the choice fun expression.We take the left and right function name for one attribute and build up the combined attribute function. Mostly a wrapper around recBuildLampat which does the main work.TODO need fun names from l and r -Now things become trickly. We are given all non-terminal names (to differentiate between a terminal (stack) and a syntactic variable; the left and right function; and the arguments to this attribute function (except the result parameter). We are given the latter as a result to an earlier call to ).~We now look at each argument and determine wether it is a syntactic variable. If so, then we actually have a tuple arguments (x,ys) where x has to optimized value and ys9 the backtracking list. The left function receives just xi in this case. For the right function, things are more complicated, since we have to flatten lists. See $.}Terminals are always given "as is" since we do not have a need for tupled-up information as we have for syntactic variables."uLook at the argument type and build the capturing variables. In particular captures synvar arguments with a 2-tuple (x,ys).$NOTE U[ f x | x <- xs ] CompE [BindS (VarP x) (VarE xs), NoBindS (AppE (VarE f) (VarE x))] %Build up the backtracking choice function. This choice function will backtrack based on the first result, then return only the second.^TODO it should be (only?) this function we will need to modify to build all algebra products.ysM can't be unboxed, as snd: of each element is a list, lazily consumed. We build up ysM as this makes fusion happen. Of course, this is a boxed vector and not as efficient, but we gain the ability to have lazily created backtracking from this!4This means strict optimization AND lazy backtracking'5Transform a monadic stream monadically into a vector.TODO Improve code!()Transform a vector into a monadic stream.TODO improve code!)BGets the names used in the evaluation function. This returns one  for each variable. In case of TupleT 0 the type is ()0 and there isn't a name to go with it. We just  mkName "()"Q a name, but this might be slightly dangerous? (Not really sure if it indeed is)With AppT _ _T we have a multidim terminal and produce another hackish name to be consumed above. AppT (AppT ArrowT (AppT (AppT (ConT Data.Array.Repa.Index.:.) (AppT (AppT (ConT Data.Array.Repa.Index.:.) (ConT Data.Array.Repa.Index.Z)) (VarT c_1627675270))) (VarT c_1627675270))) (VarT x_1627675265) +(Get all synvars, even if deep in a stack)  all non-terminal namesleft attribute functionright attribute function'all arguments to the attribute function!"#$%&'()*+)  !"#$%&'()*+) !"#$%&'()  *+   !"#$%&'()*++None!"(*12346=HJKMNone!"(*12346=HJKM,The Axiom type class-+The corresponding stream being returned by ..Given a table, run the axiom,-.,-.,-.,-.None!"(*12346=HJKM////None!"(*12346=HJKM4>Constrains the behaviour of the memoizing tables. They may be 7 if i==j: is allowed (empty subwords or similar); or they may need 6" indices, or finally they can be 5 (only i==j7 allowed) which is useful in multi-dimensional casese.; Similar to #, but terminates an argument stack.=_Finally, we need to be able to correctly build together symbols on the right-hand side of the (<<<) operator.[The default makes sure that the last (or only) argument left over is correctly assigned a Z to terminate the symbol stack.@mkStream( creates the actual stream of elements (Elm4) that will be fed to functions on the left of the (<<<)_ operator. Streams work over all monads and are specialized for each combination of arguments x and indices i.BDuring construction of the stream, we need to extract individual elements from symbols in production rules. An element in a stream is fixed by both, the type xt of the actual argument we want to grab (say individual characters we parse from an input) and the type of indices i we use.ElmV data constructors are all eradicated during fusion and should never show up in CORE.XX acts as a static filter. If b+ is true, we keep all stream elements. If b* is false, we discard all stream elements.40123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXY   Z[\*0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXY-RVUTSOQPMNJKLBCDEFGHI@A=>?\;<[ZWX8:94765Y1230012347658:9;<=>?@ABCDEFGHIJKLMNOQPRVUTSXY   [ZW\None!"(*12346=HJKMfFor multi-dimensional terminals we need to be able to calculate how the static/variable signal changes and if the index for the inner part needs to be modified.iDHandles each individual argument within a stack of terminal symbols.k;Extracts the type of a multi-dimensional terminal argument.l+Terminal symbols are stacked together with a tails and b head.n5Terminates a multi-dimensional terminal symbol stack.-]^_`abcdefghijklmnopqrstuvwxyz{|}~ ]^_`abcdefghijklmnopqrst,nolmkpijqrfgh~}debc`ast|{zy]^_xwvu!]^_`abcdefghijklmnoqrstuvwxyz{|}~p mNone!"(*12346=HJKM None!"(*12346=HJKMWe sometimes need &An undefined bitset with 2 interfaces.   None!"(*12346=HJKM None!"(*12346=HJKM,None!"(*12346=HJKMH0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXY]^_`abcdefghijklmnopqrst None!"(*12346=HJKMTODO this should go into ADP.Fusion.Table.Backtrack?, more than just tabulated syntactic vars are going to use it.#NOTE You probably need to give the monad morphism between mF and mBH so as to be able to extract forward results in the backtracking phase. None!"(*12346=HJKMTODO I think we need to check cs:.c hereTODO yes, handle Empty / NonEmpty !!!None!"(*12346=HJKMImmutable table. None!"(*12346=HJKMNone!"(*12346=HJKMNone!"(*12346;=HJKM;Get the previous index; this should really be made generic!.TODO This is probably a REALLY STUPID IDEA ;-)None!"(*12346=HJKMTODO need to deal with minSize-None!"(*12346=HJKMNone!"(*12346=HJKM0Mutate a cell in a stack of syntactic variables.&TODO generalize to monad morphism via mmorph, package. This will allow more interesting mrphs functions that can, for example, track some state in the forward phase. (Note that this can be dangerous, we do nots want to have this state influence forward results, unless that can be made deterministic, or we'll break Bellman)1This grammar is a multi-cfg in a monotone settingA vanilla context-free grammar(Expose the actual mutable table with an MTbl. (Should be temporary until MTbl1s get a more thorough treatment for auto-filling.Run and freeze MTblis. Since actually running the table-filling part is usually the last thing to do, we can freeze as well.?Default table filling, assuming that the forward monad is just IO.TODO generalize to MonadIO or  MonadPrim.RMutate tables, but observe certain hints. We use this for monotone mcfgs for now.None!"(*12346=HJKM                     .None!"(*12346=HJKM/None!"(*12346=HJKM      None!"(*12346=HJKMIActually collect split indices based on if we managed to find the right Split$ synvar (based on the right symbol).x ++ y but for inductive tuples.TODO move to PrimitiveArray Type-level (||) MClosed type family that gives us a (type) function for type symbol equality.!gWraps a normal non-terminal and attaches a type-level unique identier and z-ordering (with the unused Z at 0).DTODO attach empty/non-empty stuff (or get from non-splitted synvar?)<TODO re-introduce z-ordering later (once we have a sort fun)$Should never fail?%The  Arg synVarJ means that we probably need to rewrite the internal type resolution now!,,G gobbles up indices that are tagged with the same symbolic identifier.  !"#$%&'()*+,-./012345678 !"#$%&'()*+,"&('%$!"#+876*54), 3210/.- !"#$%&('+,-./012354)76*8None!"(*12346=HJKM9:;<<;:99:;<0None!"(*12346=HJKM !"#$%&'()*+,1None!"(*12346=HJKMF,-.      !"#$%&'()*+,None!"(*12346=HJKM=dA generic Character parser that reads a single character but allows passing additional information.= expects a function to retrieve rF at index position, followed by the actual generic vector with data.@1smart constructor for regular 1-character parsersA=Smart constructor for Maybe Peeking, followed by a character. =>?@ABCD=>?@A=>@ADCB?=>@ACB?DNone!"(*12346=HJKMEFGHIJJIHGFEEFGHIJNone!"(*12346=HJKMKLMNNMLKKLMN2None!"(*12346=HJKM=>?@ANone!"(*12346=HJKMOPQRSTOPQOPTSRQOPSRQTNone!"(*12346=HJKMUVWXYZZYXWVUUVWXYZNone!"(*12346=HJKM[\\[[\3None!"(*12346=HJKMOPQNone!"(*12346=HJKM]^_`ab]^_]^ba`_]^a`_bNone!"(*12346=HJKMcdeedccde4None!"(*12346=HJKM]^_None!"(*12346=HJKMfghijkfghfgkjihfgjihkNone!"(*12346=HJKMlmnopqqponmllmnopq None!"(*12346=HJKMrstuutsrrstu5None!"(*12346=HJKMfgh!None!"(*12346=HJKMvwxyz{vwxvw{zyxvwzyx{"None!"(*12346=HJKM|||6None!"(*12346=HJKMvwx#None!"(*12346=HJKM}}- terminals return "strings", i.e. vectors of Chr#s. They allow the user to specify [ 0 .. ][ atoms to be parsed at once. It is possible to both, limit the minimal and maximal number.-NOTE gadt comments are not parsed by haddock? }~}~ }~}~$None!"(*12346=HJKM%None!"(*12346=HJKM:TODO If we use (IVariable mx) we might be able to request exactly the range we need!7None!"(*12346=HJKM}~8None!"(*12346=HJKM=>?@AOPQ]^_fghvwx}~&None!"(*12346=HJKM'None!"(*12346=HJKM_Apply a function to symbols on the RHS of a production rule. Builds the stack of symbols from xs using ?, then hands this stack to A together with the initial iniT telling AL that we are in the "outer" position. Once the stream has been created, we  F5 to get just the arguments in the stack, and finally  the function f.1Combine two RHSs to give a choice between parses.Applies the objective function h to a stream sn. The objective function reduces the stream to a single optimal value (or some vector of co-optimal things).Separator between RHS symbols.LThis separator looks much paper "on paper" and is not widely used otherwise.,-.0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXY]^_`abcdefghijklmnopqrst      !"#$%&'()*+,=>?@AOPQ]^_fghvwx}~  (None!"(*12346=HJKMA single character terminalTwo single-character terminals Just a tableTable, then single terminalA^*_j -> A^*_{j+1} c_{j+1) !.synvar followed by a 2-tape character terminal4142)None!"(*12346=HJKM5Edges should never work as a single terminal element.$Edges extend only in cases where in i -> j, i* actually happens to be a true interface.*None!"(*12346=HJKM9:;9:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuuvwxyz{|}~               !"#$%&'()**+,-./0123456789:;<=>>?=@ABCDEFGHIJKLMNO  PPQRSTUVWXYYZ[U\]^__`abbcdUef g  !h!h!i!!!j"#k#k#l#m#n#o###p$$q$%&r&s&t&u&v&w&x&y&z&{&|&}&~&&&&&''''''(((((((((((((((((((((((((((((((((((((((((((((((((((())))))))))))))))))))))***********************  !#ADPfusion-0.4.1.0ADP.Fusion.SynVar.Split.TypeADP.Fusion.TH.CommonADP.Fusion.TH.BacktrackADP.Fusion.SynVar.AxiomADP.Fusion.QuickCheck.CommonADP.Fusion.Base.ClassesADP.Fusion.Base.MultiADP.Fusion.Base.PointADP.Fusion.Base.SetADP.Fusion.Base.Subword ADP.Fusion.THADP.Fusion.SynVar.BacktrackADP.Fusion.SynVar.IndicesADP.Fusion.SynVar.Array.TypeADP.Fusion.SynVar.Array.PointADP.Fusion.SynVar.Array.SetADP.Fusion.SynVar.Array.Subword"ADP.Fusion.SynVar.Array.TermSymbolADP.Fusion.SynVar.Fill ADP.Fusion.SynVar.Recursive.TypeADP.Fusion.SynVar.Split.SubwordADP.Fusion.Term.Chr.TypeADP.Fusion.Term.Chr.PointADP.Fusion.Term.Chr.SubwordADP.Fusion.Term.Deletion.TypeADP.Fusion.Term.Deletion.Point ADP.Fusion.Term.Deletion.SubwordADP.Fusion.Term.Edge.TypeADP.Fusion.Term.Edge.SetADP.Fusion.Term.Epsilon.TypeADP.Fusion.Term.Epsilon.PointADP.Fusion.Term.Epsilon.SubwordADP.Fusion.Term.PeekIndex.Type!ADP.Fusion.Term.PeekIndex.SubwordADP.Fusion.Term.Strng.TypeADP.Fusion.Term.Strng.PointADP.Fusion.Term.Strng.SubwordADP.Fusion.Apply ADP.FusionADP.Fusion.QuickCheck.PointADP.Fusion.QuickCheck.SetADP.Fusion.QuickCheck.Subword!ADP.Fusion.SynVar.Recursive.PointADP.Fusion.BaseADP.Fusion.SynVar.Array#ADP.Fusion.SynVar.Recursive.SubwordADP.Fusion.SynVar.RecursiveADP.Fusion.SynVar.SplitADP.Fusion.SynVarADP.Fusion.Term.ChrADP.Fusion.Term.DeletionADP.Fusion.Term.EdgeADP.Fusion.Term.EpsilonADP.Fusion.Term.PeekIndexADP.Fusion.Term.StrngADP.Fusion.Termbase Data.ProxyProxygetRuleResultTypeArgTyResultresultNilVar StackedVars stackedVars StackedTerms stackedTermsTermtermNameSynVar synVarNameChoiceProductCombining SigCombining***ProductBacktrackingSigBacktracking<||makeProductInstances getMonadNamegetObjectiveNames buildLeftTypebuildRightTypebuildSigBacktrackingTypebuildSigCombiningTypegenAlgProdFunctionsgenChoiceFunctiongenAttributeFunctionrecBuildLamPat buildLamPat argTyArgsbuildLnsbuildRnsbuildBacktrackingChoicebuildCombiningChoicestreamToVectorvectorToStreamgetRuleSynVarNames unpackArgTyflattenSynVarsAxiom AxiomStreamaxiomtr TblConstraintModifyConstraint toNonEmptytoEmptyTableConstraintOnlyZeroNonEmptyEmptyOk StaticCheck CheckRight CheckLeftSBuildStackbuildMkStreammkStreamElementElmRecElmArggetArggetIdxgetOmxgetElm RuleContextContextinitialContextComplementContext Complemented InsideContext IVariableIStaticOutsideContextOLeftOf OFirstLeftORightOfOStaticElmS staticCheckminSize TFCo:R:ElmSi $fElementSi $fBuildPairTableStaticVartableStaticVartableStreamIndexS6S5S4 TermStaticVar termStaticVartermStreamIndexTerminalStreamterminalStreamTermArg TermSymbol:|MElmTSiPackTerminalStreamoPackTerminalStreamfromTerminalStreamtoTerminalStream$fTableStaticVarOutside$fTableStaticVar:.$fTableStaticVarOutside0$fTableStaticVarZ$fRuleContextOutside$fRuleContext:.$fRuleContextOutside0$fRuleContextZ $fTermStaticVarTermSymbolOutside$fTermStaticVarTermSymbol:.$fTermStaticVarMOutside$fTermStaticVarMZ$fMkStreammSOutside $fMkStreammSZ$fTerminalStreammMOutside$fTerminalStreammMZ$fMkStreammPairiTFCo:R:ElmPairi$fElementPairi$fBuildTermSymbol$fTableStaticVarPointL$fMkStreammS:.$fMkStreammSOutside0$fMkStreammSPointL$fRuleContextComplement$fRuleContextPointLThisThatNaughtNaughtThatThis undefbs2iundefi$fMkStreammSComplement$fMkStreammS:>$fMkStreammSBitSet$fRuleContext:>$fRuleContextComplement0$fRuleContextBitSet$fTableStaticVarSubword$fMkStreammSSubword$fRuleContextSubwordmakeAlgebraProductGenBacktrackTable BacktrackBacktrackIndex toBacktrack$fBuildBacktrack TableIndices tableIndices$fTableIndicesOutside$fTableIndices:.$fTableIndices:.0$fTableIndicesOutside0$fTableIndicesZITbl iTblBigOrderiTblLittleOrderiTblConstraint iTblArrayiTblFun ElmBtITblElmITblBtITbl$fMkStreammBPairOutside$fMkStreammPairOutside$fMkStreammBPair:.$fMkStreammPair:. $fShowElmTFCo:R:ElmPairi0$fElementPairi0$fAxiomBacktrack $fAxiomITblTFCo:R:BacktrackITblmFmBr$fGenBacktrackTableITblmFmBr $fBuildITbl$fMkStreammBPairPointL$fMkStreammPairPointL$fMkStreammPair:>$fMkStreammPairBitSetFirstSecondIdxgreenIdx FirstSecond greenLight$fFirstSecondIdxPairarrSubword$fFirstSecondIdxPairarrSubword0$fFirstSecondIdxSki$fFirstSecondPairarr$fFirstSecondPairarr0$fFirstSecondSk$fMkStreammBPairSubword$fMkStreammPairSubword$fModifyConstraintBacktrack$fModifyConstraintITbl$fMkStreammPairComplement$fMkStreammPairComplement0$fMkStreammPairOutside0$fMkStreammBPairSubword0$fMkStreammPairSubword0$fTermStaticVarBacktrackSubword$fTermStaticVarITblSubword$fTerminalStreammBTermSymbol:.$fTerminalStreammTermSymbol:.ZS2 TableOrdertableLittleOrder tableBigOrder MutateTables mutateTables MutateCell mutateCell MonotoneMCFGCFG ExposeTablesTableFun OnlyTablesexpose onlyTablesrunFreezeMTblsmutateTablesDefaultmutateTablesWithHints$fMutateCellpZimomi$fMutateTablesh:.imom$fMutateCellh:.imom:. $fMutateCellMonotoneMCFG:.imom:.$fMutateCellCFG:.imomi$fTableOrder:. $fTableOrderZ$fExposeTablesZIReciRecConstraintiRecFromiRecToiRecFun ElmBtIRecElmIRecBtIRec $fAxiomIRecTFCo:R:BacktrackIRecmFmBr$fGenBacktrackTableIRecmFmBr $fBuildIRec SplitIxCol SplitIxTy splitIxColZconcatZppzconcatORSameSidSplitgetSplit CalcSplitType SplitTypeFinalFragmentElmSplitBtITbl ElmSplitITblsplit collectIx$fSplitIxColuIdTrueElm$fSplitIxColuIdTrueElm0$fSplitIxColuIdTrueElm1$fSplitIxColuIdFalseElm$fSplitIxColuIdbElm $fZconcatx:. $fZconcatxZ $fBuildSplitChrElmChrchrchrLeft $fBuildChr"$fTerminalStreammTermSymbolOutside$fTermStaticVarChrOutside$fTermStaticVarChrPointL$fTermStaticVarChrSubwordDeletion ElmDeletion$fBuildDeletion$fTermStaticVarDeletionOutside$fTermStaticVarDeletionPointL$fTermStaticVarDeletionSubwordEdgeElmEdge $fBuildEdgeEpsilon ElmEpsilon$fBuildEpsilon$fTermStaticVarEpsilonOutside$fTermStaticVarEpsilonPointL$fTermStaticVarEpsilonSubword PeekIndex ElmPeekIndex$fBuildPeekIndexStrngElmStrngmanySsomeSstrng $fBuildStrng$fTermStaticVarStrngPointLApplyFunapply $fApply(->) $fApply(->)0 $fApply(->)1 $fApply(->)2 $fApply(->)3 $fApply(->)4 $fApply(->)5 $fApply(->)6 $fApply(->)7 $fApply(->)8 $fApply(->)9 $fApply(->)10 $fApply(->)11 $fApply(->)12 $fApply(->)13<<<<<#|||...~~%GetIxsRgetIxs prop_Epsilonprop_O_Epsilon prop_ZEpsilonprop_O_ZEpsilonprop_O_ZEpsilonEpsilon prop_O_ItNC prop_O_ZItNCprop_O_2dimIt_NC_CNprop_2dimIt_NC_CNprop_Ttprop_CCprop_It prop_O_Itprop_ZIt prop_O_ZItprop_ItC prop_O_ItC prop_O_ItCC prop_O_ZItCC prop_2dimItCCprop_O_2dimItCCxprop_O_ixZItCC prop_ManyS prop_SomeSprop_2dim_ManyS_ManySprop_2dim_SomeS_SomeSprop_Itbl_ManySprop_Itbl_SomeSprop_1dim_Itbl_ManySprop_1dim_Itbl_SomeSprop_2dim_Itbl_ManyS_ManySprop_2dim_Itbl_SomeS_SomeS>>>xsPxsZPxsPoxsZPoxsPPxsPPomxsPPmaxImaxPLxsoptions customCheck $fGetIxsPairi$fGetIxsPairi0 $fGetIxsSiallProps prop_b_ii prop_b_ii_nn prop_b_iiiprop_b_iii_nnn prop_bii_i prop_bii_i_n prop_bii_e prop_bii_ie prop_bii_ie_n prop_bii_iee prop_bii_ieeeprop_bii_iee_nprop_bii_ieee_nhighBithighestB highestBIIxsBxoBxsBII prop_sv_OI prop_sv_IO prop_sv_OII prop_sv_IOI prop_sv_IIOprop_cOc prop_ccOcc prop_cOccc prop_cOcIc prop_cIcOc prop_2dimIt prop_2dimcIt prop_2dimItc prop_2dimcItchighestcsSxsSxoSxsSStemplate-haskellLanguage.Haskell.TH.SyntaxNamePrimitiveArray-0.6.1.0Data.PrimitiveArray.Index.ClassZTFCo:R:TblConstraintSubwordTFCo:R:TblConstraintPointRTFCo:R:TblConstraintPointLTFCo:R:TblConstraintComplementTFCo:R:TblConstraintOutsideTFCo:R:TblConstraintZTFCo:R:TblConstraint:.TFCo:R:TermArgMTFCo:R:TblConstraint:>TFCo:R:TblConstraintBitSetTFCo:R:TermArgTermSymbolTFCo:R:TermArgTermSymbol0vector-0.10.12.3!Data.Vector.Fusion.Stream.Monadicmap