Plain source file: src/compiler/GF/Command/TreeOperations.hs (2015-03-03)

GF.Command.TreeOperations is imported by: ...

moduleGF.Command.TreeOperations(treeOp,allTreeOps,treeChunks)whereimportPGFimportPGF.Internal(Expr(..),unAppForm)importData.ListtypeTreeOp=[Expr]->[Expr]treeOp::PGF->String->Maybe(EitherTreeOp(CId->TreeOp))treeOppgff=fmapsnd$lookupf$allTreeOpspgfallTreeOps::PGF->[(String,(String,EitherTreeOp(CId->TreeOp)))]allTreeOpspgf=[ ("compute",("compute by using semantic definitions (def)",Left$map(computepgf))), ("transfer",("syntactic transfer by applying function, recursively in subtrees",Right$\f->map(transferpgff))), ("paraphrase",("paraphrase by using semantic definitions (def)",Left$nub.concatMap(paraphrasepgf))), ("largest",("sort trees from largest to smallest, in number of nodes",Left$largest)), ("nub",("remove duplicate trees",Left$nub)), ("smallest",("sort trees from smallest to largest, in number of nodes",Left$smallest)), ("subtrees",("return all fully applied subtrees (stopping at abstractions), by default sorted from the largest",Left$concatMapsubtrees)), ("funs",("return all fun functions appearing in the tree, with duplications",Left$concatMapfunNodes)) --- ("chunks",("return all chunks, i.e. maximal subtrees where the top node is not a metavariable", --- Left $ concatMap treeChunks)) --- a tree with ? head does not type check anyway AR 5/11/2013 ]largest::[Expr]->[Expr]largest=reverse.smallestsmallest::[Expr]->[Expr]smallest=sortBy(\tu->compare(sizet) (sizeu))wheresizet=casetofEAbs__e->sizee+1EAppe1e2->sizee1+sizee2+1_->1treeChunks::Expr->[Expr]treeChunks=snd.ckswhereckst=caseunAppFormtof(EFunf,ts)->caseunzip(mapcksts)of(bs,_)|andbs->(True, [t]) (_,cts)->(False,concatcts) (EMeta_,ts)->(False,concatMap(snd.cks)ts)_->(True, [t])subtrees::Expr->[Expr]subtreest=t:caseunApptofJust(f,ts)->concatMapsubtreests_->[] -- don't go under abstractionsfunNodes::Expr->[Expr]funNodest=casetofEAbs__e->funNodeseEAppe1e2->funNodese1++funNodese2EFun_->[t]_->[] -- not literals, metas, etc --- simple-minded transfer; should use PGF.Expr.matchtransfer::PGF->CId->Expr->Exprtransferpgffe=casetransfeofv|v/=appfe->v_->caseeofEAppga->EApp(transferpgffg) (transferpgffa)_->ewhereappf=EApp(EFunf)transf=computepgf.appf

Index

(HTML for this module was generated on 2015-03-03. About the conversion tool.)