beautifHOLContentsIndex
PrintHOL
Description
Module handles the actual pretty-printing.
Synopsis
type Flags = [String]
arglst :: Flags
notreeArg :: String
data Env = EnvDT {
label :: Int
newLn :: Bool
unOp :: Int
absInd :: Int
relInd :: Int
defaultInd :: Int
prevSameBinOp :: Bool
splitArgs :: Bool
innerTerm :: Bool
showLabels :: Bool
noLabels :: Bool
}
mkinitEnv :: Flags -> Env
resetEnv :: Env -> Env
printTree :: Print a => a -> Flags -> String
type Doc = [ShowS] -> [ShowS]
doc :: ShowS -> Doc
render :: Doc -> String
concatS :: [ShowS] -> ShowS
concatD :: [Doc] -> Doc
replicateS :: Int -> ShowS -> ShowS
spaces :: Int -> ShowS
type EnvT = Reader Env Doc
prtList :: Print a => [a] -> [Env] -> [Doc]
class Print a where
prt :: a -> EnvT
mkEsc :: Char -> Char -> ShowS
maxLabels :: [SENT] -> Env -> [Env]
intersperseTerms :: Env -> [TERM] -> [Doc]
binOpDoc :: Env -> SENT -> SENT -> String -> Int -> (SENT -> Bool) -> Doc
quantDoc :: Env -> [TERM] -> SENT -> String -> Int -> (SENT -> Bool) -> Doc
ifDoc :: Env -> SENT -> SENT -> SENT -> Doc
ifEnv :: Env -> Int -> Int -> Int -> Env
letDoc :: Env -> [DEF] -> SENT -> Doc
letEnv :: Env -> Int -> Int -> Bool -> Env
notEnv :: Env -> Int -> Bool -> Env
argSeparators :: Env -> Doc
nextLnArgs :: Env -> Doc
newSplit :: [TERM] -> Bool
curriedTerm :: [TERM] -> Bool
maxArg :: [TERM] -> Int
termStrLens :: TERM -> Int
numApp :: Bool -> Int -> Int -> Int
showLabel :: Env -> ShowS
predIdLen :: PredId -> Int
functIdLen :: FunctId -> Int
absIndUp :: Env -> Int -> Int
andSent :: SENT -> Bool
orSent :: SENT -> Bool
impSent :: SENT -> Bool
forallSent :: SENT -> Bool
existsSent :: SENT -> Bool
binEnv1 :: Env -> Int -> Bool -> Int -> Env
binEnv2 :: Env -> Int -> Bool -> Int -> Env
checkUnOpArg :: SENT -> String -> Doc
checkQuant :: SENT -> Bool
checkBinOp :: SENT -> Bool
negInd :: Env -> SENT -> Doc
quantEnv1 :: Env -> Int -> Bool -> Int -> Env
relUpdate :: Int -> Int -> Int
simpInd :: Env -> Doc
upIndUnOp :: Env -> Int -> Int
quantOpInd :: Env -> String -> Doc
binaryOpInd :: Env -> String -> Doc
computeSpcs :: Bool -> Int -> Int -> ShowS
labelInd :: Env -> ShowS
Documentation
type Flags = [String]
Possible flags to the program.
arglst :: Flags
List of possible arguments. Do not modify the ordering of this list (add new flags to the end).
notreeArg :: String
Defne flags here so they can be easily renamed.
data Env
The major datatype passed around holding the pretty-printing state.
Constructors
EnvDT
label :: IntLine label
newLn :: BoolIf true, then we're on a new line. Note: binary operators are always on a new line; this tells us whether some other sentence or term is on its own line.
unOp :: IntHow many negations we've seen
absInd :: IntIndentation after label stuff. Where the line begins.
relInd :: IntRelative indentation (from last operator)
defaultInd :: IntDefault indendtation (up to the longest label of a formula)
prevSameBinOp :: BoolWas this binary operator the argument to the same binary operator? (If so, we don't indent.)
splitArgs :: BoolTrue: put args to functions & predicates on their own line. The number is the length of the identifier, plus other args and identifiers, up to this term.
innerTerm :: BoolIs this term inside another term? (The only case in which it is not is if it is an argument to = .)
showLabels :: BoolShow labels? This is only for whether labels should currently be suppressed (e.g., in let defs). For no labels at all, we set a global flag.
noLabels :: BoolAre we showing labels at all (or are they globally suppressed)?
mkinitEnv :: Flags -> Env
The initial environment.
resetEnv :: Env -> Env
Resets the environment except for the default indentation (from the length of the longest label).
printTree :: Print a => a -> Flags -> String
type Doc = [ShowS] -> [ShowS]
doc :: ShowS -> Doc
render :: Doc -> String
Takes the final Doc and returns the output. Ideally, the Doc should be considered the logical structure of the pretty-printed formula and the render assigns concrete syntax.
concatS :: [ShowS] -> ShowS
concatD :: [Doc] -> Doc
replicateS :: Int -> ShowS -> ShowS
spaces :: Int -> ShowS
type EnvT = Reader Env Doc
prtList :: Print a => [a] -> [Env] -> [Doc]
class Print a where
The Print class. Each constructor of the grammar instantiates this. The prt function tells how to pretty-print each construct.
Methods
prt :: a -> EnvT
show/hide Instances
mkEsc :: Char -> Char -> ShowS
Escape characters for rendering.
maxLabels :: [SENT] -> Env -> [Env]
intersperseTerms :: Env -> [TERM] -> [Doc]
For a list of terms, we intersperse the argument separator string.
binOpDoc :: Env -> SENT -> SENT -> String -> Int -> (SENT -> Bool) -> Doc
Returns the String to bring for binary operator sentences.
quantDoc :: Env -> [TERM] -> SENT -> String -> Int -> (SENT -> Bool) -> Doc
Returns the String to print for a forall/exists sentence.
ifDoc :: Env -> SENT -> SENT -> SENT -> Doc
Returns the string to print for if-then-else sentences.
ifEnv
:: Env
-> Intlength of ifTab
-> Intextra space needed because if is shorter than then and else
-> Intoperand label
-> Env
New environment for the second argument to a binary operator.
letDoc :: Env -> [DEF] -> SENT -> Doc
Returns the doc for let [defs] in SENT. [DEF] should be nonempty.
letEnv
:: Env
-> Intlength of letTab
-> Intextra space needed because let is longer than in
-> Boolwhether labels should be shown or suppressed
-> Env
notEnv :: Env -> Int -> Bool -> Env
argSeparators :: Env -> Doc
Takes an environment and returns separators (default is commas) for between lists of variables, terms, etc. and if necessary, it inserts linebreak commands. The Doc returned is interspersed into the list of of variables or terms.
nextLnArgs :: Env -> Doc
Puts either args or curried arguments on the next line with the right indenting.
newSplit :: [TERM] -> Bool
Are the args long enough that we have to split them, or is there a curried function that is a term?
curriedTerm :: [TERM] -> Bool
maxArg :: [TERM] -> Int
termStrLens :: TERM -> Int
numApp
:: Boolare labels currently suppressed (e.g., in let...in statements).
-> Intdepth
-> Intwhich operand
-> Int
showLabel :: Env -> ShowS
predIdLen :: PredId -> Int
functIdLen :: FunctId -> Int
absIndUp :: Env -> Int -> Int
Absolute indentation (for splitting across lines and not splitting).
andSent :: SENT -> Bool
orSent :: SENT -> Bool
impSent :: SENT -> Bool
forallSent :: SENT -> Bool
existsSent :: SENT -> Bool
binEnv1
:: Env
-> Int
-> Boolis the same operator as we've just seen, so no indentation
-> Intlabel
-> Env
Returns the new environment for the first argument to a binary operator.
binEnv2 :: Env -> Int -> Bool -> Int -> Env
Returns the new environment for second argument to a binary operator (see documentation for binEnv1).
checkUnOpArg :: SENT -> String -> Doc
If the next sentence to parse is a binary operator sentence, then don't do anything the not will printed with the next sentence. Otherwise, just do the indenting.
checkQuant :: SENT -> Bool
True if there is a sequence of not sentences followed by a quantified sentence.
checkBinOp :: SENT -> Bool
True if there is a sequence of negated sentences followed by a binary operator sentence.
negInd :: Env -> SENT -> Doc
quantEnv1 :: Env -> Int -> Bool -> Int -> Env
relUpdate
:: Int
-> Inti==0 menas the environment hasn't been indented yet.
-> Int
If the env has not been indented yet (i==0), then just update according to the operator's tab width (j); otherwise add the old relative indent, the new tab, and an extra space between the strings.
simpInd :: Env -> Doc
Indentation for binary operator sentences.
upIndUnOp
:: Env
-> Intoperator size
-> Int
Returns an absolute indentation depending on the operator size and whether there is a preceding unary operator. Does not indent for operators of the same kind (so there's no precedence to record).
quantOpInd :: Env -> String -> Doc
binaryOpInd :: Env -> String -> Doc
If we're inside a not sentence, then put this sentence right after the nots.
computeSpcs
:: Boolare there labels
-> Intspaces before separator
-> Intspaces after separator
-> ShowS
Compute spaces from beginning of line.
labelInd :: Env -> ShowS
Returns the indentation for directly after a label.
Produced by Haddock version 2.4.1