| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
LambdaCube.Compiler.Pretty
- class PShow a where
- pShow :: PShow a => a -> Doc
- ppShow :: PShow a => a -> String
- ppShow' :: Show a => a -> String
- pParens :: Bool -> Doc -> Doc
- pOp :: (Ord a, PShow a1, PShow a2) => a -> Int -> Int -> Doc -> a -> a1 -> a2 -> Doc
- pOp' :: (Ord a, PShow a1, PShow a2) => a -> Int -> Int -> Doc -> a -> a1 -> a2 -> Doc
- pInfixl :: (PShow a, PShow a1) => Int -> Doc -> Int -> a -> a1 -> Doc
- pInfixr :: (PShow a, PShow a1) => Int -> Doc -> Int -> a -> a1 -> Doc
- pInfixr' :: (PShow a, PShow a1) => Int -> Doc -> Int -> a -> a1 -> Doc
- pInfix :: (PShow a, PShow a1) => Int -> Doc -> Int -> a -> a1 -> Doc
- pTyApp :: (PShow a, PShow a1) => Int -> a -> a1 -> Doc
- pApps :: (PShow a, PShow a1) => Int -> a -> [a1] -> Doc
- pApp :: (PShow a, PShow a1) => Int -> a -> a1 -> Doc
- showRecord :: (PShow a, PShow a1) => [(a, a1)] -> Doc
- pattern ESC :: [Char] -> [Char] -> [Char]
- splitESC :: [Char] -> Maybe ([Char], [Char])
- withEsc :: Show a => a -> [Char] -> [Char]
- inGreen :: [Char] -> [Char]
- inBlue :: [Char] -> [Char]
- inRed :: [Char] -> [Char]
- underlined :: [Char] -> [Char]
- removeEscs :: String -> String
- correctEscs :: String -> String
- putStrLn_ :: String -> IO ()
- error_ :: String -> c
- trace_ :: String -> a -> a
- throwError_ :: MonadError String m => String -> m a
- data Doc :: *
- (<+>) :: Doc -> Doc -> Doc
- (</>) :: Doc -> Doc -> Doc
- (<$$>) :: Doc -> Doc -> Doc
- hsep :: [Doc] -> Doc
- hcat :: [Doc] -> Doc
- vcat :: [Doc] -> Doc
- punctuate :: Doc -> [Doc] -> [Doc]
- tupled :: [Doc] -> Doc
- braces :: Doc -> Doc
- parens :: Doc -> Doc
- text :: String -> Doc
- nest :: Int -> Doc -> Doc
Documentation
Instances
| PShow Bool Source | |
| PShow Char Source | |
| PShow Double Source | |
| PShow Int Source | |
| PShow Integer Source | |
| PShow () Source | |
| PShow Doc Source | |
| PShow SI Source | |
| PShow Range Source | |
| PShow Env Source | |
| PShow Exp Source | |
| PShow a => PShow [a] Source | |
| PShow a => PShow (Maybe a) Source | |
| PShow a => PShow (Set a) Source | |
| Up a => PShow (SExp' a) Source | |
| (PShow a, PShow b) => PShow (Either a b) Source | |
| (PShow a, PShow b) => PShow (a, b) Source | |
| (PShow s, PShow a) => PShow (Map s a) Source | |
| (PShow a, PShow b, PShow c) => PShow (a, b, c) Source |
showRecord :: (PShow a, PShow a1) => [(a, a1)] -> Doc Source
underlined :: [Char] -> [Char] Source
removeEscs :: String -> String Source
correctEscs :: String -> String Source
throwError_ :: MonadError String m => String -> m a Source
data Doc :: *
The abstract data type Doc represents pretty documents.
Doc is an instance of the Show class. (show doc) pretty
prints document doc with a page width of 100 characters and a
ribbon width of 40 characters.
show (text "hello" <$> text "world")
Which would return the string "hello\nworld", i.e.
hello world
(<+>) :: Doc -> Doc -> Doc infixr 6
The document (x <+> y) concatenates document x and y with a
space in between. (infixr 6)
(</>) :: Doc -> Doc -> Doc infixr 5
The document (x </> y) concatenates document x and y with a
softline in between. This effectively puts x and y either
next to each other (with a space in between) or underneath each
other. (infixr 5)
(<$$>) :: Doc -> Doc -> Doc infixr 5
The document (x <$$> y) concatenates document x and y with
a linebreak in between. (infixr 5)
The document (vcat xs) concatenates all documents xs
vertically with (<$$>). If a group undoes the line breaks
inserted by vcat, all documents are directly concatenated.
punctuate :: Doc -> [Doc] -> [Doc]
(punctuate p xs) concatenates all documents in xs with
document p except for the last document.
someText = map text ["words","in","a","tuple"] test = parens (align (cat (punctuate comma someText)))
This is layed out on a page width of 20 as:
(words,in,a,tuple)
But when the page width is 15, it is layed out as:
(words, in, a, tuple)
(If you want put the commas in front of their elements instead of
at the end, you should use tupled or, in general, encloseSep.)
The document (tupled xs) comma separates the documents xs and
encloses them in parenthesis. The documents are rendered
horizontally if that fits the page. Otherwise they are aligned
vertically. All comma separators are put in front of the elements.
The document (text s) contains the literal string s. The
string shouldn't contain any newline ('\n') characters. If the
string contains newline characters, the function string should be
used.