Module Text.PrettyImpl

Implementation of the Pretty library using linear-time, bounded implementation by Olaf Chitil.

Author: Sebastian Fischer, Bjoern Peemoeller, Jan Tikovsky

Version: December 2018

Summary of exported operations:

deDoc :: Doc -> Tokens -> Tokens  Deterministic 
resetFormat :: [FormatStm] -> (FormatStm,[FormatStm])  Deterministic 
prevFGColor :: [FormatStm] -> Color  Deterministic 
prevBGColor :: [FormatStm] -> Color  Deterministic 
prevIntensity :: [FormatStm] -> Intensity  Deterministic 
prevBlinkMode :: [FormatStm] -> BlinkMode  Deterministic 
applyFormat :: FormatStm -> String  Deterministic 
txtMode :: Int -> String  Deterministic 
colorMode :: Color -> Int  Deterministic 
intensityMode :: Intensity -> Int  Deterministic 
blinkMode :: BlinkMode -> Int  Deterministic 
applyNesting :: Nesting -> Int -> Int -> [Int] -> [Int]  Deterministic 
unApplyNesting :: [Int] -> [Int]  Deterministic 
addSpaces :: Int -> Tokens -> String  Deterministic 
normalise :: Tokens -> Tokens  Deterministic 
doc2Tokens :: Doc -> Tokens  Deterministic 
showWidth :: Int -> Doc -> String  Deterministic 
(showWidth w d) pretty prints document d with a page width of w characters
lengthVis :: String -> Int  Deterministic 
noGroup :: Tokens -> Int -> Int -> Int -> [Int] -> [FormatStm] -> String  Deterministic 
oneGroup :: Tokens -> Int -> Int -> Int -> (Bool -> (Int -> [Int] -> [FormatStm] -> String) -> Int -> [Int] -> [FormatStm] -> String) -> Int -> [Int] -> [FormatStm] -> String  Deterministic 
multiGroup :: Tokens -> Int -> Int -> Int -> (Bool -> (Int -> [Int] -> [FormatStm] -> String) -> Int -> [Int] -> [FormatStm] -> String) -> Queue (Int,Bool -> (Int -> [Int] -> [FormatStm] -> String) -> Int -> [Int] -> [FormatStm] -> String) -> Int -> (Bool -> (Int -> [Int] -> [FormatStm] -> String) -> Int -> [Int] -> [FormatStm] -> String) -> Int -> [Int] -> [FormatStm] -> String  Deterministic 
pruneOne :: Tokens -> Int -> Int -> Int -> (Bool -> (Int -> [Int] -> [FormatStm] -> String) -> Int -> [Int] -> [FormatStm] -> String) -> Int -> [Int] -> [FormatStm] -> String  Deterministic 
pruneMulti :: Tokens -> Int -> Int -> Int -> (Bool -> (Int -> [Int] -> [FormatStm] -> String) -> Int -> [Int] -> [FormatStm] -> String) -> Queue (Int,Bool -> (Int -> [Int] -> [FormatStm] -> String) -> Int -> [Int] -> [FormatStm] -> String) -> Int -> (Bool -> (Int -> [Int] -> [FormatStm] -> String) -> Int -> [Int] -> [FormatStm] -> String) -> Int -> [Int] -> [FormatStm] -> String  Deterministic 
inspect :: Doc -> Tokens  Deterministic 

Exported datatypes:


Doc

Constructors:


Horizontal

Type synonym: Horizontal = Bool


Remaining

Type synonym: Remaining = Int


Width

Type synonym: Width = Int


Position

Type synonym: Position = Int


StartPosition

Type synonym: StartPosition = Position


EndPosition

Type synonym: EndPosition = Position


Out

Type synonym: Out = Remaining -> Margins -> FormatHistory -> String


OutGroupPrefix

Type synonym: OutGroupPrefix = Horizontal -> Out -> Out


Margins

Type synonym: Margins = [Int]


Nesting

Constructors:

  • Align :: Nesting
  • Inc :: Int -> Nesting

Color

