aW.3      !"#$%&'()*+,-./012portable experimental*Niklas Broberg, niklas.broberg@chalmers.se34>A simple datatype to annotate return values from sub-patterns 56789:;<=>?@A5A simple annotation datatype for statement contexts. BCDEFGHIJKLM?Transform away occurences of regular patterns from an abstract ' Haskell module, preserving semantics. N<Transform a declaration by transforming subterms that could  contain regular patterns. OPQTransform a function match" by generating pattern guards and B declarations representing regular patterns in the argument list. F Subterms, such as guards and the right-hand side, are also traversed  transformed. RATransform and update guards and right-hand side of a function or B pattern binding. The supplied list of guards is prepended to the > original guards, and subterms are traversed and transformed. SHPlace declarations of postponed regular patterns in a let-expression to G make them lazy, in order to make them behave as irrefutable patterns. T3Make pattern binds from postponed regular patterns U.Transform expressions by traversing subterms. H Of special interest are expressions that contain patterns as subterms,  i.e. let, case6 and lambda expressions, and also list comprehensions  and do;-expressions. All other expressions simply transform their  sub-expressions, if any. = Of special interest are of course also any xml expressions. VWXYZ[-Transform pattern bind declarations inside a let-expression by transforming S subterms that could appear as regular patterns, as well as transforming the bound Q pattern itself. The reason we need to do this in a special way is scoping, i.e.  in the expression let a | Just b <- match a = list in b the variable b will not  be in scope after the in9. And besides, we would be on thin ice even if it was in P scope since we are referring to the pattern being bound in the guard that will P decide if the pattern will be bound... yikes, why does Haskell allow guards on V pattern binds to refer to the patterns being bound, could that ever lead to anything  but an infinite loop?? \OTransform binding of implicit parameters by transforming the expression on the N right-hand side. The left-hand side can only be an implicit parameter, so no  regular patterns there... ]>Transform statements by traversing and transforming subterms. > Since generator statements have slightly different semantics A depending on their context, statements are annotated with their A context to ensure that the semantics of the resulting statement @ sequence is correct. The return type is a list since generated = guards will be added as statements on the same level as the  statement to be transformed. ^_Transform alternatives in a case-expression. Patterns are : transformed, while other subterms are traversed further. `abcdefghiFGenerate variables as placeholders for any regular patterns, in order K to place their evaluation elsewhere. We must likewise move the evaluation 9 of Tags because attribute lookups are force evaluation. jk!Rename declarations appearing in lets or where clauses. l)Move irrefutable regular patterns into a let-expression instead, $ to make sure that the semantics of ~ are preserved. mn8Transform several patterns in the same context, thereby 4 generating any code for matching regular patterns. opqrstuvwxyz{|}~/Transform several patterns in the same context 3Transform a pattern by traversing the syntax tree. 5 A regular pattern is translated, other patterns are  simply left as is. 2Transform away a regular pattern, generating code  to replace it. Functions and ids from the Match module, * used in the generated matching functions Some magic& gensym-like functions, and functions  with related functionality. :Create an xml tag, given its domain, name, attributes and  children. @Create an empty xml tag, given its domain, name and attributes. /Create an attribute by applying the overloaded asAttr 1Create a property from an attribute and a value. DMake xml out of some expression by applying the overloaded function  asChild. .Lookup an attribute in the set of attributes. 3Generate a pattern under the Tag data constructor. 6Generate a pattern under the PCDATA data constructor. 0requires newtype deriving and MPTCs with fundeps experimental*Niklas Broberg, niklas.broberg@chalmers.se5 HNames can be simple or qualified with a domain. We want to conveniently ? use both simple strings or pairs wherever a Name is expected. Set attributes on XML elements 8Similarly embed values as attributes of an XML element. MEmbed values as child nodes of an XML element. The parent type will be clear * from the context so it is not mentioned.  !=Type synonyms to avoid writing out the XMLnGenT all the time "0Generate XML values in some XMLGenerator monad. #$%&'()*BThe monad transformer that allows a monad to generate XML values. +, un-lift. -./012NPairs of strings can represent names, meaning a name qualified with a domain. CStrings can represent names, meaning a simple name with no domain. &Names can represent names, of course. 2  !"#$%&'()*+,-./0122*+,)"#$%&'(! -./012  2    !"#$%&'(#$%&'()*++,-./012      !"#$%&'()*+,--./0123456789:;;<=>??@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ hsx-0.6.2 HSX.TransformHSX.XMLGenerator transform TypeCastM'' typeCastM'' TypeCastM' typeCastM' TypeCastM typeCastM TypeCast'' typeCast'' TypeCast' typeCast'TypeCasttypeCastIsNametoName AppendChildappChildappAllSetAttrsetAttrsetAllAttr:= XMLGenerator EmbedAsAttrasAttr EmbedAsChildasChildGenAttributeList GenAttribute GenChildListGenChild GenXMLListGenXMLXMLGenXMLChild Attribute genElement genEElement xmlToChildNameXMLGenT unXMLGenTset<@<<@app<:<<: MFunMetaInfoMTypeMELSTrStateNameBindRNStateRNGuardStmtType ListCompStmt GuardStmtDoStmtHsxStateHsxMMkHsxM getHsxState setHsxState initHsxStatesetHarpTransformedsetXmlTransformedrunHsxM transformDecltransformInstDecltransformClassDecltransformMatchmkRhs addLetDeclsmkDecl transformExptransformFieldUpdatetransformSplice transform2exp transform3expmkAttrtransformLetDeclstransformIPBind transformStmttransformQualStmt transformAlt mkStmtGuard mkDeclGuard runRename getRNState setRNState genVarName rename1pat rename2pat renameNpat renameRPatsrenameRPrenameLetDecls renameIrrPats renameIrrPtransformPatternsliftTrrunTr runTrFromTogetStatesetState updateState pushGuardpushDecl pushAttrGuard genMatchName genPatName genAttrNamesetHarpTransformedTsetXmlTransformedTtr1pattr2pattrNpat trPatterns trPatterntrRPat runMatchFun baseMatchFun manyMatchFun gManyMatchFun runMatch_namebaseMatch_namemanyMatch_namegManyMatch_name match_modmatch_qual_mod match_qualchoiceOpappendOp foldCompFun mkMetaUnzip matchFunctionretnamevarsnamevalnamevalsname valsvarsname mkValName extendVar xNameParts metaReturn metaConstmetaMap metaUnzip metaEither metaMaybe metaConcat metaAppend metaChoice metaPConsmetaConsmetaComp metaPJust metaPNothing metaPMkMaybemetaJust metaNothing metaMkMaybeconsFunidFunconsfcompchoiceappend just_name nothing_name left_name right_namemetaGenElementmetaGenEElement metaAsAttr metaAssign metaAsChild metaExtractmetaTag metaPcdata metaMkName $fIsName(,) $fIsName[] $fIsName(,)0