{-# LANGUAGE DeriveFunctor, FlexibleContexts, FlexibleInstances, OverloadedStrings, TypeSynonymInstances #-}
module Debian.Pretty
( PP(PP, unPP)
, prettyText
, ppPrint
, ppShow
, ppText
, prettyShow
) where
import Data.Text (Text, unpack, pack)
import Text.PrettyPrint.HughesPJClass (Doc, text, empty)
import Distribution.Pretty (Pretty(pretty), prettyShow)
newtype PP a = PP {forall a. PP a -> a
unPP :: a} deriving (forall a b. a -> PP b -> PP a
forall a b. (a -> b) -> PP a -> PP b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: forall a b. a -> PP b -> PP a
$c<$ :: forall a b. a -> PP b -> PP a
fmap :: forall a b. (a -> b) -> PP a -> PP b
$cfmap :: forall a b. (a -> b) -> PP a -> PP b
Functor)
instance Pretty (PP Text) where
pretty :: PP Text -> Doc
pretty = String -> Doc
text forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> String
unpack forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. PP a -> a
unPP
instance Pretty (PP String) where
pretty :: PP String -> Doc
pretty = String -> Doc
text forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. PP a -> a
unPP
instance Pretty (PP a) => Pretty (PP (Maybe a)) where
pretty :: PP (Maybe a) -> Doc
pretty = forall b a. b -> (a -> b) -> Maybe a -> b
maybe Doc
empty forall a. Pretty (PP a) => a -> Doc
ppPrint forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. PP a -> a
unPP
prettyText :: Pretty a => a -> Text
prettyText :: forall a. Pretty a => a -> Text
prettyText = String -> Text
pack forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Pretty a => a -> String
prettyShow
ppPrint :: Pretty (PP a) => a -> Doc
ppPrint :: forall a. Pretty (PP a) => a -> Doc
ppPrint = forall a. Pretty a => a -> Doc
pretty forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. a -> PP a
PP
ppShow :: Pretty (PP a) => a -> String
ppShow :: forall a. Pretty (PP a) => a -> String
ppShow = forall a. Pretty a => a -> String
prettyShow forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. a -> PP a
PP
ppText :: Pretty (PP a) => a -> Text
ppText :: forall a. Pretty (PP a) => a -> Text
ppText = String -> Text
pack forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Pretty a => a -> String
prettyShow forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. a -> PP a
PP