P7J m      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijkl mnopqrstuvwx mnopqrstuvwx mponnopqrstuvwxA newtype wrapper around Attr f a so that we can make Attr f E an instance of Functor, Foldable and Traversable. This is necessary D since Haskell does not allow partial application of type synonyms. " Functorised"% versions of standard type classes. 5 If you have your own structure functor, for example   Expr e  = Kst Int  | Var String  | Add e e < deriving (Eq,Ord,Read,Show,Functor,Foldable,Traversable) 6you should make it an instance of these, so that the  fixed-point type Mu Expr can be an instance of  Eq, Ord and Show. Doing so is very easy:  - instance EqF Expr where equalF = (==) 0 instance OrdF Expr where compareF = compare 2 instance ShowF Expr where showsPrecF = showsPrec The Read6 instance depends on whether we are using GHC or not.  The Haskell98 version is  2 instance ReadF Expr where readsPrecF = readsPrec while the GHC version is 1 instance ReadF Expr where readPrecF = readPrec Annotated fixed-point type.  Annotations. The fixed-point type. !" The attribute of the root node. #AA function forgetting all the attributes from an annotated tree.  !"#"# ! ! !"#$ The list of direct descendants. %GThe list of all substructures. Together with list-comprehension syntax  this is a powerful query tool. &Bottom-up transformation. '(>Top-down transformation. This provided only for completeness;  usually, it is & what you want use instead. )*'Non-recursive top-down transformation. +,9Bottom-up transformation until a normal form is reached. -.We annotate9 the nodes of the tree with functions which replace that  particular subtree. /Flattened version of .. 0Left fold. Since Mu f. is not a functor, but a type, we cannot make  it an instance of the Foldable type class. 12JThe children together with functions replacing that particular child. 340Apply the given function to each child in turn. 53Builds up a structure from a list of the children. $%&'()*+,-./012345$%&'()*+,-./012345$%&'()*+,-./0123456A  paramorphism is a generalized (right) fold. 789A  catamorphism( is a simpler version of a paramorphism :An  anamorphism is simply an unfold. ;A  hylomorphism: is the composition of a catamorphism and an anamorphism. 6789:;6789:;6789:; < Synthetised0 attributes are created in a bottom-up manner.  As an example, the sizes$ function computes the sizes of all  subtrees:  8 sizes :: (Functor f, Foldable f) => Mu f -> Attr f Int & sizes = synthetise (\t -> 1 + sum t)  (note that sum here is 7Data.Foldable.sum == Prelude.sum . Data.Foldable.toList) =Generalization of scanr for trees. >?@ Inherited/ attributes are created in a top-down manner.  As an example, the depths function computes the depth A (the distance from the root, incremented by 1) of all subtrees: + depths :: Functor f => Mu f -> Attr f Int " depths = inherit (\_ i -> i+1) 0 AGeneralization of scanl for trees BKSynthetising attributes via an accumulating map in a left-to-right fashion  (the order is the same as in foldl). CKSynthetising attributes via an accumulating map in a right-to-left fashion  (the order is the same as in foldr). DEFWe use B to number the nodes from 0 to (n-1) in * a left-to-right traversal fashion, where  n == length (universe tree)! is the number of substructures,  which is also returned. G<=>?@ABCDEFG<=>?@ABCDEFG <=>?@ABCDEFG"HIJKLMNOPQ:Creates a zipper from a tree, with the focus at the root. RRestores a tree from a zipper. SThe zipper version of #. TUVW+Moves down the child with the given index. ! The leftmost children has index 0. XMoves down the leftmost child. Y Moves down the rightmost child. Z[\]Checks whether we are the top. ^$Checks whether we cannot move down. _`a+Moves to the top, by repeatedly moving up. bMoves left until it can. cMoves right until it can. defghi"HIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghi"PLOMNHIJKQRSTUVWXYZ[\]^_`abcdefghi"HIJKIJKLOMNMNOPQRSTUVWXYZ[\]^_`abcdefghij%The type of natural transformations. k"Changing the structure of a tree. l0Lifting natural transformations to annotations. jkljkljklm  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijkl y               !"#$%&''()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSSTUVVWXYZ[\]^_`abcdefghijklmnopqrstuvvwxyz{|}~ fixplate-0.1Data.Generics.Fixplate!Data.Generics.Fixplate.AttributesData.Generics.Fixplate.Base!Data.Generics.Fixplate.Traversals Data.Generics.Fixplate.MorphismsData.Generics.Fixplate.Zipper Data.Generics.Fixplate.StructureData.Generics.Fixplate.MiscbaseGHC.BasefmapFunctor Data.FoldableFoldableData.Traversable TraversablesequencemapM sequenceAtraversetoListfoldl1foldr1foldlfoldrfoldMapfoldAttribunAttribReadF readPrecFShowF showsPrecFOrdFcompareFEqFequalFAttrAnnattrunAnnMuFixunFix attributeforgetchildrenuniverse transform transformMtopDownTransformtopDownTransformMdescenddescendMrewriterewriteMcontext contextListfoldLeft foldRightholes holesListapplybuilderparapara'paraListcataanahylo synthetise synthetise'synthetiseList synthetiseMinheritinherit' synthAccumL synthAccumR synthAccumL_ synthAccumR_ numberNodes numberNodes_LocfocuspathPathunPathTopNoderootdefocus locForgetextractreplacemodifymoveDown moveDownL moveDownRmoveUp moveRightmoveLeftisTopisBottom isLeftmost isRightmostmoveTopleftmost rightmostunsafeMoveDownunsafeMoveDownLunsafeMoveDownR unsafeMoveUpunsafeMoveLeftunsafeMoveRightNatTrafo restructureliftAnnTwoOneEmpty mapAccumL_unsafeapp_prec<#> tillNothingchain chainJustiterateN