treap-0.0.0.0: Efficient implementation of the implicit treap data structure

Safe HaskellNone
LanguageHaskell2010

Treap.Pretty

Contents

Description

Very nice Treap visualisation.

Synopsis

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

data BinTree Source #

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
  ╱╲
 ╱  ╲
╱    ╲