Safe Haskell | None |
---|---|
Language | Haskell2010 |
Very nice Treap
visualisation.
Synopsis
- pretty :: forall m a. (Coercible m a, Show a) => Treap m a -> String
- prettyPrint :: forall m a. (Coercible m a, Show a) => Treap m a -> IO ()
- prettyWith :: forall m a. (Size -> Priority -> m -> a -> String) -> Treap m a -> String
- compactShowNode :: forall m a. (Coercible m a, Show a) => Size -> Priority -> m -> a -> String
- data BinTree
- showTree :: BinTree -> String
- middleLabelPos :: String -> Int
- branchLines :: Int -> [String]
Documentation
pretty :: forall m a. (Coercible m a, Show a) => Treap m a -> String Source #
Show Treap
in a pretty way using compactShowNode
function.
prettyPrint :: forall m a. (Coercible m a, Show a) => Treap m a -> IO () Source #
Call pretty
function and output the result directly to stdout
.
prettyWith :: forall m a. (Size -> Priority -> m -> a -> String) -> Treap m a -> String Source #
Show Treap
in a nice way using given function to display node.
compactShowNode :: forall m a. (Coercible m a, Show a) => Size -> Priority -> m -> a -> String Source #
Show Treap
node in a format:
<size>,<acc>:a
Internal implementation details
Intermidiate structure to help string conversion.
showTree :: BinTree -> String Source #
Hardcore function responsible for pretty showing of the BinTree
data type.
middleLabelPos :: String -> Int Source #
Calculates position of middle of non-space part of the string.
>>>
s = " abc "
>>>
length s
7>>>
middleLabelPos s
4
branchLines :: Int -> [String] Source #
Draws branches of the given height.
>>>
putStrLn $ toLines $ branchLines 1
╱╲
>>>
putStrLn $ toLines $ branchLines 2
╱╲ ╱ ╲
>>>
putStrLn $ toLines $ branchLines 3
╱╲ ╱ ╲ ╱ ╲