module Language.Bash.Pretty
( Pretty(..)
, prettyText
) where
import Text.PrettyPrint
class Pretty a where
pretty :: a -> Doc
prettyList :: [a] -> Doc
prettyList = hsep . map pretty
instance Pretty a => Pretty [a] where
pretty = prettyList
instance Pretty Doc where
pretty = id
instance Pretty Char where
pretty c = text [c]
prettyList = text
instance Pretty a => Pretty (Maybe a) where
pretty = maybe empty pretty
instance (Pretty a, Pretty b) => Pretty (Either a b) where
pretty = either pretty pretty
prettyText :: Pretty a => a -> String
prettyText = render . pretty