module Utils.Drasil.Document (blank, indent, indentList, contSep, filterEmpty,
listToDoc, Separator) where
import Text.PrettyPrint.HughesPJ
type Separator = Doc
contSep :: Separator
contSep :: Separator
contSep = String -> Separator
text String
"\n"
blank :: Doc
blank :: Separator
blank = String -> Separator
text String
""
indent :: Doc -> Doc
indent :: Separator -> Separator
indent = Int -> Separator -> Separator
nest Int
4
indentList :: [Doc] -> Doc
indentList :: [Separator] -> Separator
indentList = Separator -> Separator
indent (Separator -> Separator)
-> ([Separator] -> Separator) -> [Separator] -> Separator
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Separator] -> Separator
vcat
filterEmpty :: [Doc] -> [Doc]
filterEmpty :: [Separator] -> [Separator]
filterEmpty = (Separator -> Bool) -> [Separator] -> [Separator]
forall a. (a -> Bool) -> [a] -> [a]
filter (Bool -> Bool
not (Bool -> Bool) -> (Separator -> Bool) -> Separator -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Separator -> Bool
isEmpty)
listToDoc :: [String] -> Doc
listToDoc :: [String] -> Separator
listToDoc = [Separator] -> Separator
hsep ([Separator] -> Separator)
-> ([String] -> [Separator]) -> [String] -> Separator
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Separator -> [Separator] -> [Separator]
punctuate Separator
comma ([Separator] -> [Separator])
-> ([String] -> [Separator]) -> [String] -> [Separator]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (String -> Separator) -> [String] -> [Separator]
forall a b. (a -> b) -> [a] -> [b]
map String -> Separator
text