2013-07-07 10:56:34 +00:00
|
|
|
|
|
|
|
module SourceSyntax.PrettyPrint where
|
|
|
|
|
|
|
|
import Text.PrettyPrint
|
|
|
|
import SourceSyntax.Location
|
|
|
|
|
|
|
|
class Pretty a where
|
|
|
|
pretty :: a -> Doc
|
|
|
|
|
|
|
|
instance Pretty a => Pretty (Located a) where
|
|
|
|
pretty (L _ _ e) = pretty e
|
|
|
|
|
2013-07-10 12:31:57 +00:00
|
|
|
instance Pretty () where
|
|
|
|
pretty () = empty
|
|
|
|
|
2013-07-07 10:56:34 +00:00
|
|
|
commaCat docs = cat (punctuate comma docs)
|
2013-07-19 15:45:16 +00:00
|
|
|
commaSep docs = sep (punctuate comma docs)
|
2013-07-07 10:56:34 +00:00
|
|
|
|
|
|
|
parensIf bool doc = if bool then parens doc else doc
|