{-# LANGUAGE CPP, FlexibleInstances #-}
module Text.PrettyPrint.Leijen.Text.Monadic (
Doc,
empty, char, text, textStrict, beside, nest, line, linebreak, group, softline,
softbreak, spacebreak,
align, hang, indent, encloseSep, list, tupled, semiBraces,
(<+>), (<++>), (<$>), (</>), (<$$>), (<//>),
hsep, vsep, fillSep, sep, hcat, vcat, fillCat, cat, punctuate,
fill, fillBreak,
enclose, squotes, dquotes, parens, angles, braces, brackets,
lparen, rparen, langle, rangle, lbrace, rbrace, lbracket, rbracket,
squote, dquote, semi, colon, comma, space, dot, backslash, equals,
string, stringStrict, int, integer, float, double, rational, bool,
column, nesting, width,
Pretty(..), prettyM,
SimpleDoc(..), renderPretty, renderCompact, renderOneLine,
displayB, displayT, displayTStrict, displayIO, putDoc, hPutDoc
) where
import Prelude ()
import Prelude.Compat hiding ((<$>))
import Text.PrettyPrint.Leijen.Text (Doc, Pretty(..), SimpleDoc(..),
displayB, displayIO, displayT,
displayTStrict, hPutDoc, putDoc,
renderCompact, renderOneLine,
renderPretty)
import qualified Text.PrettyPrint.Leijen.Text as PP
import Control.Applicative (liftA2, liftA3)
import qualified Data.Text as TS
import Data.Text.Lazy (Text)
infixr 5 </>,<//>,<$>,<$$>
infixr 6 <+>,<++>,`beside`
list :: (Functor m) => m [Doc] -> m Doc
list :: m [Doc] -> m Doc
list = ([Doc] -> Doc) -> m [Doc] -> m Doc
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [Doc] -> Doc
PP.list
tupled :: (Functor m) => m [Doc] -> m Doc
tupled :: m [Doc] -> m Doc
tupled = ([Doc] -> Doc) -> m [Doc] -> m Doc
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [Doc] -> Doc
PP.tupled
semiBraces :: (Functor m) => m [Doc] -> m Doc
semiBraces :: m [Doc] -> m Doc
semiBraces = ([Doc] -> Doc) -> m [Doc] -> m Doc
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [Doc] -> Doc
PP.semiBraces
encloseSep :: (Applicative m) => m Doc -> m Doc -> m Doc -> m [Doc] -> m Doc
encloseSep :: m Doc -> m Doc -> m Doc -> m [Doc] -> m Doc
encloseSep m Doc
a m Doc
b m Doc
c m [Doc]
d = (Doc -> Doc -> Doc -> [Doc] -> Doc)
-> m Doc -> m Doc -> m Doc -> m ([Doc] -> Doc)
forall (f :: * -> *) a b c d.
Applicative f =>
(a -> b -> c -> d) -> f a -> f b -> f c -> f d
liftA3 Doc -> Doc -> Doc -> [Doc] -> Doc
PP.encloseSep m Doc
a m Doc
b m Doc
c m ([Doc] -> Doc) -> m [Doc] -> m Doc
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> m [Doc]
d
punctuate :: (Applicative m) => m Doc -> m [Doc] -> m [Doc]
punctuate :: m Doc -> m [Doc] -> m [Doc]
punctuate = (Doc -> [Doc] -> [Doc]) -> m Doc -> m [Doc] -> m [Doc]
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 Doc -> [Doc] -> [Doc]
PP.punctuate
sep :: (Functor m) => m [Doc] -> m Doc
sep :: m [Doc] -> m Doc
sep = ([Doc] -> Doc) -> m [Doc] -> m Doc
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [Doc] -> Doc
PP.sep
fillSep :: (Functor m) => m [Doc] -> m Doc
fillSep :: m [Doc] -> m Doc
fillSep = ([Doc] -> Doc) -> m [Doc] -> m Doc
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [Doc] -> Doc
PP.fillSep
hsep :: (Functor m) => m [Doc] -> m Doc
hsep :: m [Doc] -> m Doc
hsep = ([Doc] -> Doc) -> m [Doc] -> m Doc
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [Doc] -> Doc
PP.hsep
vsep :: (Functor m) => m [Doc] -> m Doc
vsep :: m [Doc] -> m Doc
vsep = ([Doc] -> Doc) -> m [Doc] -> m Doc
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [Doc] -> Doc
PP.vsep
cat :: (Functor m) => m [Doc] -> m Doc
cat :: m [Doc] -> m Doc
cat = ([Doc] -> Doc) -> m [Doc] -> m Doc
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [Doc] -> Doc
PP.cat
fillCat :: (Functor m) => m [Doc] -> m Doc
fillCat :: m [Doc] -> m Doc
fillCat = ([Doc] -> Doc) -> m [Doc] -> m Doc
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [Doc] -> Doc
PP.fillCat
hcat :: (Functor m) => m [Doc] -> m Doc
hcat :: m [Doc] -> m Doc
hcat = ([Doc] -> Doc) -> m [Doc] -> m Doc
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [Doc] -> Doc
PP.hcat
vcat :: (Functor m) => m [Doc] -> m Doc
vcat :: m [Doc] -> m Doc
vcat = ([Doc] -> Doc) -> m [Doc] -> m Doc
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [Doc] -> Doc
PP.vcat
beside :: (Applicative m) => m Doc -> m Doc -> m Doc
beside :: m Doc -> m Doc -> m Doc
beside = (Doc -> Doc -> Doc) -> m Doc -> m Doc -> m Doc
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 (Doc -> Doc -> Doc
PP.beside)
(<+>) :: (Applicative m) => m Doc -> m Doc -> m Doc
<+> :: m Doc -> m Doc -> m Doc
(<+>) = (Doc -> Doc -> Doc) -> m Doc -> m Doc -> m Doc
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 Doc -> Doc -> Doc
(PP.<+>)
(<++>) :: (Applicative m) => m Doc -> m Doc -> m Doc
<++> :: m Doc -> m Doc -> m Doc
(<++>) = (Doc -> Doc -> Doc) -> m Doc -> m Doc -> m Doc
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 Doc -> Doc -> Doc
(PP.<++>)
(</>) :: (Applicative m) => m Doc -> m Doc -> m Doc
</> :: m Doc -> m Doc -> m Doc
(</>) = (Doc -> Doc -> Doc) -> m Doc -> m Doc -> m Doc
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 Doc -> Doc -> Doc
(PP.</>)
(<//>) :: (Applicative m) => m Doc -> m Doc -> m Doc
<//> :: m Doc -> m Doc -> m Doc
(<//>) = (Doc -> Doc -> Doc) -> m Doc -> m Doc -> m Doc
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 Doc -> Doc -> Doc
(PP.<//>)
(<$>) :: (Applicative m) => m Doc -> m Doc -> m Doc
<$> :: m Doc -> m Doc -> m Doc
(<$>) = (Doc -> Doc -> Doc) -> m Doc -> m Doc -> m Doc
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 Doc -> Doc -> Doc
(PP.<$>)
(<$$>) :: (Applicative m) => m Doc -> m Doc -> m Doc
<$$> :: m Doc -> m Doc -> m Doc
(<$$>) = (Doc -> Doc -> Doc) -> m Doc -> m Doc -> m Doc
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 Doc -> Doc -> Doc
(PP.<$$>)
softline :: (Applicative m) => m Doc
softline :: m Doc
softline = Doc -> m Doc
forall (f :: * -> *) a. Applicative f => a -> f a
pure Doc
PP.softline
softbreak :: (Applicative m) => m Doc
softbreak :: m Doc
softbreak = Doc -> m Doc
forall (f :: * -> *) a. Applicative f => a -> f a
pure Doc
PP.softbreak
spacebreak :: (Applicative m) => m Doc
spacebreak :: m Doc
spacebreak = Doc -> m Doc
forall (f :: * -> *) a. Applicative f => a -> f a
pure Doc
PP.spacebreak
squotes :: (Functor m) => m Doc -> m Doc
squotes :: m Doc -> m Doc
squotes = (Doc -> Doc) -> m Doc -> m Doc
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Doc -> Doc
PP.squotes
dquotes :: (Functor m) => m Doc -> m Doc
dquotes :: m Doc -> m Doc
dquotes = (Doc -> Doc) -> m Doc -> m Doc
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Doc -> Doc
PP.dquotes
braces :: (Functor m) => m Doc -> m Doc
braces :: m Doc -> m Doc
braces = (Doc -> Doc) -> m Doc -> m Doc
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Doc -> Doc
PP.braces
parens :: (Functor m) => m Doc -> m Doc
parens :: m Doc -> m Doc
parens = (Doc -> Doc) -> m Doc -> m Doc
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Doc -> Doc
PP.parens
angles :: (Functor m) => m Doc -> m Doc
angles :: m Doc -> m Doc
angles = (Doc -> Doc) -> m Doc -> m Doc
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Doc -> Doc
PP.angles
brackets :: (Functor m) => m Doc -> m Doc
brackets :: m Doc -> m Doc
brackets = (Doc -> Doc) -> m Doc -> m Doc
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Doc -> Doc
PP.brackets
enclose :: (Applicative m) => m Doc -> m Doc -> m Doc -> m Doc
enclose :: m Doc -> m Doc -> m Doc -> m Doc
enclose = (Doc -> Doc -> Doc -> Doc) -> m Doc -> m Doc -> m Doc -> m Doc
forall (f :: * -> *) a b c d.
Applicative f =>
(a -> b -> c -> d) -> f a -> f b -> f c -> f d
liftA3 Doc -> Doc -> Doc -> Doc
PP.enclose
lparen :: (Applicative m) => m Doc
lparen :: m Doc
lparen = Doc -> m Doc
forall (f :: * -> *) a. Applicative f => a -> f a
pure Doc
PP.lparen
rparen :: (Applicative m) => m Doc
rparen :: m Doc
rparen = Doc -> m Doc
forall (f :: * -> *) a. Applicative f => a -> f a
pure Doc
PP.rparen
langle :: (Applicative m) => m Doc
langle :: m Doc
langle = Doc -> m Doc
forall (f :: * -> *) a. Applicative f => a -> f a
pure Doc
PP.langle
rangle :: (Applicative m) => m Doc
rangle :: m Doc
rangle = Doc -> m Doc
forall (f :: * -> *) a. Applicative f => a -> f a
pure Doc
PP.rangle
lbrace :: (Applicative m) => m Doc
lbrace :: m Doc
lbrace = Doc -> m Doc
forall (f :: * -> *) a. Applicative f => a -> f a
pure Doc
PP.lbrace
rbrace :: (Applicative m) => m Doc
rbrace :: m Doc
rbrace = Doc -> m Doc
forall (f :: * -> *) a. Applicative f => a -> f a
pure Doc
PP.rbrace
lbracket :: (Applicative m) => m Doc
lbracket :: m Doc
lbracket = Doc -> m Doc
forall (f :: * -> *) a. Applicative f => a -> f a
pure Doc
PP.lbracket
rbracket :: (Applicative m) => m Doc
rbracket :: m Doc
rbracket = Doc -> m Doc
forall (f :: * -> *) a. Applicative f => a -> f a
pure Doc
PP.rbracket
squote :: (Applicative m) => m Doc
squote :: m Doc
squote = Doc -> m Doc
forall (f :: * -> *) a. Applicative f => a -> f a
pure Doc
PP.squote
dquote :: (Applicative m) => m Doc
dquote :: m Doc
dquote = Doc -> m Doc
forall (f :: * -> *) a. Applicative f => a -> f a
pure Doc
PP.dquote
semi :: (Applicative m) => m Doc
semi :: m Doc
semi = Doc -> m Doc
forall (f :: * -> *) a. Applicative f => a -> f a
pure Doc
PP.semi
colon :: (Applicative m) => m Doc
colon :: m Doc
colon = Doc -> m Doc
forall (f :: * -> *) a. Applicative f => a -> f a
pure Doc
PP.colon
comma :: (Applicative m) => m Doc
comma :: m Doc
comma = Doc -> m Doc
forall (f :: * -> *) a. Applicative f => a -> f a
pure Doc
PP.comma
space :: (Applicative m) => m Doc
space :: m Doc
space = Doc -> m Doc
forall (f :: * -> *) a. Applicative f => a -> f a
pure Doc
PP.space
dot :: (Applicative m) => m Doc
dot :: m Doc
dot = Doc -> m Doc
forall (f :: * -> *) a. Applicative f => a -> f a
pure Doc
PP.dot
backslash :: (Applicative m) => m Doc
backslash :: m Doc
backslash = Doc -> m Doc
forall (f :: * -> *) a. Applicative f => a -> f a
pure Doc
PP.backslash
equals :: (Applicative m) => m Doc
equals :: m Doc
equals = Doc -> m Doc
forall (f :: * -> *) a. Applicative f => a -> f a
pure Doc
PP.equals
string :: (Applicative m) => Text -> m Doc
string :: Text -> m Doc
string = Doc -> m Doc
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Doc -> m Doc) -> (Text -> Doc) -> Text -> m Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Doc
PP.string
stringStrict :: Monad m => TS.Text -> m Doc
stringStrict :: Text -> m Doc
stringStrict = Doc -> m Doc
forall (m :: * -> *) a. Monad m => a -> m a
return (Doc -> m Doc) -> (Text -> Doc) -> Text -> m Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Doc
PP.stringStrict
bool :: (Applicative m) => Bool -> m Doc
bool :: Bool -> m Doc
bool = Doc -> m Doc
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Doc -> m Doc) -> (Bool -> Doc) -> Bool -> m Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> Doc
PP.bool
int :: (Applicative m) => Int -> m Doc
int :: Int -> m Doc
int = Doc -> m Doc
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Doc -> m Doc) -> (Int -> Doc) -> Int -> m Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Doc
PP.int
integer :: (Applicative m) => Integer -> m Doc
integer :: Integer -> m Doc
integer = Doc -> m Doc
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Doc -> m Doc) -> (Integer -> Doc) -> Integer -> m Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> Doc
PP.integer
float :: (Applicative m) => Float -> m Doc
float :: Float -> m Doc
float = Doc -> m Doc
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Doc -> m Doc) -> (Float -> Doc) -> Float -> m Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Float -> Doc
PP.float
double :: (Applicative m) => Double -> m Doc
double :: Double -> m Doc
double = Doc -> m Doc
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Doc -> m Doc) -> (Double -> Doc) -> Double -> m Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Double -> Doc
PP.double
rational :: (Applicative m) => Rational -> m Doc
rational :: Rational -> m Doc
rational = Doc -> m Doc
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Doc -> m Doc) -> (Rational -> Doc) -> Rational -> m Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Rational -> Doc
PP.rational
prettyM :: (Pretty a, Applicative m) => a -> m Doc
prettyM :: a -> m Doc
prettyM = Doc -> m Doc
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Doc -> m Doc) -> (a -> Doc) -> a -> m Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Doc
forall a. Pretty a => a -> Doc
pretty
fill :: (Functor m) => Int -> m Doc -> m Doc
fill :: Int -> m Doc -> m Doc
fill = (Doc -> Doc) -> m Doc -> m Doc
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((Doc -> Doc) -> m Doc -> m Doc)
-> (Int -> Doc -> Doc) -> Int -> m Doc -> m Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Doc -> Doc
PP.fill
width :: (Applicative m) => m Doc -> m (Int -> Doc) -> m Doc
width :: m Doc -> m (Int -> Doc) -> m Doc
width = (Doc -> (Int -> Doc) -> Doc) -> m Doc -> m (Int -> Doc) -> m Doc
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 Doc -> (Int -> Doc) -> Doc
PP.width
fillBreak :: (Functor m) => Int -> m Doc -> m Doc
fillBreak :: Int -> m Doc -> m Doc
fillBreak = (Doc -> Doc) -> m Doc -> m Doc
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((Doc -> Doc) -> m Doc -> m Doc)
-> (Int -> Doc -> Doc) -> Int -> m Doc -> m Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Doc -> Doc
PP.fillBreak
indent :: (Functor m) => Int -> m Doc -> m Doc
indent :: Int -> m Doc -> m Doc
indent = (Doc -> Doc) -> m Doc -> m Doc
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((Doc -> Doc) -> m Doc -> m Doc)
-> (Int -> Doc -> Doc) -> Int -> m Doc -> m Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Doc -> Doc
PP.indent
hang :: (Functor m) => Int -> m Doc -> m Doc
hang :: Int -> m Doc -> m Doc
hang = (Doc -> Doc) -> m Doc -> m Doc
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((Doc -> Doc) -> m Doc -> m Doc)
-> (Int -> Doc -> Doc) -> Int -> m Doc -> m Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Doc -> Doc
PP.hang
align :: (Functor m) => m Doc -> m Doc
align :: m Doc -> m Doc
align = (Doc -> Doc) -> m Doc -> m Doc
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Doc -> Doc
PP.align
empty :: (Applicative m) => m Doc
empty :: m Doc
empty = Doc -> m Doc
forall (f :: * -> *) a. Applicative f => a -> f a
pure Doc
PP.empty
char :: (Applicative m) => Char -> m Doc
char :: Char -> m Doc
char = Doc -> m Doc
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Doc -> m Doc) -> (Char -> Doc) -> Char -> m Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Doc
PP.char
text :: (Applicative m) => Text -> m Doc
text :: Text -> m Doc
text = Doc -> m Doc
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Doc -> m Doc) -> (Text -> Doc) -> Text -> m Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Doc
PP.text
textStrict :: Monad m => TS.Text -> m Doc
textStrict :: Text -> m Doc
textStrict = Doc -> m Doc
forall (m :: * -> *) a. Monad m => a -> m a
return (Doc -> m Doc) -> (Text -> Doc) -> Text -> m Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Doc
PP.textStrict
line :: (Applicative m) => m Doc
line :: m Doc
line = Doc -> m Doc
forall (f :: * -> *) a. Applicative f => a -> f a
pure Doc
PP.line
linebreak :: (Applicative m) => m Doc
linebreak :: m Doc
linebreak = Doc -> m Doc
forall (f :: * -> *) a. Applicative f => a -> f a
pure Doc
PP.linebreak
nest :: (Functor m) => Int -> m Doc -> m Doc
nest :: Int -> m Doc -> m Doc
nest = (Doc -> Doc) -> m Doc -> m Doc
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((Doc -> Doc) -> m Doc -> m Doc)
-> (Int -> Doc -> Doc) -> Int -> m Doc -> m Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Doc -> Doc
PP.nest
column :: (Functor m) => m (Int -> Doc) -> m Doc
column :: m (Int -> Doc) -> m Doc
column = ((Int -> Doc) -> Doc) -> m (Int -> Doc) -> m Doc
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Int -> Doc) -> Doc
PP.column
nesting :: (Functor m) => m (Int -> Doc) -> m Doc
nesting :: m (Int -> Doc) -> m Doc
nesting = ((Int -> Doc) -> Doc) -> m (Int -> Doc) -> m Doc
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Int -> Doc) -> Doc
PP.nesting
group :: (Functor m) => m Doc -> m Doc
group :: m Doc -> m Doc
group = (Doc -> Doc) -> m Doc -> m Doc
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Doc -> Doc
PP.group