module Text.PrettyPrint.Highlight (
HighlightStyle(..)
, HighlightDocument(..)
, comment
, keyword
, operator
, comment_
, keyword_
, operator_
, opParens
, module Text.PrettyPrint.Class
) where
import Text.PrettyPrint.Class
data HighlightStyle = Keyword | Comment | Operator
deriving( Eq, Ord, Show )
class Document d => HighlightDocument d where
highlight :: HighlightStyle -> d -> d
instance HighlightDocument Doc where
highlight _ = id
comment, keyword, operator :: HighlightDocument d => d -> d
comment = highlight Comment
keyword = highlight Keyword
operator = highlight Operator
comment_, keyword_, operator_ :: HighlightDocument d => String -> d
comment_ = comment . text
keyword_ = keyword . text
operator_ = operator . text
opParens :: HighlightDocument d => d -> d
opParens d = operator_ "(" <> d <> operator_ ")"