{-# LANGUAGE CPP #-}

-- |
-- Module      :  Text.PrettyPrint.Mainland
-- Copyright   :  (c) 2006-2011 Harvard University
--                (c) 2011-2012 Geoffrey Mainland
--                (c) 2015-2017 Drexel University
-- License     :  BSD-style
-- Maintainer  :  mainland@drexel.edu
--
-- Stability   :  provisional
-- Portability :  portable
--
-- This module is based on /A Prettier Printer/ by Phil Wadler in
-- /The Fun of Programming/, Jeremy Gibbons and Oege de Moor (eds)
-- <http://homepages.inf.ed.ac.uk/wadler/papers/prettier/prettier.pdf>
--
-- At the time it was originally written I didn't know about Daan Leijen's
-- pretty printing module based on the same paper. I have since incorporated
-- many of his improvements. This module is geared towards pretty printing
-- source code; its main advantages over other libraries are the ability to
-- automatically track the source locations associated with pretty printed
-- values and output appropriate #line pragmas and the use of
-- 'Data.Text.Lazy.Text' for output.

module Text.PrettyPrint.Mainland.Class (
    -- * The 'Pretty' type class for pretty printing
    Pretty(..),

    pprint
  ) where

import Control.Monad.IO.Class (MonadIO, liftIO)
import Data.Complex (Complex, realPart, imagPart)
import Data.Int
import Data.Loc (L(..),
                 Loc(..),
                 Pos(..),
                 posFile)
import qualified Data.Map as Map
#if !(MIN_VERSION_base(4,9,0))
import Data.Monoid (Monoid(..), (<>))
#endif /* !(MIN_VERSION_base(4,9,0)) */
#if MIN_VERSION_base(4,9,0) && !(MIN_VERSION_base(4,11,0))
import Data.Semigroup (Semigroup(..))
#endif
import qualified Data.Set as Set
import qualified Data.Text as T
import qualified Data.Text.Lazy as L
import Data.Word
import Data.Ratio (Ratio(..), denominator, numerator)

import Text.PrettyPrint.Mainland

-- | The 'pprint' function outputs a value of any type that is an instance of
-- 'Pretty' to the standard output device by calling 'ppr' and adding a newline.
pprint :: (Pretty a, MonadIO m) => a -> m ()
pprint :: forall a (m :: * -> *). (Pretty a, MonadIO m) => a -> m ()
pprint = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> (a -> IO ()) -> a -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Doc -> IO ()
putDocLn (Doc -> IO ()) -> (a -> Doc) -> a -> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Doc
forall a. Pretty a => a -> Doc
ppr

class Pretty a where
#if __GLASGOW_HASKELL__ >= 708
    {-# MINIMAL pprPrec | ppr #-}
#endif
    ppr     :: a -> Doc
    pprPrec :: Int -> a -> Doc
    pprList :: [a] -> Doc

    ppr        = Int -> a -> Doc
forall a. Pretty a => Int -> a -> Doc
pprPrec Int
0
    pprPrec Int
_  = a -> Doc
forall a. Pretty a => a -> Doc
ppr
    pprList [a]
xs = [Doc] -> Doc
list ((a -> Doc) -> [a] -> [Doc]
forall a b. (a -> b) -> [a] -> [b]
map a -> Doc
forall a. Pretty a => a -> Doc
ppr [a]
xs)

instance Pretty a => Pretty [a] where
    ppr :: [a] -> Doc
ppr = [a] -> Doc
forall a. Pretty a => [a] -> Doc
pprList

instance Pretty a => Pretty (Maybe a) where
    pprPrec :: Int -> Maybe a -> Doc
pprPrec Int
_ Maybe a
Nothing  = Doc
empty
    pprPrec Int
p (Just a
a) = Int -> a -> Doc
forall a. Pretty a => Int -> a -> Doc
pprPrec Int
p a
a

instance Pretty Bool where
    ppr :: Bool -> Doc
ppr = Bool -> Doc
bool

instance Pretty Char where
    ppr :: Char -> Doc
ppr     = Char -> Doc
char
    pprList :: [Char] -> Doc
pprList = [Char] -> Doc
string

instance Pretty Int where
    pprPrec :: Int -> Int -> Doc
pprPrec Int
p Int
x = [Char] -> Doc
text (Int -> Int -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec Int
p Int
x [Char]
"")

instance Pretty Integer where
    pprPrec :: Int -> Integer -> Doc
pprPrec Int
p Integer
x = [Char] -> Doc
text (Int -> Integer -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec Int
p Integer
x [Char]
"")

instance Pretty Float where
    pprPrec :: Int -> Float -> Doc
pprPrec Int
p Float
x = [Char] -> Doc
text (Int -> Float -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec Int
p Float
x [Char]
"")

instance Pretty Double where
    pprPrec :: Int -> Double -> Doc
pprPrec Int
p Double
x = [Char] -> Doc
text (Int -> Double -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec Int
p Double
x [Char]
"")

ratioPrec, ratioPrec1 :: Int
ratioPrec :: Int
ratioPrec  = Int
7  -- Precedence of ':%' constructor
ratioPrec1 :: Int
ratioPrec1 = Int
ratioPrec Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
1

instance (Integral a, Pretty a) => Pretty (Ratio a)  where
    pprPrec :: Int -> Ratio a -> Doc
pprPrec Int
p Ratio a
x =
        Bool -> Doc -> Doc
parensIf (Int
p Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
ratioPrec) (Doc -> Doc) -> Doc -> Doc
forall a b. (a -> b) -> a -> b
$
        Int -> a -> Doc
forall a. Pretty a => Int -> a -> Doc
pprPrec Int
ratioPrec1 (Ratio a -> a
forall a. Ratio a -> a
numerator Ratio a
x) Doc -> Doc -> Doc
<+> Char -> Doc
char Char
'%' Doc -> Doc -> Doc
<+> Int -> a -> Doc
forall a. Pretty a => Int -> a -> Doc
pprPrec Int
ratioPrec1 (Ratio a -> a
forall a. Ratio a -> a
denominator Ratio a
x)

addPrec :: Int
addPrec :: Int
addPrec  = Int
6  -- Precedence of '+'

instance (RealFloat a, Pretty a) => Pretty (Complex a)  where
    pprPrec :: Int -> Complex a -> Doc
pprPrec Int
p Complex a
x =
        Bool -> Doc -> Doc
parensIf (Int
p Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
addPrec) (Doc -> Doc) -> Doc -> Doc
forall a b. (a -> b) -> a -> b
$
        Int -> a -> Doc
forall a. Pretty a => Int -> a -> Doc
pprPrec Int
addPrec (Complex a -> a
forall a. Complex a -> a
realPart Complex a
x) Doc -> Doc -> Doc
<+> [Char] -> Doc
text [Char]
":+" Doc -> Doc -> Doc
<+> Int -> a -> Doc
forall a. Pretty a => Int -> a -> Doc
pprPrec Int
addPrec (Complex a -> a
forall a. Complex a -> a
imagPart Complex a
x)

instance Pretty Word8 where
    pprPrec :: Int -> Word8 -> Doc
pprPrec Int
p Word8
x = [Char] -> Doc
text (Int -> Word8 -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec Int
p Word8
x [Char]
"")

instance Pretty Word16 where
    pprPrec :: Int -> Word16 -> Doc
pprPrec Int
p Word16
x = [Char] -> Doc
text (Int -> Word16 -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec Int
p Word16
x [Char]
"")

instance Pretty Word32 where
    pprPrec :: Int -> Word32 -> Doc
pprPrec Int
p Word32
x = [Char] -> Doc
text (Int -> Word32 -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec Int
p Word32
x [Char]
"")

instance Pretty Word64 where
    pprPrec :: Int -> Word64 -> Doc
pprPrec Int
p Word64
x = [Char] -> Doc
text (Int -> Word64 -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec Int
p Word64
x [Char]
"")

instance Pretty Int8 where
    pprPrec :: Int -> Int8 -> Doc
pprPrec Int
p Int8
x = [Char] -> Doc
text (Int -> Int8 -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec Int
p Int8
x [Char]
"")

instance Pretty Int16 where
    pprPrec :: Int -> Int16 -> Doc
pprPrec Int
p Int16
x = [Char] -> Doc
text (Int -> Int16 -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec Int
p Int16
x [Char]
"")

instance Pretty Int32 where
    pprPrec :: Int -> Int32 -> Doc
pprPrec Int
p Int32
x = [Char] -> Doc
text (Int -> Int32 -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec Int
p Int32
x [Char]
"")

instance Pretty Int64 where
    pprPrec :: Int -> Int64 -> Doc
pprPrec Int
p Int64
x = [Char] -> Doc
text (Int -> Int64 -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec Int
p Int64
x [Char]
"")

instance Pretty T.Text where
    ppr :: Text -> Doc
ppr = Text -> Doc
strictText

instance Pretty L.Text where
    ppr :: Text -> Doc
ppr = Text -> Doc
lazyText

instance Pretty Doc where
    ppr :: Doc -> Doc
ppr Doc
doc = Doc
doc

instance Pretty Pos where
    ppr :: Pos -> Doc
ppr p :: Pos
p@(Pos [Char]
_ Int
l Int
c Int
_) =
        [Char] -> Doc
text (Pos -> [Char]
posFile Pos
p) Doc -> Doc -> Doc
forall a. Semigroup a => a -> a -> a
<> Doc
colon Doc -> Doc -> Doc
forall a. Semigroup a => a -> a -> a
<> Int -> Doc
forall a. Pretty a => a -> Doc
ppr Int
l Doc -> Doc -> Doc
forall a. Semigroup a => a -> a -> a
<> Doc
colon Doc -> Doc -> Doc
forall a. Semigroup a => a -> a -> a
<> Int -> Doc
forall a. Pretty a => a -> Doc
ppr Int
c

instance Pretty Loc where
    ppr :: Loc -> Doc
ppr Loc
NoLoc = [Char] -> Doc
text [Char]
"<no location info>"

    ppr (Loc p1 :: Pos
p1@(Pos [Char]
f1 Int
l1 Int
c1 Int
_) p2 :: Pos
p2@(Pos [Char]
f2 Int
l2 Int
c2 Int
_))
        | [Char]
f1 [Char] -> [Char] -> Bool
forall a. Eq a => a -> a -> Bool
== [Char]
f2   = [Char] -> Doc
text (Pos -> [Char]
posFile Pos
p1) Doc -> Doc -> Doc
forall a. Semigroup a => a -> a -> a
<> Doc
colon Doc -> Doc -> Doc
<//> Int -> Int -> Int -> Int -> Doc
pprLineCol Int
l1 Int
c1 Int
l2 Int
c2
        | Bool
otherwise  = Pos -> Doc
forall a. Pretty a => a -> Doc
ppr Pos
p1 Doc -> Doc -> Doc
forall a. Semigroup a => a -> a -> a
<> [Char] -> Doc
text [Char]
"-" Doc -> Doc -> Doc
forall a. Semigroup a => a -> a -> a
<> Pos -> Doc
forall a. Pretty a => a -> Doc
ppr Pos
p2
      where
        pprLineCol :: Int -> Int -> Int -> Int -> Doc
        pprLineCol :: Int -> Int -> Int -> Int -> Doc
pprLineCol Int
l1 Int
c1 Int
l2 Int
c2
            | Int
l1 Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
l2 Bool -> Bool -> Bool
&& Int
c1 Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
c2  =  Int -> Doc
forall a. Pretty a => a -> Doc
ppr Int
l1 Doc -> Doc -> Doc
<//> Doc
colon Doc -> Doc -> Doc
<//> Int -> Doc
forall a. Pretty a => a -> Doc
ppr Int
c1
            | Int
l1 Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
l2 Bool -> Bool -> Bool
&& Int
c1 Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
/= Int
c2  =  Int -> Doc
forall a. Pretty a => a -> Doc
ppr Int
l1 Doc -> Doc -> Doc
<//> Doc
colon Doc -> Doc -> Doc
<//>
                                       Int -> Doc
forall a. Pretty a => a -> Doc
ppr Int
c1 Doc -> Doc -> Doc
forall a. Semigroup a => a -> a -> a
<> [Char] -> Doc
text [Char]
"-" Doc -> Doc -> Doc
forall a. Semigroup a => a -> a -> a
<> Int -> Doc
forall a. Pretty a => a -> Doc
ppr Int
c2
            | Bool
otherwise             =  Int -> Doc
forall a. Pretty a => a -> Doc
ppr Int
l1 Doc -> Doc -> Doc
<//> Doc
colon Doc -> Doc -> Doc
<//> Int -> Doc
forall a. Pretty a => a -> Doc
ppr Int
c1
                                       Doc -> Doc -> Doc
forall a. Semigroup a => a -> a -> a
<> [Char] -> Doc
text [Char]
"-" Doc -> Doc -> Doc
forall a. Semigroup a => a -> a -> a
<>
                                       Int -> Doc
forall a. Pretty a => a -> Doc
ppr Int
l2 Doc -> Doc -> Doc
<//> Doc
colon Doc -> Doc -> Doc
<//> Int -> Doc
forall a. Pretty a => a -> Doc
ppr Int
c2

instance Pretty x => Pretty (L x) where
    pprPrec :: Int -> L x -> Doc
pprPrec Int
p (L Loc
_ x
x) = Int -> x -> Doc
forall a. Pretty a => Int -> a -> Doc
pprPrec Int
p x
x

instance (Pretty k, Pretty v) => Pretty (Map.Map k v) where
    ppr :: Map k v -> Doc
ppr = [(k, v)] -> Doc
forall a. Pretty a => [a] -> Doc
pprList ([(k, v)] -> Doc) -> (Map k v -> [(k, v)]) -> Map k v -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Map k v -> [(k, v)]
forall k a. Map k a -> [(k, a)]
Map.toList

instance Pretty a => Pretty (Set.Set a) where
    ppr :: Set a -> Doc
ppr = [a] -> Doc
forall a. Pretty a => [a] -> Doc
pprList ([a] -> Doc) -> (Set a -> [a]) -> Set a -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Set a -> [a]
forall a. Set a -> [a]
Set.toList

instance Pretty () where
    ppr :: () -> Doc
ppr () =
        [Doc] -> Doc
tuple []

instance (Pretty a, Pretty b)
  => Pretty (a, b) where
    ppr :: (a, b) -> Doc
ppr (a
a, b
b) =
        [Doc] -> Doc
tuple [a -> Doc
forall a. Pretty a => a -> Doc
ppr a
a, b -> Doc
forall a. Pretty a => a -> Doc
ppr b
b]

instance (Pretty a, Pretty b, Pretty c)
  => Pretty (a, b, c) where
    ppr :: (a, b, c) -> Doc
ppr (a
a, b
b, c
c) =
        [Doc] -> Doc
tuple [a -> Doc
forall a. Pretty a => a -> Doc
ppr a
a, b -> Doc
forall a. Pretty a => a -> Doc
ppr b
b, c -> Doc
forall a. Pretty a => a -> Doc
ppr c
c]

instance (Pretty a, Pretty b, Pretty c, Pretty d)
  => Pretty (a, b, c, d) where
    ppr :: (a, b, c, d) -> Doc
ppr (a
a, b
b, c
c, d
d) =
        [Doc] -> Doc
tuple [a -> Doc
forall a. Pretty a => a -> Doc
ppr a
a, b -> Doc
forall a. Pretty a => a -> Doc
ppr b
b, c -> Doc
forall a. Pretty a => a -> Doc
ppr c
c, d -> Doc
forall a. Pretty a => a -> Doc
ppr d
d]

instance (Pretty a, Pretty b, Pretty c, Pretty d, Pretty e)
  => Pretty (a, b, c, d, e) where
    ppr :: (a, b, c, d, e) -> Doc
ppr (a
a, b
b, c
c, d
d, e
e) =
        [Doc] -> Doc
tuple [a -> Doc
forall a. Pretty a => a -> Doc
ppr a
a, b -> Doc
forall a. Pretty a => a -> Doc
ppr b
b, c -> Doc
forall a. Pretty a => a -> Doc
ppr c
c, d -> Doc
forall a. Pretty a => a -> Doc
ppr d
d, e -> Doc
forall a. Pretty a => a -> Doc
ppr e
e]

instance (Pretty a, Pretty b, Pretty c, Pretty d, Pretty e,
          Pretty f)
  => Pretty (a, b, c, d, e, f) where
    ppr :: (a, b, c, d, e, f) -> Doc
ppr (a
a, b
b, c
c, d
d, e
e, f
f) =
        [Doc] -> Doc
tuple [a -> Doc
forall a. Pretty a => a -> Doc
ppr a
a, b -> Doc
forall a. Pretty a => a -> Doc
ppr b
b, c -> Doc
forall a. Pretty a => a -> Doc
ppr c
c, d -> Doc
forall a. Pretty a => a -> Doc
ppr d
d, e -> Doc
forall a. Pretty a => a -> Doc
ppr e
e,
               f -> Doc
forall a. Pretty a => a -> Doc
ppr f
f]

instance (Pretty a, Pretty b, Pretty c, Pretty d, Pretty e,
          Pretty f, Pretty g)
  => Pretty (a, b, c, d, e, f, g) where
    ppr :: (a, b, c, d, e, f, g) -> Doc
ppr (a
a, b
b, c
c, d
d, e
e, f
f, g
g) =
        [Doc] -> Doc
tuple [a -> Doc
forall a. Pretty a => a -> Doc
ppr a
a, b -> Doc
forall a. Pretty a => a -> Doc
ppr b
b, c -> Doc
forall a. Pretty a => a -> Doc
ppr c
c, d -> Doc
forall a. Pretty a => a -> Doc
ppr d
d, e -> Doc
forall a. Pretty a => a -> Doc
ppr e
e,
               f -> Doc
forall a. Pretty a => a -> Doc
ppr f
f, g -> Doc
forall a. Pretty a => a -> Doc
ppr g
g]

instance (Pretty a, Pretty b, Pretty c, Pretty d, Pretty e,
          Pretty f, Pretty g, Pretty h)
  => Pretty (a, b, c, d, e, f, g, h) where
    ppr :: (a, b, c, d, e, f, g, h) -> Doc
ppr (a
a, b
b, c
c, d
d, e
e, f
f, g
g, h
h) =
        [Doc] -> Doc
tuple [a -> Doc
forall a. Pretty a => a -> Doc
ppr a
a, b -> Doc
forall a. Pretty a => a -> Doc
ppr b
b, c -> Doc
forall a. Pretty a => a -> Doc
ppr c
c, d -> Doc
forall a. Pretty a => a -> Doc
ppr d
d, e -> Doc
forall a. Pretty a => a -> Doc
ppr e
e,
               f -> Doc
forall a. Pretty a => a -> Doc
ppr f
f, g -> Doc
forall a. Pretty a => a -> Doc
ppr g
g, h -> Doc
forall a. Pretty a => a -> Doc
ppr h
h]

instance (Pretty a, Pretty b, Pretty c, Pretty d, Pretty e,
          Pretty f, Pretty g, Pretty h, Pretty i)
  => Pretty (a, b, c, d, e, f, g, h, i) where
    ppr :: (a, b, c, d, e, f, g, h, i) -> Doc
ppr (a
a, b
b, c
c, d
d, e
e, f
f, g
g, h
h, i
i) =
        [Doc] -> Doc
tuple [a -> Doc
forall a. Pretty a => a -> Doc
ppr a
a, b -> Doc
forall a. Pretty a => a -> Doc
ppr b
b, c -> Doc
forall a. Pretty a => a -> Doc
ppr c
c, d -> Doc
forall a. Pretty a => a -> Doc
ppr d
d, e -> Doc
forall a. Pretty a => a -> Doc
ppr e
e,
               f -> Doc
forall a. Pretty a => a -> Doc
ppr f
f, g -> Doc
forall a. Pretty a => a -> Doc
ppr g
g, h -> Doc
forall a. Pretty a => a -> Doc
ppr h
h, i -> Doc
forall a. Pretty a => a -> Doc
ppr i
i]

instance (Pretty a, Pretty b, Pretty c, Pretty d, Pretty e,
          Pretty f, Pretty g, Pretty h, Pretty i, Pretty j)
  => Pretty (a, b, c, d, e, f, g, h, i, j) where
    ppr :: (a, b, c, d, e, f, g, h, i, j) -> Doc
ppr (a
a, b
b, c
c, d
d, e
e, f
f, g
g, h
h, i
i, j
j) =
        [Doc] -> Doc
tuple [a -> Doc
forall a. Pretty a => a -> Doc
ppr a
a, b -> Doc
forall a. Pretty a => a -> Doc
ppr b
b, c -> Doc
forall a. Pretty a => a -> Doc
ppr c
c, d -> Doc
forall a. Pretty a => a -> Doc
ppr d
d, e -> Doc
forall a. Pretty a => a -> Doc
ppr e
e,
               f -> Doc
forall a. Pretty a => a -> Doc
ppr f
f, g -> Doc
forall a. Pretty a => a -> Doc
ppr g
g, h -> Doc
forall a. Pretty a => a -> Doc
ppr h
h, i -> Doc
forall a. Pretty a => a -> Doc
ppr i
i, j -> Doc
forall a. Pretty a => a -> Doc
ppr j
j]

instance (Pretty a, Pretty b, Pretty c, Pretty d, Pretty e,
          Pretty f, Pretty g, Pretty h, Pretty i, Pretty j,
          Pretty k)
  => Pretty (a, b, c, d, e, f, g, h, i, j, k) where
    ppr :: (a, b, c, d, e, f, g, h, i, j, k) -> Doc
ppr (a
a, b
b, c
c, d
d, e
e, f
f, g
g, h
h, i
i, j
j, k
k) =
        [Doc] -> Doc
tuple [a -> Doc
forall a. Pretty a => a -> Doc
ppr a
a, b -> Doc
forall a. Pretty a => a -> Doc
ppr b
b, c -> Doc
forall a. Pretty a => a -> Doc
ppr c
c, d -> Doc
forall a. Pretty a => a -> Doc
ppr d
d, e -> Doc
forall a. Pretty a => a -> Doc
ppr e
e,
               f -> Doc
forall a. Pretty a => a -> Doc
ppr f
f, g -> Doc
forall a. Pretty a => a -> Doc
ppr g
g, h -> Doc
forall a. Pretty a => a -> Doc
ppr h
h, i -> Doc
forall a. Pretty a => a -> Doc
ppr i
i, j -> Doc
forall a. Pretty a => a -> Doc
ppr j
j,
               k -> Doc
forall a. Pretty a => a -> Doc
ppr k
k]

instance (Pretty a, Pretty b, Pretty c, Pretty d, Pretty e,
          Pretty f, Pretty g, Pretty h, Pretty i, Pretty j,
          Pretty k, Pretty l)
  => Pretty (a, b, c, d, e, f, g, h, i, j, k, l) where
    ppr :: (a, b, c, d, e, f, g, h, i, j, k, l) -> Doc
ppr (a
a, b
b, c
c, d
d, e
e, f
f, g
g, h
h, i
i, j
j, k
k, l
l) =
        [Doc] -> Doc
tuple [a -> Doc
forall a. Pretty a => a -> Doc
ppr a
a, b -> Doc
forall a. Pretty a => a -> Doc
ppr b
b, c -> Doc
forall a. Pretty a => a -> Doc
ppr c
c, d -> Doc
forall a. Pretty a => a -> Doc
ppr d
d, e -> Doc
forall a. Pretty a => a -> Doc
ppr e
e,
               f -> Doc
forall a. Pretty a => a -> Doc
ppr f
f, g -> Doc
forall a. Pretty a => a -> Doc
ppr g
g, h -> Doc
forall a. Pretty a => a -> Doc
ppr h
h, i -> Doc
forall a. Pretty a => a -> Doc
ppr i
i, j -> Doc
forall a. Pretty a => a -> Doc
ppr j
j,
               k -> Doc
forall a. Pretty a => a -> Doc
ppr k
k, l -> Doc
forall a. Pretty a => a -> Doc
ppr l
l]

instance (Pretty a, Pretty b, Pretty c, Pretty d, Pretty e,
          Pretty f, Pretty g, Pretty h, Pretty i, Pretty j,
          Pretty k, Pretty l, Pretty m)
  => Pretty (a, b, c, d, e, f, g, h, i, j, k, l, m) where
    ppr :: (a, b, c, d, e, f, g, h, i, j, k, l, m) -> Doc
ppr (a
a, b
b, c
c, d
d, e
e, f
f, g
g, h
h, i
i, j
j, k
k, l
l, m
m) =
        [Doc] -> Doc
tuple [a -> Doc
forall a. Pretty a => a -> Doc
ppr a
a, b -> Doc
forall a. Pretty a => a -> Doc
ppr b
b, c -> Doc
forall a. Pretty a => a -> Doc
ppr c
c, d -> Doc
forall a. Pretty a => a -> Doc
ppr d
d, e -> Doc
forall a. Pretty a => a -> Doc
ppr e
e,
               f -> Doc
forall a. Pretty a => a -> Doc
ppr f
f, g -> Doc
forall a. Pretty a => a -> Doc
ppr g
g, h -> Doc
forall a. Pretty a => a -> Doc
ppr h
h, i -> Doc
forall a. Pretty a => a -> Doc
ppr i
i, j -> Doc
forall a. Pretty a => a -> Doc
ppr j
j,
               k -> Doc
forall a. Pretty a => a -> Doc
ppr k
k, l -> Doc
forall a. Pretty a => a -> Doc
ppr l
l, m -> Doc
forall a. Pretty a => a -> Doc
ppr m
m]

instance (Pretty a, Pretty b, Pretty c, Pretty d, Pretty e,
          Pretty f, Pretty g, Pretty h, Pretty i, Pretty j,
          Pretty k, Pretty l, Pretty m, Pretty n)
  => Pretty (a, b, c, d, e, f, g, h, i, j, k, l, m, n) where
    ppr :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> Doc
ppr (a
a, b
b, c
c, d
d, e
e, f
f, g
g, h
h, i
i, j
j, k
k, l
l, m
m, n
n) =
        [Doc] -> Doc
tuple [a -> Doc
forall a. Pretty a => a -> Doc
ppr a
a, b -> Doc
forall a. Pretty a => a -> Doc
ppr b
b, c -> Doc
forall a. Pretty a => a -> Doc
ppr c
c, d -> Doc
forall a. Pretty a => a -> Doc
ppr d
d, e -> Doc
forall a. Pretty a => a -> Doc
ppr e
e,
               f -> Doc
forall a. Pretty a => a -> Doc
ppr f
f, g -> Doc
forall a. Pretty a => a -> Doc
ppr g
g, h -> Doc
forall a. Pretty a => a -> Doc
ppr h
h, i -> Doc
forall a. Pretty a => a -> Doc
ppr i
i, j -> Doc
forall a. Pretty a => a -> Doc
ppr j
j,
               k -> Doc
forall a. Pretty a => a -> Doc
ppr k
k, l -> Doc
forall a. Pretty a => a -> Doc
ppr l
l, m -> Doc
forall a. Pretty a => a -> Doc
ppr m
m, n -> Doc
forall a. Pretty a => a -> Doc
ppr n
n]

instance (Pretty a, Pretty b, Pretty c, Pretty d, Pretty e,
          Pretty f, Pretty g, Pretty h, Pretty i, Pretty j,
          Pretty k, Pretty l, Pretty m, Pretty n, Pretty o)
  => Pretty (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) where
    ppr :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> Doc
ppr (a
a, b
b, c
c, d
d, e
e, f
f, g
g, h
h, i
i, j
j, k
k, l
l, m
m, n
n, o
o) =
        [Doc] -> Doc
tuple [a -> Doc
forall a. Pretty a => a -> Doc
ppr a
a, b -> Doc
forall a. Pretty a => a -> Doc
ppr b
b, c -> Doc
forall a. Pretty a => a -> Doc
ppr c
c, d -> Doc
forall a. Pretty a => a -> Doc
ppr d
d, e -> Doc
forall a. Pretty a => a -> Doc
ppr e
e,
               f -> Doc
forall a. Pretty a => a -> Doc
ppr f
f, g -> Doc
forall a. Pretty a => a -> Doc
ppr g
g, h -> Doc
forall a. Pretty a => a -> Doc
ppr h
h, i -> Doc
forall a. Pretty a => a -> Doc
ppr i
i, j -> Doc
forall a. Pretty a => a -> Doc
ppr j
j,
               k -> Doc
forall a. Pretty a => a -> Doc
ppr k
k, l -> Doc
forall a. Pretty a => a -> Doc
ppr l
l, m -> Doc
forall a. Pretty a => a -> Doc
ppr m
m, n -> Doc
forall a. Pretty a => a -> Doc
ppr n
n, o -> Doc
forall a. Pretty a => a -> Doc
ppr o
o]