    --  $Header: /data/cvs-rep/uust/lib/pretty/UU/Pretty/Ext.hs,v 1.1 2002/11/13 16:05:20 uust Exp $
    --  $Name:  $ (version name)

    module UU.Pretty.Ext ( -- Derived from single and multiple
                           (>^<), (>>^<<), (>#<), (>>#<<), wide_text
                         , vlist, hlist, hlist_sp, list_h1, hlist_h1
                         , (>|<<), (>-<<), (>>|<), (>>-<), pp_es
                           -- Displaying the result
                         , vdisp
                           -- Printing brackets
                         , pp_wrap, pp_quotes, pp_doubleQuotes
                         , pp_parens, pp_brackets, pp_braces
                           -- Printing structures
                         , hv, hv_sp, pp_block, pp_ite
                         , pp_list, pp_slist, pp_parens_list
                         ) where

    {- Derived pretty-printing combinators. Version 2.0c
       Authors: S. Doaitse Swierstra and Pablo R. Azero
       Date: July, 1999
     -}

    import UU.Pretty.Basic

    infixr 3 >#<, >>#<<, >>|<, >|<<
    infixr 2 >>-<, >-<<
    infixr 1 >^<, >>^<<

    -- -------------------------------------------------------------------
    -- PP instances for often used simple data types ---------------------

    instance PP Int where
      pp :: Int -> PP_Doc
    pp = String -> PP_Doc
    text (String -> PP_Doc) -> (Int -> String) -> Int -> PP_Doc
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Int -> String
    forall a. Show a => a -> String
    show

    instance PP Float where
      pp :: Float -> PP_Doc
    pp = String -> PP_Doc
    text (String -> PP_Doc) -> (Float -> String) -> Float -> PP_Doc
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Float -> String
    forall a. Show a => a -> String
    show

    -- -------------------------------------------------------------------
    -- Derived from single and multiple ----------------------------------

    (>^<), (>#<) :: (PP a, PP b) => a -> b -> PP_Doc
    a :: a
    a  >^< :: a -> b -> PP_Doc
    >^<  b :: b
    b  =  PP_Doc -> PP_Doc
    join  (a
    a  a -> b -> PP_Doc
    forall a b. (PP a, PP b) => a -> b -> PP_Doc
    >//<  b
    b)
    l :: a
    l  >#< :: a -> b -> PP_Doc
    >#<  r :: b
    r  =  a
    l a -> PP_Doc -> PP_Doc
    forall a b. (PP a, PP b) => a -> b -> PP_Doc
    >|< " " String -> b -> PP_Doc
    forall a b. (PP a, PP b) => a -> b -> PP_Doc
    >|< b
    r

    pp_es :: t a -> PP_Doc
    pp_es string :: t a
    string = if t a -> Bool
    forall (t :: * -> *) a. Foldable t => t a -> Bool
    null t a
    string then PP_Doc
    empty else t a -> PP_Doc
    forall a. PP a => a -> PP_Doc
    pp t a
    string

    wide_text :: Int -> String -> PP_Doc
    wide_text t :: Int
    t s :: String
    s | Int
    ls Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    > Int
    t    = String -> PP_Doc
    text String
    s
                  | Bool
    otherwise = String -> PP_Doc
    text (String -> PP_Doc) -> (String -> String) -> String -> PP_Doc
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (if Int
    t Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    >= 0 then Int -> String -> String
    forall a. Int -> [a] -> [a]
    take Int
    t else Int -> String -> String
    forall a. Int -> [a] -> [a]
    take 0) (String -> PP_Doc) -> String -> PP_Doc
    forall a b. (a -> b) -> a -> b
    $ (String
    s String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ String
    spaces)
      where ls :: Int
    ls     = String -> Int
    forall (t :: * -> *) a. Foldable t => t a -> Int
    length String
    s
            spaces :: String
    spaces = Char -> String
    forall a. a -> [a]
    repeat ' '

    hlist, vlist, hlist_sp :: PP a => [a] -> PP_Doc
    vlist :: [a] -> PP_Doc
    vlist    = (a -> PP_Doc -> PP_Doc) -> PP_Doc -> [a] -> PP_Doc
    forall (t :: * -> *) a b.
    Foldable t =>
    (a -> b -> b) -> b -> t a -> b
    foldr  a -> PP_Doc -> PP_Doc
    forall a b. (PP a, PP b) => a -> b -> PP_Doc
    (>-<) PP_Doc
    empty
    hlist :: [a] -> PP_Doc
    hlist    = (a -> PP_Doc -> PP_Doc) -> PP_Doc -> [a] -> PP_Doc
    forall (t :: * -> *) a b.
    Foldable t =>
    (a -> b -> b) -> b -> t a -> b
    foldr  a -> PP_Doc -> PP_Doc
    forall a b. (PP a, PP b) => a -> b -> PP_Doc
    (>|<) PP_Doc
    empty
    hlist_sp :: [a] -> PP_Doc
    hlist_sp = (a -> PP_Doc -> PP_Doc) -> PP_Doc -> [a] -> PP_Doc
    forall (t :: * -> *) a b.
    Foldable t =>
    (a -> b -> b) -> b -> t a -> b
    foldr  a -> PP_Doc -> PP_Doc
    forall a b. (PP a, PP b) => a -> b -> PP_Doc
    (>#<) PP_Doc
    empty

    list_h1 :: [PP_Doc] -> [PP_Doc]
    list_h1 :: [PP_Doc] -> [PP_Doc]
    list_h1   = (PP_Doc -> PP_Doc) -> [PP_Doc] -> [PP_Doc]
    forall a b. (a -> b) -> [a] -> [b]
    map PP_Doc -> PP_Doc
    element_h1

    hlist_h1 :: [PP_Doc] -> PP_Doc
    hlist_h1  = (PP_Doc -> PP_Doc -> PP_Doc) -> [PP_Doc] -> PP_Doc
    forall (t :: * -> *) a. Foldable t => (a -> a -> a) -> t a -> a
    foldr1 PP_Doc -> PP_Doc -> PP_Doc
    forall a b. (PP a, PP b) => a -> b -> PP_Doc
    (>|<) ([PP_Doc] -> PP_Doc)
    -> ([PP_Doc] -> [PP_Doc]) -> [PP_Doc] -> PP_Doc
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [PP_Doc] -> [PP_Doc]
    list_h1

    (>>^<<), (>>#<<) :: PP_Exp -> PP_Exp -> PP_Exp
    a :: PP_Exp
    a >>^<< :: PP_Exp -> PP_Exp -> PP_Exp
    >>^<< b :: PP_Exp
    b  =  PP_Exp -> PP_Exp
    ejoin (PP_Exp
    a PP_Exp -> PP_Exp -> PP_Exp
    >>//<< PP_Exp
    b)
    l :: PP_Exp
    l >>#<< :: PP_Exp -> PP_Exp -> PP_Exp
    >>#<< r :: PP_Exp
    r  =  PP_Exp
    l PP_Exp -> PP_Exp -> PP_Exp
    >>|<< (" " String -> PP_Exp -> PP_Exp
    forall a. PP a => a -> PP_Exp -> PP_Exp
    >|<< PP_Exp
    r)

    (>|<<), (>-<<) :: PP a => a -> PP_Exp -> PP_Exp
    l :: a
    l >|<< :: a -> PP_Exp -> PP_Exp
    >|<< r :: PP_Exp
    r = a -> PP_Exp
    forall a. PP a => a -> PP_Exp
    c2e a
    l PP_Exp -> PP_Exp -> PP_Exp
    >>|<< PP_Exp
    r
    u :: a
    u >-<< :: a -> PP_Exp -> PP_Exp
    >-<< l :: PP_Exp
    l = a -> PP_Exp
    forall a. PP a => a -> PP_Exp
    c2e a
    u PP_Exp -> PP_Exp -> PP_Exp
    >>-<< PP_Exp
    l

    (>>|<), (>>-<) :: PP a => PP_Exp -> a -> PP_Exp
    l :: PP_Exp
    l >>|< :: PP_Exp -> a -> PP_Exp
    >>|< r :: a
    r = PP_Exp
    l PP_Exp -> PP_Exp -> PP_Exp
    >>|<< a -> PP_Exp
    forall a. PP a => a -> PP_Exp
    c2e a
    r
    u :: PP_Exp
    u >>-< :: PP_Exp -> a -> PP_Exp
    >>-< l :: a
    l = PP_Exp
    u PP_Exp -> PP_Exp -> PP_Exp
    >>-<< a -> PP_Exp
    forall a. PP a => a -> PP_Exp
    c2e a
    l

    -- -------------------------------------------------------------------
    -- Displaying the result ---------------------------------------------

    vdisp :: Int -> [PP_Doc] -> ShowS
    vdisp :: Int -> [PP_Doc] -> String -> String
    vdisp pw :: Int
    pw = (PP_Doc -> (String -> String) -> String -> String)
    -> (String -> String) -> [PP_Doc] -> String -> String
    forall (t :: * -> *) a b.
    Foldable t =>
    (a -> b -> b) -> b -> t a -> b
    foldr (\f :: PP_Doc
    f fs :: String -> String
    fs -> PP_Doc -> Int -> String -> String
    disp PP_Doc
    f Int
    pw (String -> String) -> (String -> String) -> String -> String
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . ("\n"String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++) (String -> String) -> (String -> String) -> String -> String
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . String -> String
    fs) String -> String
    forall a. a -> a
    id

    -- -------------------------------------------------------------------
    -- Printing brackets -------------------------------------------------

    pp_wrap :: PP a =>  a -> a -> PP_Doc -> PP_Doc
    pp_wrap :: a -> a -> PP_Doc -> PP_Doc
    pp_wrap op :: a
    op cl :: a
    cl p :: PP_Doc
    p = a
    op a -> PP_Doc -> PP_Doc
    forall a b. (PP a, PP b) => a -> b -> PP_Doc
    >|< (PP_Doc
    p PP_Doc -> a -> PP_Doc
    forall a b. (PP a, PP b) => a -> b -> PP_Doc
    >|< a
    cl)

    pp_quotes :: PP_Doc -> PP_Doc
    pp_quotes       = Char -> Char -> PP_Doc -> PP_Doc
    forall a. PP a => a -> a -> PP_Doc -> PP_Doc
    pp_wrap '`' '\''
    pp_doubleQuotes :: PP_Doc -> PP_Doc
    pp_doubleQuotes = Char -> Char -> PP_Doc -> PP_Doc
    forall a. PP a => a -> a -> PP_Doc -> PP_Doc
    pp_wrap '"' '"'
    pp_parens :: PP_Doc -> PP_Doc
    pp_parens       = Char -> Char -> PP_Doc -> PP_Doc
    forall a. PP a => a -> a -> PP_Doc -> PP_Doc
    pp_wrap '(' ')'
    pp_brackets :: PP_Doc -> PP_Doc
    pp_brackets     = Char -> Char -> PP_Doc -> PP_Doc
    forall a. PP a => a -> a -> PP_Doc -> PP_Doc
    pp_wrap '[' ']'
    pp_braces :: PP_Doc -> PP_Doc
    pp_braces       = Char -> Char -> PP_Doc -> PP_Doc
    forall a. PP a => a -> a -> PP_Doc -> PP_Doc
    pp_wrap '{' '}'

    -- -------------------------------------------------------------------
    -- Printing structures

    -- hv: display a list of elements either horizontally or vertically,
    -- 2 possible layouts: horizonal or vertical

    hv :: PP a => [a] -> PP_Doc
    hv :: [a] -> PP_Doc
    hv = PP_Doc -> PP_Doc
    join (PP_Doc -> PP_Doc) -> ([a] -> PP_Doc) -> [a] -> PP_Doc
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (PP_Doc -> PP_Doc -> PP_Doc) -> PP_Doc -> [PP_Doc] -> PP_Doc
    forall (t :: * -> *) a b.
    Foldable t =>
    (a -> b -> b) -> b -> t a -> b
    foldr PP_Doc -> PP_Doc -> PP_Doc
    forall a. PP a => a -> a -> PP_Doc
    onehv (PP_Doc
    empty PP_Doc -> PP_Doc -> PP_Doc
    forall a b. (PP a, PP b) => a -> b -> PP_Doc
    >//< PP_Doc
    empty) ([PP_Doc] -> PP_Doc) -> ([a] -> [PP_Doc]) -> [a] -> PP_Doc
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (a -> PP_Doc) -> [a] -> [PP_Doc]
    forall a b. (a -> b) -> [a] -> [b]
    map a -> PP_Doc
    forall a. PP a => a -> PP_Doc
    pp
      where onehv :: a -> a -> PP_Doc
    onehv p :: a
    p ps :: a
    ps =      PP_Exp -> PP_Exp
    eelement_h1 PP_Exp
    par PP_Exp -> PP_Exp -> PP_Exp
    >>|<< PP_Exp
    fpar
                       PP_Exp -> PP_Exp -> PP_Exp
    >>//<< PP_Exp
    par PP_Exp -> PP_Exp -> PP_Exp
    >>-<< PP_Exp
    spar
                       PP_Exp -> [a] -> PP_Doc
    forall a. PP a => PP_Exp -> [a] -> PP_Doc
    >>$<   [a
    p, a
    ps]

    -- hv_sp: same as hv but inserts spaces between the elements
    -- 2 possible layouts: horizonal or vertical

    hv_sp :: PP a => [a] -> PP_Doc
    hv_sp :: [a] -> PP_Doc
    hv_sp l :: [a]
    l | [a] -> Bool
    forall (t :: * -> *) a. Foldable t => t a -> Bool
    null [a]
    l    = PP_Doc
    empty
            | Bool
    otherwise = [PP_Doc] -> PP_Doc
    forall a. PP a => [a] -> PP_Doc
    lhv_sp ([PP_Doc] -> PP_Doc) -> ([a] -> [PP_Doc]) -> [a] -> PP_Doc
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (a -> PP_Doc) -> [a] -> [PP_Doc]
    forall a b. (a -> b) -> [a] -> [b]
    map a -> PP_Doc
    forall a. PP a => a -> PP_Doc
    pp ([a] -> PP_Doc) -> [a] -> PP_Doc
    forall a b. (a -> b) -> a -> b
    $ [a]
    l

    lhv_sp :: [a] -> PP_Doc
    lhv_sp fs :: [a]
    fs@(f :: a
    f:fss :: [a]
    fss) = PP_Exp
    hs PP_Exp -> PP_Exp -> PP_Exp
    >>^<< PP_Exp
    vs PP_Exp -> [a] -> PP_Doc
    forall a. PP a => PP_Exp -> [a] -> PP_Doc
    >>$< [a]
    fs
      where (hs :: PP_Exp
    hs, vs :: PP_Exp
    vs)  = (a -> (PP_Exp, PP_Exp) -> (PP_Exp, PP_Exp))
    -> (PP_Exp, PP_Exp) -> [a] -> (PP_Exp, PP_Exp)
    forall (t :: * -> *) a b.
    Foldable t =>
    (a -> b -> b) -> b -> t a -> b
    foldr a -> (PP_Exp, PP_Exp) -> (PP_Exp, PP_Exp)
    forall p. p -> (PP_Exp, PP_Exp) -> (PP_Exp, PP_Exp)
    paralg (PP_Exp
    par, PP_Exp
    par) [a]
    fss
            paralg :: p -> (PP_Exp, PP_Exp) -> (PP_Exp, PP_Exp)
    paralg    = \_ (nhs :: PP_Exp
    nhs,nvs :: PP_Exp
    nvs) -> (PP_Exp -> PP_Exp
    eelement_h1 PP_Exp
    par PP_Exp -> PP_Exp -> PP_Exp
    >>#<< PP_Exp
    nhs, PP_Exp
    par PP_Exp -> PP_Exp -> PP_Exp
    >>-<< PP_Exp
    nvs)

    -- pp_block: printing of block structures with open, close and separator
    --           keywords
    -- 2 possible layouts: horizonal or vertical

    --pp_block :: String -> String -> String -> [PP_Doc] -> PP_Doc
    pp_block :: t a -> t a -> t a -> [PP_Doc] -> PP_Doc
    pp_block okw :: t a
    okw ckw :: t a
    ckw sep :: t a
    sep fs :: [PP_Doc]
    fs
      | [PP_Doc] -> Bool
    forall (t :: * -> *) a. Foldable t => t a -> Bool
    null [PP_Doc]
    fs   = [PP_Doc] -> PP_Doc
    forall a. PP a => [a] -> PP_Doc
    hv [PP_Doc
    open, PP_Doc
    close]
      | Bool
    otherwise = PP_Doc -> PP_Doc
    join
          (      PP_Exp -> PP_Exp
    eelement_h1  PP_Exp
    par PP_Exp -> PP_Exp -> PP_Exp
    >>|<< PP_Exp
    fpar
          PP_Exp -> PP_Exp -> PP_Exp
    >>//<<              PP_Exp
    par PP_Exp -> PP_Exp -> PP_Exp
    >>-<< PP_Exp
    spar
          PP_Exp -> [PP_Doc] -> PP_Doc
    forall a. PP a => PP_Exp -> [a] -> PP_Doc
    >>$< [PP_Doc
    open PP_Doc -> PP_Doc -> PP_Doc
    forall a b. (PP a, PP b) => a -> b -> PP_Doc
    >|< (Int -> PP_Doc -> PP_Doc
    forall a. PP a => Int -> a -> PP_Doc
    indent (Int
    startcolumnInt -> Int -> Int
    forall a. Num a => a -> a -> a
    -Int
    lk) (PP_Doc -> PP_Doc) -> ([PP_Doc] -> PP_Doc) -> [PP_Doc] -> PP_Doc
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [PP_Doc] -> PP_Doc
    forall a. [a] -> a
    head ([PP_Doc] -> PP_Doc) -> [PP_Doc] -> PP_Doc
    forall a b. (a -> b) -> a -> b
    $ [PP_Doc]
    fs), PP_Doc
    hvopts]
          )
      where lk :: Int
    lk           =  t a -> Int
    forall (t :: * -> *) a. Foldable t => t a -> Int
    length t a
    okw
            lsep :: Int
    lsep         =  t a -> Int
    forall (t :: * -> *) a. Foldable t => t a -> Int
    length t a
    sep
            startcolumn :: Int
    startcolumn  =  (Int
    lk Int -> Int -> Int
    forall a. Ord a => a -> a -> a
    `max` Int
    lsep)
            hvopts :: PP_Doc
    hvopts       =  (PP_Doc -> PP_Doc -> PP_Doc) -> PP_Doc -> [PP_Doc] -> PP_Doc
    forall (t :: * -> *) a b.
    Foldable t =>
    (a -> b -> b) -> b -> t a -> b
    foldr PP_Doc -> PP_Doc -> PP_Doc
    hvoptalg PP_Doc
    dclose ([PP_Doc] -> [PP_Doc]
    forall a. [a] -> [a]
    tail [PP_Doc]
    fs)
            hvoptalg :: PP_Doc -> PP_Doc -> PP_Doc
    hvoptalg p :: PP_Doc
    p ps :: PP_Doc
    ps
              = (       PP_Exp
    par  PP_Exp -> PP_Exp -> PP_Exp
    >>|<<  PP_Exp -> PP_Exp
    eelement_h1 PP_Exp
    par                   PP_Exp -> PP_Exp -> PP_Exp
    >>|<<  PP_Exp
    fpar
                 PP_Exp -> PP_Exp -> PP_Exp
    >>//<< PP_Exp
    par  PP_Exp -> PP_Exp -> PP_Exp
    >>|<<  Int -> PP_Exp -> PP_Exp
    eindent (Int
    startcolumn Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - Int
    lsep) PP_Exp
    par  PP_Exp -> PP_Exp -> PP_Exp
    >>-<<  PP_Exp
    spar
                ) PP_Exp -> [PP_Doc] -> PP_Doc
    forall a. PP a => PP_Exp -> [a] -> PP_Doc
    >>$< [t a -> PP_Doc
    forall (t :: * -> *) a. (Foldable t, PP (t a)) => t a -> PP_Doc
    pp_es t a
    sep, PP_Doc
    p, PP_Doc
    ps]
            dclose :: PP_Doc
    dclose       =  Int -> PP_Exp -> PP_Exp
    eindent (Int
    startcolumnInt -> Int -> Int
    forall a. Num a => a -> a -> a
    -Int
    lk) PP_Exp
    par PP_Exp -> PP_Exp -> PP_Exp
    >>//<< PP_Exp
    par PP_Exp -> [PP_Doc] -> PP_Doc
    forall a. PP a => PP_Exp -> [a] -> PP_Doc
    >>$< [PP_Doc
    close]
            open :: PP_Doc
    open         =  t a -> PP_Doc
    forall (t :: * -> *) a. (Foldable t, PP (t a)) => t a -> PP_Doc
    pp_es t a
    okw
            close :: PP_Doc
    close        =  t a -> PP_Doc
    forall (t :: * -> *) a. (Foldable t, PP (t a)) => t a -> PP_Doc
    pp_es t a
    ckw

    -- pp_ite: printing an if-then-else-fi statement
    -- three possible layouts: horizonal, vertical or mixed

    --pp_ite :: (PP a, PP b, PP c, PP d)
    --       => a -> b -> c -> d -> PP_Doc -> PP_Doc -> PP_Doc -> PP_Doc
    pp_ite :: a -> a -> a -> a -> b -> b -> b -> PP_Doc
    pp_ite kw_if :: a
    kw_if kw_then :: a
    kw_then kw_else :: a
    kw_else kw_fi :: a
    kw_fi c :: b
    c t :: b
    t e :: b
    e
      = (     PP_Exp -> PP_Exp
    eelement_h1 ( PP_Exp
    par PP_Exp -> PP_Exp -> PP_Exp
    >>|<< PP_Exp
    par PP_Exp -> PP_Exp -> PP_Exp
    >>|<< PP_Exp
    par PP_Exp -> PP_Exp -> PP_Exp
    >>|<< PP_Exp
    par )
        PP_Exp -> PP_Exp -> PP_Exp
    >>^<< (     (     ( PP_Exp
    par PP_Exp -> PP_Exp -> PP_Exp
    >>|<< PP_Exp
    par PP_Exp -> PP_Exp -> PP_Exp
    >>^<< PP_Exp
    par PP_Exp -> PP_Exp -> PP_Exp
    >>-<< PP_Exp
    par )
                    PP_Exp -> [PP_Exp] -> PP_Exp
    >>$<< [PP_Exp
    par, PP_Exp
    par PP_Exp -> PP_Exp -> PP_Exp
    >>-<< PP_Exp
    par]
                    )
              PP_Exp -> PP_Exp -> PP_Exp
    >>-<< PP_Exp
    par
              )
        )  PP_Exp -> [PP_Doc] -> PP_Doc
    forall a. PP a => PP_Exp -> [a] -> PP_Doc
    >>$< [ a
    kw_if   a -> b -> PP_Doc
    forall a b. (PP a, PP b) => a -> b -> PP_Doc
    >|< b
    c
                , a
    kw_then a -> b -> PP_Doc
    forall a b. (PP a, PP b) => a -> b -> PP_Doc
    >|< b
    t
                , a
    kw_else a -> b -> PP_Doc
    forall a b. (PP a, PP b) => a -> b -> PP_Doc
    >|< b
    e
                , a -> PP_Doc
    forall a. PP a => a -> PP_Doc
    pp a
    kw_fi
                ]

    -- pp_slist: printing a list of elements in a "mini page", needs open, close and
    --          separator keywords and a "mini page" width
    -- one possible layout: depends on the page width given, when it reaches the end
    -- of the page it continues on the next line
    -- restrictions: only simple elements allowed (no pp_slists or flexible layouts
    --               in the list [PP_Doc])

    pp_slist :: Int -> String -> String -> String -> [PP_Doc] -> PP_Doc
    pp_slist :: Int -> String -> String -> String -> [PP_Doc] -> PP_Doc
    pp_slist pw :: Int
    pw ol :: String
    ol cl :: String
    cl sep :: String
    sep fl :: [PP_Doc]
    fl
      | [PP_Doc] -> Bool
    forall (t :: * -> *) a. Foldable t => t a -> Bool
    null [PP_Doc]
    fl    =   [PP_Doc] -> PP_Doc
    forall a. PP a => [a] -> PP_Doc
    hv [PP_Doc
    open, PP_Doc
    close]
      | Bool
    otherwise  =   PP_Exp -> PP_Exp
    eelement_h1 (PP_Exp
    par PP_Exp -> PP_Exp -> PP_Exp
    >>|<< PP_Exp
    par) PP_Exp -> PP_Exp -> PP_Exp
    >>^<< (PP_Exp
    par PP_Exp -> PP_Exp -> PP_Exp
    >>-<< PP_Exp
    par)
                   PP_Exp -> [PP_Doc] -> PP_Doc
    forall a. PP a => PP_Exp -> [a] -> PP_Doc
    >>$< [PP_Doc
    nes, PP_Doc
    close]
      where nes :: PP_Doc
    nes    =   Int -> [PP_Doc] -> PP_Doc
    forall a. PP a => Int -> [a] -> PP_Doc
    fillblock Int
    pw (PP_Doc
    openPP_Doc -> [PP_Doc] -> [PP_Doc]
    forall a. a -> [a] -> [a]
    : PP_Doc
    nePP_Doc -> [PP_Doc] -> [PP_Doc]
    forall a. a -> [a] -> [a]
    : (PP_Doc -> PP_Doc) -> [PP_Doc] -> [PP_Doc]
    forall a b. (a -> b) -> [a] -> [b]
    map (String -> PP_Doc
    forall (t :: * -> *) a. (Foldable t, PP (t a)) => t a -> PP_Doc
    pp_es String
    sep PP_Doc -> PP_Doc -> PP_Doc
    forall a b. (PP a, PP b) => a -> b -> PP_Doc
    >|<) ([PP_Doc] -> [PP_Doc]
    forall a. [a] -> [a]
    tail [PP_Doc]
    fl))
            ne :: PP_Doc
    ne     =   (Int -> Char -> String
    forall a. Int -> a -> [a]
    replicate (if Int
    ws Int -> Int -> Bool
    forall a. Eq a => a -> a -> Bool
    == 0 then 0 else Int
    ws Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - 1) ' ')
                   String -> PP_Doc -> PP_Doc
    forall a b. (PP a, PP b) => a -> b -> PP_Doc
    >|< ([PP_Doc] -> PP_Doc
    forall a. [a] -> a
    head [PP_Doc]
    fl)
            ws :: Int
    ws     =   String -> Int
    forall (t :: * -> *) a. Foldable t => t a -> Int
    length String
    sep
            open :: PP_Doc
    open   = String -> PP_Doc
    forall (t :: * -> *) a. (Foldable t, PP (t a)) => t a -> PP_Doc
    pp_es String
    ol
            close :: PP_Doc
    close  = String -> PP_Doc
    forall (t :: * -> *) a. (Foldable t, PP (t a)) => t a -> PP_Doc
    pp_es String
    cl

    -- pp_list: printing a list of elements in a "mini page", needs open, close and
    --          separator keywords and a "mini page" width
    -- one possible layout: depends on the page width given, when it reaches the end
    -- of the page it continues on the next line

    pp_list :: Int -> String -> String -> String -> [PP_Doc] -> PP_Doc
    pp_list :: Int -> String -> String -> String -> [PP_Doc] -> PP_Doc
    pp_list pw :: Int
    pw ol :: String
    ol cl :: String
    cl _   []     = String -> PP_Doc
    forall (t :: * -> *) a. (Foldable t, PP (t a)) => t a -> PP_Doc
    pp_es (String
    ol String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ String
    cl)
    pp_list pw :: Int
    pw ol :: String
    ol cl :: String
    cl sep :: String
    sep (f :: PP_Doc
    f:fs :: [PP_Doc]
    fs)
      = Int -> [PP_Doc] -> PP_Doc
    forall a. PP a => Int -> [a] -> PP_Doc
    fillblock Int
    pw (String -> PP_Doc
    forall a. PP a => a -> PP_Doc
    pp String
    olPP_Doc -> [PP_Doc] -> [PP_Doc]
    forall a. a -> [a] -> [a]
    : (PP_Doc -> PP_Doc
    forall a. PP a => a -> PP_Doc
    pp PP_Doc
    f)PP_Doc -> [PP_Doc] -> [PP_Doc]
    forall a. a -> [a] -> [a]
    : ((PP_Doc -> PP_Doc) -> [PP_Doc] -> [PP_Doc]
    forall a b. (a -> b) -> [a] -> [b]
    map (String -> PP_Doc
    forall (t :: * -> *) a. (Foldable t, PP (t a)) => t a -> PP_Doc
    pp_es String
    sep PP_Doc -> PP_Doc -> PP_Doc
    forall a b. (PP a, PP b) => a -> b -> PP_Doc
    >|<) [PP_Doc]
    fs) [PP_Doc] -> [PP_Doc] -> [PP_Doc]
    forall a. [a] -> [a] -> [a]
    ++ [ String -> PP_Doc
    forall a. PP a => a -> PP_Doc
    pp String
    cl ])

    -- pp_parens_list: idem pp_list, with parenthesis and comma separator

    pp_parens_list :: Int -> [PP_Doc] -> PP_Doc
    pp_parens_list :: Int -> [PP_Doc] -> PP_Doc
    pp_parens_list mpw :: Int
    mpw = Int -> String -> String -> String -> [PP_Doc] -> PP_Doc
    pp_list Int
    mpw "(" ")" ", "