modulePuppet.DSL.Printer(showAST,showVarMap)whereimportText.PrettyPrintimportPuppet.DSL.TypesimportqualifiedData.MapasMapimportText.Parsec.Pos-- | This shows the parsed AST a bit like the original syntax.showAST::[Statement]->StringshowASTx=render(vcat(mapshowStatementx))showStatement::Statement->DocshowStatement(Nodenamex_)=text"node"<+>textname<+>lbrace$$nest4(vcat(mapshowStatementx))$$rbraceshowStatement(VariableAssignmentnamex_)=text"$"<>textname<+>text"="<+>showExpressionxshowStatement(Includeinc_)=text("include "++inc)showStatement(Requirereq_)=text("require "++req)showStatement(ResourcertypernameparamsNormal_)=text(rtype)<+>lbrace<+>showExpressionrname<>text":"$$nest4(showAssignmentsparams)<>text";"$$rbraceshowStatement(ResourcertypernameparamsVirtualp)=text"@"<>showStatement(ResourcertypernameparamsNormalp)showStatement(ResourcertypernameparamsExportedp)=text"@@"<>showStatement(ResourcertypernameparamsNormalp)showStatement(ResourceDefaultrtypeparams_)=text(rtype)<+>braces(showAssignmentsparams)showStatement(ClassDeclarationcnameNothingparamsstatements_)=text"class"<+>textcname<+>parens(hcat(punctuate(text",")(mapshowOptionalParameterparams)))<+>lbrace$$nest4(vcat(mapshowStatementstatements))$$rbraceshowStatement(ClassDeclarationcname(Justparent)paramsstatements_)=text"class"<+>textcname<>parens(hcat(punctuate(text",")(mapshowOptionalParameterparams)))<+>text"inherits"<+>textparent<+>lbrace$$nest4(vcat(mapshowStatementstatements))$$rbraceshowStatement(DefineDeclarationcnameparamsstatements_)=text"define"<+>textcname<+>parens(hcat(punctuate(text",")(mapshowOptionalParameterparams)))<+>lbrace$$nest4(vcat(mapshowStatementstatements))$$rbraceshowStatement(ConditionalStatementx_)=text"CONDITION LIST"$$nest4(vcat(mapshowConditionx))showStatementx=text(showx)showCondition::(Expression,[Statement])->DocshowCondition(BTrue,[])=emptyshowCondition(e,stmts)=showExpressione<+>text"{"$$nest4(vcat(mapshowStatementstmts))$$text"}"showOptionalParameter::(String,MaybeExpression)->DocshowOptionalParameter(param,Nothing)=text"$"<>textparamshowOptionalParameter(param,(Juste))=text"$"<>textparam<+>text"="<+>showExpressioneshowExpressionBuilder::String->Expression->Expression->DocshowExpressionBuildersymbab=char'('<>showExpressiona<+>textsymb<+>showExpressionb<>char')'showExpression::Expression->DocshowExpression(Valuex)=showValuexshowExpression(ConditionalValuevarconds)=showExpressionvar<+>text"=>"<+>showExpressioncondsshowExpression(PlusOperationab)=showExpressionBuilder"+"abshowExpression(MinusOperationab)=showExpressionBuilder"-"abshowExpression(DivOperationab)=showExpressionBuilder"/"abshowExpression(MultiplyOperationab)=showExpressionBuilder"*"abshowExpression(ShiftLeftOperationab)=showExpressionBuilder"<<"abshowExpression(ShiftRightOperationab)=showExpressionBuilder">>"abshowExpression(AndOperationab)=showExpressionBuilder"and"abshowExpression(OrOperationab)=showExpressionBuilder"or"abshowExpression(EqualOperationab)=showExpressionBuilder"=="abshowExpression(DifferentOperationab)=showExpressionBuilder"!="abshowExpression(AboveOperationab)=showExpressionBuilder">"abshowExpression(AboveEqualOperationab)=showExpressionBuilder">="abshowExpression(UnderEqualOperationab)=showExpressionBuilder"<="abshowExpression(UnderOperationab)=showExpressionBuilder"<"abshowExpression(RegexpOperationab)=showExpressionBuilder"=~"abshowExpression(NotRegexpOperationab)=showExpressionBuilder"!~"abshowExpression(NotOperationa)=char'('<>char'!'<+>showExpressiona<>char')'showExpression(NegOperationa)=char'('<>char'-'<+>showExpressiona<>char')'showExpression(BTrue)=text"true"showExpression(BFalse)=text"false"showExpression(LookupOperationab)=showExpressiona<>char'['<>showExpressionb<>char']'showExpressionx=text(showx)showValue::Value->DocshowValue(Literalx)=text(showx)showValue(VariableReferencex)=text"$"<>textxshowValue(FunctionCallfuncnameargs)=textfuncname<>parens(hcat(mapshowExpressionargs))showValue(PuppetArrayx)=brackets(hcat(punctuate(text", ")(mapshowExpressionx)))showValue(ResourceReferencertypername)=textrtype<>brackets(showExpressionrname)showValue(PuppetHash(Parametersparams))=hanglbrace2(showAssignmentsparams)$$rbraceshowValue(Integerx)=integerxshowValuex=text(showx)showAssignments::[(Expression,Expression)]->DocshowAssignmentsparams=vcat(punctuate(text", ")(mapshowAssignmentparams))showAssignment::(Expression,Expression)->DocshowAssignment(param,value)=showExpressionparam<+>text"=>"<+>showExpressionvalue-- | Useful for displaying a map of variables.showVarMap::Map.MapString(Expression,SourcePos)->StringshowVarMapx=render$vcat(mapdescLine(Map.toListx))wheredescLine(name,(expr,pos))=textname<+>char'='<+>showExpressionexpr<+>char'('<>text(showpos)<>char')'