ff_&z      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxy5Common utility functions for the binary-tree package.(c) Donnacha Oisn Kidney 2018MITmail@doisinkidney.comportableSafe'SA clone of Control.Monad.State.Strict, reimplemented here to avoid the dependency.:An abstract representation of a textual drawing of a tree.,A function to convert a drawing to a string._Given an uncons function for a binary tree, draw the tree in a structured, human-readable way.dConvert a tree to the Drawing type. This function is exposed so that users may replace the call to  in D with a more efficient implementation that could use (for example) Text.Evaluate a stateful action.    'A simple, generic, inorder binary tree.(c) Donnacha Oisn Kidney, 2018MITmail@doisinkidney.com experimentalportableSafe16-C An inorder binary tree.A binary tree with one element.A binary tree with no elements.Fold over a tree.foldTree Leaf Node xs === xsThe depth of the tree. depth empty0depth (singleton ())1Unfold a tree from a seed. n a creates a tree of size n filled a."putStr (drawTree (replicate 4 ())) % () % ()%()%$ %()1\(NonNegative n) -> length (replicate n ()) === n   n a replicates the action a nz times, trying to balance the result as much as possible. The actions are executed in a preorder traversal (same as the z instance.)?toList (evalState (replicateA 10 (State (\s -> (s, s + 1)))) 1)[1,2,3,4,5,6,7,8,9,10]!4Construct a tree from a list, in an inorder fashion.toList (fromList xs) === xs"=Convert a tree to a human-readable structural representation.#putStr (drawTree (fromList [1..7])) % 1 % 2%$ % %34%$ % % 5 %6%$ %7#0Pretty-print a tree with a custom show function.6putStr (drawTreeWith (const "%") (fromList [1..7]) "") % % % %%$ % %%%%$ % % % %%%$ %%-putStr (drawTreeWith id (singleton "abc") "")abc=putStr (drawTreeWith id (Node (singleton "d") "abc" Leaf) "") % dabc%AputStr (drawTreeWith id (fromList ["abc", "d", "ef", "ghij"]) "") % abc % d%ef%$ %ghij$Pretty-print a tree.printTree (fromList [1..7]) % 1 % 2%$ % %34%$ % % 5 %6%$ %7printTree (singleton 1)1-printTree (singleton 1 `mappend` singleton 2)1% %2%BThis instance is necessarily inefficient, to obey the monoid laws.printTree (fromList [1..6]) % 1 % 2%$ % %34%$ % % 5 %6%1printTree (fromList [1..6] `mappend` singleton 7) % 1 % 2%$ % %34%$ % % 5 %6%$ %7{ distributes over toList:HtoList (mappend xs (ys :: Tree Int)) === mappend (toList xs) (toList ys) !"#$ !"#$%A simple, generic, leafy binary tree.(c) Donnacha Oisn Kidney, 2018MITmail@doisinkidney.com experimentalportableSafe16A 8A leafy binary tree.;A binary tree with one element.<Fold over a tree.foldTree Leaf (:*:) xs === xs=The depth of the tree.depth (singleton ())1>Unfold a tree from a seed.?? n a creates a tree of size n filled with a.printTree (replicate 4 ()) % ()% %$%%()%$%% ()%%$ %().\(Positive n) -> length (replicate n ()) === n@@ n a replicates the action a nn times, trying to balance the result as much as possible. The actions are executed in the same order as the z instance.?toList (evalState (replicateA 10 (State (\s -> (s, s + 1)))) 1)[1,2,3,4,5,6,7,8,9,10]AConstruct a tree from a list.<The constructed tree is somewhat, but not totally, balanced.printTree (fromList [1,2,3,4]) % 1% %$%%2%$%% 3%%$ %4"printTree (fromList [1,2,3,4,5,6])  % 1 % %$ %%2% %$%%% 3%%%$% %4%$%% 5%%$ %6B=Convert a tree to a human-readable structural representation.0putStr (drawTree (Leaf 1 :*: Leaf 2 :*: Leaf 3)) % 1% %$%%2%$%3C0Pretty-print a tree with a custom show function.DPretty-print a treeN 4http://leventerkok.github.io/papers/erkok-thesis.pdfoErkok, Levent. Value Recursion in Monadic Computations.  PhD Thesis, Oregon Health & Science University, 2002. 8:9;<=>?@ABCD 89:>?@;A<=BCD89::5(A simple, generic, preorder binary tree.(c) Donnacha Oisn Kidney, 2018MITmail@doisinkidney.com experimentalportableSafe16^B YA preorder binary tree.\A binary tree with one element.]A binary tree with no elements.^Fold over a tree.foldTree Leaf Node xs === xs_The depth of the tree. depth empty0depth (singleton ())1`Unfold a tree from a seed.aa n a creates a tree of size n filled a."putStr (drawTree (replicate 4 ())) % () % ()%()%$ %()1\(NonNegative n) -> length (replicate n ()) === nbb n a replicates the action a nz times, trying to balance the result as much as possible. The actions are executed in a preorder traversal (same as the z instance.)?toList (evalState (replicateA 10 (State (\s -> (s, s + 1)))) 1)[1,2,3,4,5,6,7,8,9,10]c5Construct a tree from a list, in an preorder fashion.toList (fromList xs) === xsd=Convert a tree to a human-readable structural representation.#putStr (drawTree (fromList [1..7])) % 3 % 2%$ % %41%$ % % 6 %5%$ %7e0Pretty-print a tree with a custom show function.6putStr (drawTreeWith (const "%") (fromList [1..7]) "") % % % %%$ % %%%%$ % % % %%%$ %%-putStr (drawTreeWith id (singleton "abc") "")abc>putStr (drawTreeWith id (Node "abc" (singleton "d") Leaf) "") % dabc%AputStr (drawTreeWith id (fromList ["abc", "d", "ef", "ghij"]) "") % ef % d%abc%$ %ghijfPretty-print a tree.printTree (fromList [1..7]) % 3 % 2%$ % %41%$ % % 6 %5%$ %7-printTree (singleton 1 `mappend` singleton 2)1% %2gBThis instance is necessarily inefficient, to obey the monoid laws.printTree (fromList [1..6]) % 3 % 2%$ % %41%$ % % 6 %5%1printTree (fromList [1..6] `mappend` singleton 7) % 3 % 2%$ % %41%$ % % 6 %5%$ %7{ distributes over toList:HtoList (mappend xs (ys :: Tree Int)) === mappend (toList xs) (toList ys)YZ[\]^_`abcdefYZ[`ab\]c^_defYZ[Safe^|}~        !"#$%&'()*+,-./0123456789:;<= "#$%&'(),-./012+>?@456789:;< !"#$%&'()*+,-./0123456789:;<ABCDEFGHIJKLM*binary-tree-0.1.0.0-5kE77xsJTZyBUr3TAvFHdnData.Tree.Binary.InternalData.Tree.Binary.InorderData.Tree.Binary.LeafyData.Tree.Binary.PreorderPaths_binary_treebaseData.Functor.Identity runIdentityIdentityStaterunStateDrawingNilNewLine BottomLeft BottomRightTopLeftTopRightVertSplitItemPadding runDrawingdrawTree toDrawing evalState$fApplicativeState$fFunctorStateTreeLeafNode singletonemptyfoldTreedepth unfoldTree replicate replicateAfromList drawTreeWith printTree $fMonoidTree$fSemigroupTree $fRead1Tree $fShow1Tree $fOrd1Tree $fEq1Tree $fNFDataTree$fTraversableTree$fFoldableTree$fAlternativeTree$fApplicativeTree $fFunctorTree $fShowTree $fReadTree$fEqTree $fOrdTree $fDataTree $fGenericTree$fGeneric1Tree:*:$fMonadZipTree$fMonadFixTree $fMonadTree Data.FoldableFoldableGHC.Basemappendversion getBinDir getLibDir getDynLibDir getDataDir getLibexecDir getSysconfDirgetDataFileName