Constructors:

  • Black :: Color
  • Red :: Color
  • Green :: Color
  • Yellow :: Color
  • Blue :: Color
  • Magenta :: Color
  • Cyan :: Color
  • White :: Color
  • Default :: Color

Intensity

Constructors:

  • Faint :: Intensity
  • Normal :: Intensity
  • Bold :: Intensity

BlinkMode

Constructors:

  • Off :: BlinkMode
  • Slow :: BlinkMode
  • Rapid :: BlinkMode

FormatStm

Constructors:

  • SetForeground :: Color -> FormatStm
  • SetBackground :: Color -> FormatStm
  • SetIntensity :: Intensity -> FormatStm
  • SetBlinkMode :: BlinkMode -> FormatStm
  • SetItalicized :: Bool -> FormatStm
  • SetUnderlined :: Bool -> FormatStm
  • SetCrossedout :: Bool -> FormatStm
  • InverseColoring :: Bool -> FormatStm

FormatHistory

Type synonym: FormatHistory = [FormatStm]


Tokens

Constructors:


Exported operations:

deDoc :: Doc -> Tokens -> Tokens  Deterministic 

Further infos:
  • solution complete, i.e., able to compute all solutions

prevFGColor :: [FormatStm] -> Color  Deterministic 

prevBGColor :: [FormatStm] -> Color  Deterministic 

applyFormat :: FormatStm -> String  Deterministic 

txtMode :: Int -> String  Deterministic 

colorMode :: Color -> Int  Deterministic 

intensityMode :: Intensity -> Int  Deterministic 

blinkMode :: BlinkMode -> Int  Deterministic 

applyNesting :: Nesting -> Int -> Int -> [Int] -> [Int]  Deterministic 

unApplyNesting :: [Int] -> [Int]  Deterministic 

addSpaces :: Int -> Tokens -> String  Deterministic 

normalise :: Tokens -> Tokens  Deterministic 

doc2Tokens :: Doc -> Tokens  Deterministic 

showWidth :: Int -> Doc -> String  Deterministic 

(showWidth w d) pretty prints document d with a page width of w characters

Example call:
(showWidth w d)
Parameters:
  • w : width of page
  • d : a document
Returns:
pretty printed document

lengthVis :: String -> Int  Deterministic 

noGroup :: Tokens -> Int -> Int -> Int -> [Int] -> [FormatStm] -> String  Deterministic 

oneGroup :: Tokens -> Int -> Int -> Int -> (Bool -> (Int -> [Int] -> [FormatStm] -> String) -> Int -> [Int] -> [FormatStm] -> String) -> Int -> [Int] -> [FormatStm] -> String  Deterministic 

multiGroup :: Tokens -> Int -> Int -> Int -> (Bool -> (Int -> [Int] -> [FormatStm] -> String) -> Int -> [Int] -> [FormatStm] -> String) -> Queue (Int,Bool -> (Int -> [Int] -> [FormatStm] -> String) -> Int -> [Int] -> [FormatStm] -> String) -> Int -> (Bool -> (Int -> [Int] -> [FormatStm] -> String) -> Int -> [Int] -> [FormatStm] -> String) -> Int -> [Int] -> [FormatStm] -> String  Deterministic 

pruneOne :: Tokens -> Int -> Int -> Int -> (Bool -> (Int -> [Int] -> [FormatStm] -> String) -> Int -> [Int] -> [FormatStm] -> String) -> Int -> [Int] -> [FormatStm] -> String  Deterministic 

pruneMulti :: Tokens -> Int -> Int -> Int -> (Bool -> (Int -> [Int] -> [FormatStm] -> String) -> Int -> [Int] -> [FormatStm] -> String) -> Queue (Int,Bool -> (Int -> [Int] -> [FormatStm] -> String) -> Int -> [Int] -> [FormatStm] -> String) -> Int -> (Bool -> (Int -> [Int] -> [FormatStm] -> String) -> Int -> [Int] -> [FormatStm] -> String) -> Int -> [Int] -> [FormatStm] -> String  Deterministic 

inspect :: Doc -> Tokens  Deterministic