-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Configurable text rendering of trees. -- -- Configurable text rendering of trees. @package tree-render-text @version 0.4.0.0 -- | Configurable text rendering of trees. -- -- Example renderings for: -- --
--   import Data.Tree
--   import Data.Tree.Render.Text
--   
--   tree :: Tree String
--   tree
--     = Node "Add"
--       [ Node "Add"
--         [ Node "0" []
--         , Node "Mul"
--           [ Node "1" []
--           , Node "2" []
--           ]
--         ]
--       , Node "Neg"
--         [ Node "Max"
--           [ Node "3" []
--           , Node "4" []
--           , Node "5" []
--           , Node "Var"
--             [ Node "x" []
--             ]
--           , Node "6" []
--           ]
--         ]
--       ]
--   
--   renderTree (tracedRenderOptions id) tree
--   
--   ● Add
--   ├─● Add
--   │ ├─● 0
--   │ ╰─● Mul
--   │   ├─● 1
--   │   ╰─● 2
--   ╰─● Neg
--     ╰─● Max
--       ├─● 3
--       ├─● 4
--       ├─● 5
--       ├─● Var
--       │ ╰─● x
--       ╰─● 6
--   
--   Other renderings by setting 'ParentLocation' and 'ChildOrder' in the options:
--   
--     ╭─● 0         ╭─● 0       ● Add             ╭─● 6         ╭─● 6
--     │ ╭─● 1     ╭─● Add       ├─● Neg           │ ╭─● x       │ ╭─● x
--     │ ├─● 2     │ │ ╭─● 1     │ ╰─● Max         ├─● Var       ├─● Var
--     ├─● Mul     │ ╰─● Mul     │   ├─● 6         ├─● 5         ├─● 5
--   ╭─● Add       │   ╰─● 2     │   ├─● Var       ├─● 4       ╭─● Max
--   │   ╭─● 3     ● Add         │   │ ╰─● x       ├─● 3       │ ├─● 4
--   │   ├─● 4     ╰─● Neg       │   ├─● 5       ╭─● Max       │ ╰─● 3
--   │   ├─● 5       │ ╭─● 3     │   ├─● 4     ╭─● Neg       ╭─● Neg
--   │   │ ╭─● x     │ ├─● 4     │   ╰─● 3     │   ╭─● 2     ● Add
--   │   ├─● Var     ╰─● Max     ╰─● Add       │   ├─● 1     │   ╭─● 2
--   │   ├─● 6         ├─● 5       ├─● Mul     │ ╭─● Mul     │ ╭─● Mul
--   │ ╭─● Max         ├─● Var     │ ├─● 2     │ ├─● 0       │ │ ╰─● 1
--   ├─● Neg           │ ╰─● x     │ ╰─● 1     ├─● Add       ╰─● Add
--   ● Add             ╰─● 6       ╰─● 0       ● Add           ╰─● 0
--   
module Data.Tree.Render.Text -- | Describes where a parent node is rendered, relative to its children. data ParentLocation -- | Renders the parent before any of its children. ParentBeforeChildren :: ParentLocation -- | Renders the parent after all of its children. ParentAfterChildren :: ParentLocation -- | Renders the parent in the middle of its children (if there are -- multiple children). The index is rounded down when using -- FirstToLast and rounded up when using LastToFirst. ParentBetweenChildren :: ParentLocation -- | This is a value from [0, 1, ..., length children] inclusive. -- (Values outside this range are clamped to the closest valid value.) -- -- A value of 0 makes the parent rendered before any of its -- children A value of length children makes the parent rendered -- after all of its children. Other values place the parent in the -- corresponding spot between its children. ParentAtChildIndex :: Int -> ParentLocation -- | Describes the render order of a node's children. data ChildOrder FirstToLast :: ChildOrder LastToFirst :: ChildOrder -- | A part of a path along a rendered tree. data BranchPath -- | Describes a turn going up toward the left. -- -- e.g. "╭─" BranchUp :: BranchPath -- | Describes a turn going down toward the left. -- -- e.g. "╰─" BranchDown :: BranchPath -- | Describes a T-join of a path going up and down toward the left. -- -- e.g. "├─" BranchJoin :: BranchPath -- | Describes a path going up and down. -- -- e.g. "│ " BranchContinue :: BranchPath -- | Describes a part that does NOT contain a path piece. -- -- e.g. " " BranchEmpty :: BranchPath -- | Local context about a node. data LocalContext label LocalContext :: Tree label -> !Int -> !Int -> !Int -> LocalContext label -- | The node assiated with this context. [lcCurrentNode] :: LocalContext label -> Tree label -- | The depth of the current node. [lcCurrentDepth] :: LocalContext label -> !Int -- | The index of the current node with respect to its parent's children. [lcLitterIndex] :: LocalContext label -> !Int -- | The number of children the current node's parent has. [lcLitterSize] :: LocalContext label -> !Int -- | Options used for rendering a Tree. data RenderOptionsM m string label RenderOptions :: (Maybe (LocalContext label) -> m ParentLocation) -> (Maybe (LocalContext label) -> m ChildOrder) -> Int -> Bool -> m () -> (string -> m ()) -> (Maybe label -> m string) -> (Maybe (LocalContext label) -> m string) -> (BranchPath -> string) -> RenderOptionsM m string label -- | Controls where parent nodes are rendered. -- -- A value of Nothing is passed when rending the artificial root -- of a Forest. -- -- Simple use cases would use a constant function ignoring the local -- context. [oParentLocation] :: RenderOptionsM m string label -> Maybe (LocalContext label) -> m ParentLocation -- | Controls the order a node's children are rendered. -- -- A value of Nothing is passed when rending the artificial root -- of a Forest. -- -- Simple use cases would use a constant function ignoring the local -- context. [oChildOrder] :: RenderOptionsM m string label -> Maybe (LocalContext label) -> m ChildOrder -- | The amount of vertical spacing between nodes. [oVerticalPad] :: RenderOptionsM m string label -> Int -- | If True, a newline is prepended to the rendered output. [oPrependNewline] :: RenderOptionsM m string label -> Bool -- | Writes a newline. [oWriteNewline] :: RenderOptionsM m string label -> m () -- | Writes a string. [oWrite] :: RenderOptionsM m string label -> string -> m () -- | Shows a rootLabel. The returned value should contain no -- newlines. [oShowNodeLabel] :: RenderOptionsM m string label -> Maybe label -> m string -- | Get the marker for a node (without rendering its label). The returned -- value should contain no newlines. -- -- LocalContext is passed as an argument to allow things such as: -- -- -- -- A value of Nothing is passed when rending the artificial root -- of a Forest. -- -- Simple use cases would typically ignore the local context. [oNodeMarker] :: RenderOptionsM m string label -> Maybe (LocalContext label) -> m string -- | Shows a BranchPath. The returned value should contain no -- newlines and should all be of the same printed width when rendered as -- text. [oShowBranchPath] :: RenderOptionsM m string label -> BranchPath -> string -- | An alias of RenderOptionsM for producing pure String -- renders. type RenderOptions = RenderOptionsM (Writer (DList Char)) -- | Renders a Tree to a String. renderTree :: RenderOptions String label -> Tree label -> String -- | Renders a Forest to a String. renderForest :: RenderOptions String label -> Forest label -> String -- | Renders a pretty printed Tree within a monadic context. renderTreeM :: Monad m => RenderOptionsM m string label -> Tree label -> m () -- | Renders a pretty printed Forest within a monadic context. renderForestM :: Monad m => RenderOptionsM m string label -> Forest label -> m () -- | A simplified tracedRenderOptionsM specialized to -- RenderOptions. tracedRenderOptions :: (label -> String) -> RenderOptions String label -- | A simplified tracedRenderOptionsAsciiM specialized to -- RenderOptions. tracedRenderOptionsAscii :: (label -> String) -> RenderOptions String label -- | A simplified middleCutRenderOptionsM specialized to -- RenderOptions. middleCutRenderOptions :: (label -> String) -> RenderOptions String label -- | A simplified zigZagRenderOptionsM specialized to -- RenderOptions. zigZagRenderOptions :: (label -> String) -> RenderOptions String label -- | A simplified tabbedRenderOptionsM specialized to -- RenderOptions. tabbedRenderOptions :: String -> (label -> String) -> RenderOptions String label -- | Options for rendering a line-traced tree using unicode drawing -- characters. -- -- This uses: -- --
--   BranchUp       -> "╭─"
--   BranchDown     -> "╰─"
--   BranchJoin     -> "├─"
--   BranchContinue -> "│ "
--   BranchEmpty    -> "  "
--   
-- --
--   oNodeMarker = \case
--     Just {} -> "● "
--     Nothing -> "●"
--   
tracedRenderOptionsM :: Monad m => (String -> string) -> (string -> m ()) -> (label -> m string) -> RenderOptionsM m string label -- | Options for rendering a line-traced tree using ASCII characters. -- -- This uses: -- --
--   BranchUp       -> ",-"
--   BranchDown     -> "`-"
--   BranchJoin     -> "|-"
--   BranchContinue -> "| "
--   BranchEmpty    -> "  "
--   
-- --
--   oNodeMarker = \case
--     Just {} -> "o "
--     Nothing -> "o"
--   
tracedRenderOptionsAsciiM :: Monad m => (String -> string) -> (string -> m ()) -> (label -> m string) -> RenderOptionsM m string label -- | A variety on tracedRenderOptionsM where the path tracing is -- performed in a zig-zag-like fashion such that there is a cut down the -- middle of a node's children. middleCutRenderOptionsM :: Monad m => (String -> string) -> (string -> m ()) -> (label -> m string) -> RenderOptionsM m string label -- | A variety on tracedRenderOptionsM where the path tracing is -- performed in a zig-zag fashion. zigZagRenderOptionsM :: Monad m => (String -> string) -> (string -> m ()) -> (label -> m string) -> RenderOptionsM m string label -- | Options for rendering a tree in rows indented only by tabs. tabbedRenderOptionsM :: Monad m => String -> (String -> string) -> (string -> m ()) -> (label -> m string) -> RenderOptionsM m string label instance GHC.Classes.Ord Data.Tree.Render.Text.BranchPath instance GHC.Classes.Eq Data.Tree.Render.Text.BranchPath instance GHC.Show.Show Data.Tree.Render.Text.BranchPath instance GHC.Classes.Ord Data.Tree.Render.Text.ChildOrder instance GHC.Classes.Eq Data.Tree.Render.Text.ChildOrder instance GHC.Show.Show Data.Tree.Render.Text.ChildOrder instance GHC.Classes.Ord Data.Tree.Render.Text.ParentLocation instance GHC.Classes.Eq Data.Tree.Render.Text.ParentLocation instance GHC.Show.Show Data.Tree.Render.Text.ParentLocation