{-
Copyright (c) 2015, Dan Rosén
Copyright (c) 2016, Nick Smallbone

All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

    * Redistributions of source code must retain the above copyright
      notice, this list of conditions and the following disclaimer.

    * Redistributions in binary form must reproduce the above
      copyright notice, this list of conditions and the following
      disclaimer in the documentation and/or other materials provided
      with the distribution.

    * Neither the name of the copyright holder nor the names of other
      contributors may be used to endorse or promote products derived
      from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-}
-- File generated by the BNF Converter (bnfc 2.9.4).

{-# LANGUAGE CPP #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE LambdaCase #-}
#if __GLASGOW_HASKELL__ <= 708
{-# LANGUAGE OverlappingInstances #-}
#endif

-- | Pretty-printer for TIP.

module TIP.PrintTIP where

import Prelude
  ( ($), (.)
  , Bool(..), (==), (<)
  , Int, Integer, Double, (+), (-), (*)
  , String, (++)
  , ShowS, showChar, showString
  , all, elem, foldr, id, map, null, replicate, shows, span
  )
import Data.Char ( Char, isSpace )
import qualified TIP.AbsTIP

-- | The top-level printing method.

printTree :: Print a => a -> String
printTree :: a -> String
printTree = Doc -> String
render (Doc -> String) -> (a -> Doc) -> a -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> a -> Doc
forall a. Print a => Int -> a -> Doc
prt 0

type Doc = [ShowS] -> [ShowS]

doc :: ShowS -> Doc
doc :: ShowS -> Doc
doc = (:)

render :: Doc -> String
render :: Doc -> String
render d :: Doc
d = Int -> Bool -> [String] -> ShowS
rend 0 Bool
False ((ShowS -> String) -> [ShowS] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map (ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ "") ([ShowS] -> [String]) -> [ShowS] -> [String]
forall a b. (a -> b) -> a -> b
$ Doc
d []) ""
  where
  rend
    :: Int        -- ^ Indentation level.
    -> Bool       -- ^ Pending indentation to be output before next character?
    -> [String]
    -> ShowS
  rend :: Int -> Bool -> [String] -> ShowS
rend i :: Int
i p :: Bool
p = \case
      "["      :ts :: [String]
ts -> Char -> ShowS
char '[' ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Bool -> [String] -> ShowS
rend Int
i Bool
False [String]
ts
      "("      :ts :: [String]
ts -> Char -> ShowS
char '(' ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Bool -> [String] -> ShowS
rend Int
i Bool
False [String]
ts
      "{"      :ts :: [String]
ts -> Int -> Bool -> ShowS
onNewLine Int
i     Bool
p ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> ShowS
showChar   '{'  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> [String] -> ShowS
new (Int
iInt -> Int -> Int
forall a. Num a => a -> a -> a
+1) [String]
ts
      "}" : ";":ts :: [String]
ts -> Int -> Bool -> ShowS
onNewLine (Int
iInt -> Int -> Int
forall a. Num a => a -> a -> a
-1) Bool
p ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString "};" ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> [String] -> ShowS
new (Int
iInt -> Int -> Int
forall a. Num a => a -> a -> a
-1) [String]
ts
      "}"      :ts :: [String]
ts -> Int -> Bool -> ShowS
onNewLine (Int
iInt -> Int -> Int
forall a. Num a => a -> a -> a
-1) Bool
p ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> ShowS
showChar   '}'  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> [String] -> ShowS
new (Int
iInt -> Int -> Int
forall a. Num a => a -> a -> a
-1) [String]
ts
      [";"]        -> Char -> ShowS
char ';'
      ";"      :ts :: [String]
ts -> Char -> ShowS
char ';' ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> [String] -> ShowS
new Int
i [String]
ts
      t :: String
t  : ts :: [String]
ts@(s :: String
s:_) | String -> Bool
closingOrPunctuation String
s
                   -> ShowS
pending ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
t ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Bool -> [String] -> ShowS
rend Int
i Bool
False [String]
ts
      t :: String
t        :ts :: [String]
ts -> ShowS
pending ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
space String
t      ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Bool -> [String] -> ShowS
rend Int
i Bool
False [String]
ts
      []           -> ShowS
forall a. a -> a
id
    where
    -- Output character after pending indentation.
    char :: Char -> ShowS
    char :: Char -> ShowS
char c :: Char
c = ShowS
pending ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> ShowS
showChar Char
c

    -- Output pending indentation.
    pending :: ShowS
    pending :: ShowS
pending = if Bool
p then Int -> ShowS
indent Int
i else ShowS
forall a. a -> a
id

  -- Indentation (spaces) for given indentation level.
  indent :: Int -> ShowS
  indent :: Int -> ShowS
indent i :: Int
i = Int -> ShowS -> ShowS
replicateS (2Int -> Int -> Int
forall a. Num a => a -> a -> a
*Int
i) (Char -> ShowS
showChar ' ')

  -- Continue rendering in new line with new indentation.
  new :: Int -> [String] -> ShowS
  new :: Int -> [String] -> ShowS
new j :: Int
j ts :: [String]
ts = Char -> ShowS
showChar '\n' ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Bool -> [String] -> ShowS
rend Int
j Bool
True [String]
ts

  -- Make sure we are on a fresh line.
  onNewLine :: Int -> Bool -> ShowS
  onNewLine :: Int -> Bool -> ShowS
onNewLine i :: Int
i p :: Bool
p = (if Bool
p then ShowS
forall a. a -> a
id else Char -> ShowS
showChar '\n') ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> ShowS
indent Int
i

  -- Separate given string from following text by a space (if needed).
  space :: String -> ShowS
  space :: String -> ShowS
space t :: String
t s :: String
s =
    case ((Char -> Bool) -> String -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
all Char -> Bool
isSpace String
t', String -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null String
spc, String -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null String
rest) of
      (True , _   , True ) -> []              -- remove trailing space
      (False, _   , True ) -> String
t'              -- remove trailing space
      (False, True, False) -> String
t' String -> ShowS
forall a. [a] -> [a] -> [a]
++ ' ' Char -> ShowS
forall a. a -> [a] -> [a]
: String
s   -- add space if none
      _                    -> String
t' String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
s
    where
      t' :: String
t'          = String -> ShowS
showString String
t []
      (spc :: String
spc, rest :: String
rest) = (Char -> Bool) -> String -> (String, String)
forall a. (a -> Bool) -> [a] -> ([a], [a])
span Char -> Bool
isSpace String
s

  closingOrPunctuation :: String -> Bool
  closingOrPunctuation :: String -> Bool
closingOrPunctuation [c :: Char
c] = Char
c Char -> String -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` String
closerOrPunct
  closingOrPunctuation _   = Bool
False

  closerOrPunct :: String
  closerOrPunct :: String
closerOrPunct = ")],;"

parenth :: Doc -> Doc
parenth :: Doc -> Doc
parenth ss :: Doc
ss = ShowS -> Doc
doc (Char -> ShowS
showChar '(') Doc -> Doc -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Doc
ss Doc -> Doc -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShowS -> Doc
doc (Char -> ShowS
showChar ')')

concatS :: [ShowS] -> ShowS
concatS :: [ShowS] -> ShowS
concatS = (ShowS -> ShowS -> ShowS) -> ShowS -> [ShowS] -> ShowS
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
(.) ShowS
forall a. a -> a
id

concatD :: [Doc] -> Doc
concatD :: [Doc] -> Doc
concatD = (Doc -> Doc -> Doc) -> Doc -> [Doc] -> Doc
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr Doc -> Doc -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
(.) Doc
forall a. a -> a
id

replicateS :: Int -> ShowS -> ShowS
replicateS :: Int -> ShowS -> ShowS
replicateS n :: Int
n f :: ShowS
f = [ShowS] -> ShowS
concatS (Int -> ShowS -> [ShowS]
forall a. Int -> a -> [a]
replicate Int
n ShowS
f)

-- | The printer class does the job.

class Print a where
  prt :: Int -> a -> Doc

instance {-# OVERLAPPABLE #-} Print a => Print [a] where
  prt :: Int -> [a] -> Doc
prt i :: Int
i = [Doc] -> Doc
concatD ([Doc] -> Doc) -> ([a] -> [Doc]) -> [a] -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> Doc) -> [a] -> [Doc]
forall a b. (a -> b) -> [a] -> [b]
map (Int -> a -> Doc
forall a. Print a => Int -> a -> Doc
prt Int
i)

instance Print Char where
  prt :: Int -> Char -> Doc
prt _ c :: Char
c = ShowS -> Doc
doc (Char -> ShowS
showChar '\'' ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Char -> ShowS
mkEsc '\'' Char
c ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> ShowS
showChar '\'')

instance Print String where
  prt :: Int -> String -> Doc
prt _ = String -> Doc
printString

printString :: String -> Doc
printString :: String -> Doc
printString s :: String
s = ShowS -> Doc
doc (Char -> ShowS
showChar '"' ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [ShowS] -> ShowS
concatS ((Char -> ShowS) -> String -> [ShowS]
forall a b. (a -> b) -> [a] -> [b]
map (Char -> Char -> ShowS
mkEsc '"') String
s) ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> ShowS
showChar '"')

mkEsc :: Char -> Char -> ShowS
mkEsc :: Char -> Char -> ShowS
mkEsc q :: Char
q = \case
  s :: Char
s | Char
s Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
q -> Char -> ShowS
showChar '\\' ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> ShowS
showChar Char
s
  '\\' -> String -> ShowS
showString "\\\\"
  '\n' -> String -> ShowS
showString "\\n"
  '\t' -> String -> ShowS
showString "\\t"
  s :: Char
s -> Char -> ShowS
showChar Char
s

prPrec :: Int -> Int -> Doc -> Doc
prPrec :: Int -> Int -> Doc -> Doc
prPrec i :: Int
i j :: Int
j = if Int
j Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
< Int
i then Doc -> Doc
parenth else Doc -> Doc
forall a. a -> a
id

instance Print Integer where
  prt :: Int -> Integer -> Doc
prt _ x :: Integer
x = ShowS -> Doc
doc (Integer -> ShowS
forall a. Show a => a -> ShowS
shows Integer
x)

instance Print Double where
  prt :: Int -> Double -> Doc
prt _ x :: Double
x = ShowS -> Doc
doc (Double -> ShowS
forall a. Show a => a -> ShowS
shows Double
x)

instance Print TIP.AbsTIP.UnquotedSymbol where
  prt :: Int -> UnquotedSymbol -> Doc
prt _ (TIP.AbsTIP.UnquotedSymbol (_,i :: String
i)) = ShowS -> Doc
doc (ShowS -> Doc) -> ShowS -> Doc
forall a b. (a -> b) -> a -> b
$ String -> ShowS
showString String
i
instance Print TIP.AbsTIP.QuotedSymbol where
  prt :: Int -> QuotedSymbol -> Doc
prt _ (TIP.AbsTIP.QuotedSymbol (_,i :: String
i)) = ShowS -> Doc
doc (ShowS -> Doc) -> ShowS -> Doc
forall a b. (a -> b) -> a -> b
$ String -> ShowS
showString String
i
instance Print TIP.AbsTIP.Keyword where
  prt :: Int -> Keyword -> Doc
prt _ (TIP.AbsTIP.Keyword i :: String
i) = ShowS -> Doc
doc (ShowS -> Doc) -> ShowS -> Doc
forall a b. (a -> b) -> a -> b
$ String -> ShowS
showString String
i
instance Print TIP.AbsTIP.Start where
  prt :: Int -> Start -> Doc
prt i :: Int
i = \case
    TIP.AbsTIP.Start decls :: [Decl]
decls -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [Int -> [Decl] -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 [Decl]
decls])

instance Print [TIP.AbsTIP.Decl] where
  prt :: Int -> [Decl] -> Doc
prt _ [] = [Doc] -> Doc
concatD []
  prt _ (x :: Decl
x:xs :: [Decl]
xs) = [Doc] -> Doc
concatD [ShowS -> Doc
doc (String -> ShowS
showString "("), Int -> Decl -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 Decl
x, ShowS -> Doc
doc (String -> ShowS
showString ")"), Int -> [Decl] -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 [Decl]
xs]

instance Print TIP.AbsTIP.Decl where
  prt :: Int -> Decl -> Doc
prt i :: Int
i = \case
    TIP.AbsTIP.DeclareDatatype attrsymbol :: AttrSymbol
attrsymbol datatype :: Datatype
datatype -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [ShowS -> Doc
doc (String -> ShowS
showString "declare-datatype"), Int -> AttrSymbol -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 AttrSymbol
attrsymbol, Int -> Datatype -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 Datatype
datatype])
    TIP.AbsTIP.DeclareDatatypes datatypenames :: [DatatypeName]
datatypenames datatypes :: [Datatype]
datatypes -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [ShowS -> Doc
doc (String -> ShowS
showString "declare-datatypes"), ShowS -> Doc
doc (String -> ShowS
showString "("), Int -> [DatatypeName] -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 [DatatypeName]
datatypenames, ShowS -> Doc
doc (String -> ShowS
showString ")"), ShowS -> Doc
doc (String -> ShowS
showString "("), Int -> [Datatype] -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 [Datatype]
datatypes, ShowS -> Doc
doc (String -> ShowS
showString ")")])
    TIP.AbsTIP.DeclareSort attrsymbol :: AttrSymbol
attrsymbol n :: Integer
n -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [ShowS -> Doc
doc (String -> ShowS
showString "declare-sort"), Int -> AttrSymbol -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 AttrSymbol
attrsymbol, Int -> Integer -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 Integer
n])
    TIP.AbsTIP.DeclareConst attrsymbol :: AttrSymbol
attrsymbol consttype :: ConstType
consttype -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [ShowS -> Doc
doc (String -> ShowS
showString "declare-const"), Int -> AttrSymbol -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 AttrSymbol
attrsymbol, Int -> ConstType -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 ConstType
consttype])
    TIP.AbsTIP.DeclareFun attrsymbol :: AttrSymbol
attrsymbol funtype :: FunType
funtype -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [ShowS -> Doc
doc (String -> ShowS
showString "declare-fun"), Int -> AttrSymbol -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 AttrSymbol
attrsymbol, Int -> FunType -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 FunType
funtype])
    TIP.AbsTIP.DefineFun fundec :: FunDec
fundec expr :: Expr
expr -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [ShowS -> Doc
doc (String -> ShowS
showString "define-fun"), Int -> FunDec -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 FunDec
fundec, Int -> Expr -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 Expr
expr])
    TIP.AbsTIP.DefineFunRec fundec :: FunDec
fundec expr :: Expr
expr -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [ShowS -> Doc
doc (String -> ShowS
showString "define-fun-rec"), Int -> FunDec -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 FunDec
fundec, Int -> Expr -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 Expr
expr])
    TIP.AbsTIP.DefineFunsRec bracketedfundecs :: [BracketedFunDec]
bracketedfundecs exprs :: [Expr]
exprs -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [ShowS -> Doc
doc (String -> ShowS
showString "define-funs-rec"), ShowS -> Doc
doc (String -> ShowS
showString "("), Int -> [BracketedFunDec] -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 [BracketedFunDec]
bracketedfundecs, ShowS -> Doc
doc (String -> ShowS
showString ")"), ShowS -> Doc
doc (String -> ShowS
showString "("), Int -> [Expr] -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 [Expr]
exprs, ShowS -> Doc
doc (String -> ShowS
showString ")")])
    TIP.AbsTIP.Formula assertion :: Assertion
assertion attrs :: [Attr]
attrs expr :: Expr
expr -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [Int -> Assertion -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 Assertion
assertion, Int -> [Attr] -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 [Attr]
attrs, Int -> Expr -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 Expr
expr])
    TIP.AbsTIP.FormulaPar assertion :: Assertion
assertion attrs :: [Attr]
attrs par :: Par
par expr :: Expr
expr -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [Int -> Assertion -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 Assertion
assertion, Int -> [Attr] -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 [Attr]
attrs, ShowS -> Doc
doc (String -> ShowS
showString "("), Int -> Par -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 Par
par, Int -> Expr -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 Expr
expr, ShowS -> Doc
doc (String -> ShowS
showString ")")])

instance Print TIP.AbsTIP.Assertion where
  prt :: Int -> Assertion -> Doc
prt i :: Int
i = \case
    TIP.AbsTIP.Assert -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [ShowS -> Doc
doc (String -> ShowS
showString "assert")])
    TIP.AbsTIP.Prove -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [ShowS -> Doc
doc (String -> ShowS
showString "prove")])

instance Print TIP.AbsTIP.Par where
  prt :: Int -> Par -> Doc
prt i :: Int
i = \case
    TIP.AbsTIP.Par symbols :: [Symbol]
symbols -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [ShowS -> Doc
doc (String -> ShowS
showString "par"), ShowS -> Doc
doc (String -> ShowS
showString "("), Int -> [Symbol] -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 [Symbol]
symbols, ShowS -> Doc
doc (String -> ShowS
showString ")")])

instance Print TIP.AbsTIP.ConstType where
  prt :: Int -> ConstType -> Doc
prt i :: Int
i = \case
    TIP.AbsTIP.ConstTypeMono type_ :: Type
type_ -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [Int -> Type -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 Type
type_])
    TIP.AbsTIP.ConstTypePoly par :: Par
par type_ :: Type
type_ -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [ShowS -> Doc
doc (String -> ShowS
showString "("), Int -> Par -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 Par
par, Int -> Type -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 Type
type_, ShowS -> Doc
doc (String -> ShowS
showString ")")])

instance Print TIP.AbsTIP.InnerFunType where
  prt :: Int -> InnerFunType -> Doc
prt i :: Int
i = \case
    TIP.AbsTIP.InnerFunType types :: [Type]
types type_ :: Type
type_ -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [ShowS -> Doc
doc (String -> ShowS
showString "("), Int -> [Type] -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 [Type]
types, ShowS -> Doc
doc (String -> ShowS
showString ")"), Int -> Type -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 Type
type_])

instance Print TIP.AbsTIP.FunType where
  prt :: Int -> FunType -> Doc
prt i :: Int
i = \case
    TIP.AbsTIP.FunTypeMono innerfuntype :: InnerFunType
innerfuntype -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [Int -> InnerFunType -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 InnerFunType
innerfuntype])
    TIP.AbsTIP.FunTypePoly par :: Par
par innerfuntype :: InnerFunType
innerfuntype -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [ShowS -> Doc
doc (String -> ShowS
showString "("), Int -> Par -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 Par
par, ShowS -> Doc
doc (String -> ShowS
showString "("), Int -> InnerFunType -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 InnerFunType
innerfuntype, ShowS -> Doc
doc (String -> ShowS
showString ")"), ShowS -> Doc
doc (String -> ShowS
showString ")")])

instance Print TIP.AbsTIP.InnerFunDec where
  prt :: Int -> InnerFunDec -> Doc
prt i :: Int
i = \case
    TIP.AbsTIP.InnerFunDec bindings :: [Binding]
bindings type_ :: Type
type_ -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [ShowS -> Doc
doc (String -> ShowS
showString "("), Int -> [Binding] -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 [Binding]
bindings, ShowS -> Doc
doc (String -> ShowS
showString ")"), Int -> Type -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 Type
type_])

instance Print TIP.AbsTIP.FunDec where
  prt :: Int -> FunDec -> Doc
prt i :: Int
i = \case
    TIP.AbsTIP.FunDecMono attrsymbol :: AttrSymbol
attrsymbol innerfundec :: InnerFunDec
innerfundec -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [Int -> AttrSymbol -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 AttrSymbol
attrsymbol, Int -> InnerFunDec -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 InnerFunDec
innerfundec])
    TIP.AbsTIP.FunDecPoly attrsymbol :: AttrSymbol
attrsymbol par :: Par
par innerfundec :: InnerFunDec
innerfundec -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [Int -> AttrSymbol -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 AttrSymbol
attrsymbol, ShowS -> Doc
doc (String -> ShowS
showString "("), Int -> Par -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 Par
par, ShowS -> Doc
doc (String -> ShowS
showString "("), Int -> InnerFunDec -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 InnerFunDec
innerfundec, ShowS -> Doc
doc (String -> ShowS
showString ")"), ShowS -> Doc
doc (String -> ShowS
showString ")")])

instance Print TIP.AbsTIP.BracketedFunDec where
  prt :: Int -> BracketedFunDec -> Doc
prt i :: Int
i = \case
    TIP.AbsTIP.BracketedFunDec fundec :: FunDec
fundec -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [ShowS -> Doc
doc (String -> ShowS
showString "("), Int -> FunDec -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 FunDec
fundec, ShowS -> Doc
doc (String -> ShowS
showString ")")])

instance Print TIP.AbsTIP.DatatypeName where
  prt :: Int -> DatatypeName -> Doc
prt i :: Int
i = \case
    TIP.AbsTIP.DatatypeName attrsymbol :: AttrSymbol
attrsymbol n :: Integer
n -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [ShowS -> Doc
doc (String -> ShowS
showString "("), Int -> AttrSymbol -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 AttrSymbol
attrsymbol, Int -> Integer -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 Integer
n, ShowS -> Doc
doc (String -> ShowS
showString ")")])

instance Print TIP.AbsTIP.InnerDatatype where
  prt :: Int -> InnerDatatype -> Doc
prt i :: Int
i = \case
    TIP.AbsTIP.InnerDatatype constructors :: [Constructor]
constructors -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [ShowS -> Doc
doc (String -> ShowS
showString "("), Int -> [Constructor] -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 [Constructor]
constructors, ShowS -> Doc
doc (String -> ShowS
showString ")")])

instance Print TIP.AbsTIP.Datatype where
  prt :: Int -> Datatype -> Doc
prt i :: Int
i = \case
    TIP.AbsTIP.DatatypeMono innerdatatype :: InnerDatatype
innerdatatype -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [Int -> InnerDatatype -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 InnerDatatype
innerdatatype])
    TIP.AbsTIP.DatatypePoly par :: Par
par innerdatatype :: InnerDatatype
innerdatatype -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [ShowS -> Doc
doc (String -> ShowS
showString "("), Int -> Par -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 Par
par, Int -> InnerDatatype -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 InnerDatatype
innerdatatype, ShowS -> Doc
doc (String -> ShowS
showString ")")])

instance Print TIP.AbsTIP.Constructor where
  prt :: Int -> Constructor -> Doc
prt i :: Int
i = \case
    TIP.AbsTIP.Constructor attrsymbol :: AttrSymbol
attrsymbol bindings :: [Binding]
bindings -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [ShowS -> Doc
doc (String -> ShowS
showString "("), Int -> AttrSymbol -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 AttrSymbol
attrsymbol, Int -> [Binding] -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 [Binding]
bindings, ShowS -> Doc
doc (String -> ShowS
showString ")")])

instance Print TIP.AbsTIP.Binding where
  prt :: Int -> Binding -> Doc
prt i :: Int
i = \case
    TIP.AbsTIP.Binding symbol :: Symbol
symbol type_ :: Type
type_ -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [ShowS -> Doc
doc (String -> ShowS
showString "("), Int -> Symbol -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 Symbol
symbol, Int -> Type -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 Type
type_, ShowS -> Doc
doc (String -> ShowS
showString ")")])

instance Print TIP.AbsTIP.LetDecl where
  prt :: Int -> LetDecl -> Doc
prt i :: Int
i = \case
    TIP.AbsTIP.LetDecl symbol :: Symbol
symbol expr :: Expr
expr -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [ShowS -> Doc
doc (String -> ShowS
showString "("), Int -> Symbol -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 Symbol
symbol, Int -> Expr -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 Expr
expr, ShowS -> Doc
doc (String -> ShowS
showString ")")])

instance Print TIP.AbsTIP.Type where
  prt :: Int -> Type -> Doc
prt i :: Int
i = \case
    TIP.AbsTIP.TyVar symbol :: Symbol
symbol -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [Int -> Symbol -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 Symbol
symbol])
    TIP.AbsTIP.TyApp symbol :: Symbol
symbol types :: [Type]
types -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [ShowS -> Doc
doc (String -> ShowS
showString "("), Int -> Symbol -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 Symbol
symbol, Int -> [Type] -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 [Type]
types, ShowS -> Doc
doc (String -> ShowS
showString ")")])
    TIP.AbsTIP.ArrowTy types :: [Type]
types -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [ShowS -> Doc
doc (String -> ShowS
showString "("), ShowS -> Doc
doc (String -> ShowS
showString "=>"), Int -> [Type] -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 [Type]
types, ShowS -> Doc
doc (String -> ShowS
showString ")")])
    TIP.AbsTIP.IntTy -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [ShowS -> Doc
doc (String -> ShowS
showString "Int")])
    TIP.AbsTIP.RealTy -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [ShowS -> Doc
doc (String -> ShowS
showString "Real")])
    TIP.AbsTIP.BoolTy -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [ShowS -> Doc
doc (String -> ShowS
showString "Bool")])

instance Print TIP.AbsTIP.Expr where
  prt :: Int -> Expr -> Doc
prt i :: Int
i = \case
    TIP.AbsTIP.Var polysymbol :: PolySymbol
polysymbol -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [Int -> PolySymbol -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 PolySymbol
polysymbol])
    TIP.AbsTIP.App head :: Head
head exprs :: [Expr]
exprs -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [ShowS -> Doc
doc (String -> ShowS
showString "("), Int -> Head -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 Head
head, Int -> [Expr] -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 [Expr]
exprs, ShowS -> Doc
doc (String -> ShowS
showString ")")])
    TIP.AbsTIP.Match expr :: Expr
expr cases :: [Case]
cases -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [ShowS -> Doc
doc (String -> ShowS
showString "("), ShowS -> Doc
doc (String -> ShowS
showString "match"), Int -> Expr -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 Expr
expr, ShowS -> Doc
doc (String -> ShowS
showString "("), Int -> [Case] -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 [Case]
cases, ShowS -> Doc
doc (String -> ShowS
showString ")"), ShowS -> Doc
doc (String -> ShowS
showString ")")])
    TIP.AbsTIP.Let letdecls :: [LetDecl]
letdecls expr :: Expr
expr -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [ShowS -> Doc
doc (String -> ShowS
showString "("), ShowS -> Doc
doc (String -> ShowS
showString "let"), ShowS -> Doc
doc (String -> ShowS
showString "("), Int -> [LetDecl] -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 [LetDecl]
letdecls, ShowS -> Doc
doc (String -> ShowS
showString ")"), Int -> Expr -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 Expr
expr, ShowS -> Doc
doc (String -> ShowS
showString ")")])
    TIP.AbsTIP.Binder binder :: Binder
binder bindings :: [Binding]
bindings expr :: Expr
expr -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [ShowS -> Doc
doc (String -> ShowS
showString "("), Int -> Binder -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 Binder
binder, ShowS -> Doc
doc (String -> ShowS
showString "("), Int -> [Binding] -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 [Binding]
bindings, ShowS -> Doc
doc (String -> ShowS
showString ")"), Int -> Expr -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 Expr
expr, ShowS -> Doc
doc (String -> ShowS
showString ")")])
    TIP.AbsTIP.Lit lit :: Lit
lit -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [Int -> Lit -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 Lit
lit])

instance Print TIP.AbsTIP.Lit where
  prt :: Int -> Lit -> Doc
prt i :: Int
i = \case
    TIP.AbsTIP.LitInt n :: Integer
n -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [Int -> Integer -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 Integer
n])
    TIP.AbsTIP.LitNegInt n :: Integer
n -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [ShowS -> Doc
doc (String -> ShowS
showString "-"), Int -> Integer -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 Integer
n])
    TIP.AbsTIP.LitTrue -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [ShowS -> Doc
doc (String -> ShowS
showString "true")])
    TIP.AbsTIP.LitFalse -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [ShowS -> Doc
doc (String -> ShowS
showString "false")])

instance Print TIP.AbsTIP.Binder where
  prt :: Int -> Binder -> Doc
prt i :: Int
i = \case
    TIP.AbsTIP.Lambda -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [ShowS -> Doc
doc (String -> ShowS
showString "lambda")])
    TIP.AbsTIP.Forall -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [ShowS -> Doc
doc (String -> ShowS
showString "forall")])
    TIP.AbsTIP.Exists -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [ShowS -> Doc
doc (String -> ShowS
showString "exists")])

instance Print TIP.AbsTIP.Case where
  prt :: Int -> Case -> Doc
prt i :: Int
i = \case
    TIP.AbsTIP.Case pattern_ :: Pattern
pattern_ expr :: Expr
expr -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [ShowS -> Doc
doc (String -> ShowS
showString "("), Int -> Pattern -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 Pattern
pattern_, Int -> Expr -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 Expr
expr, ShowS -> Doc
doc (String -> ShowS
showString ")")])

instance Print TIP.AbsTIP.Pattern where
  prt :: Int -> Pattern -> Doc
prt i :: Int
i = \case
    TIP.AbsTIP.Default -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [ShowS -> Doc
doc (String -> ShowS
showString "_")])
    TIP.AbsTIP.ConPat symbol :: Symbol
symbol symbols :: [Symbol]
symbols -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [ShowS -> Doc
doc (String -> ShowS
showString "("), Int -> Symbol -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 Symbol
symbol, Int -> [Symbol] -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 [Symbol]
symbols, ShowS -> Doc
doc (String -> ShowS
showString ")")])
    TIP.AbsTIP.SimplePat symbol :: Symbol
symbol -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [Int -> Symbol -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 Symbol
symbol])
    TIP.AbsTIP.LitPat lit :: Lit
lit -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [Int -> Lit -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 Lit
lit])

instance Print TIP.AbsTIP.Head where
  prt :: Int -> Head -> Doc
prt i :: Int
i = \case
    TIP.AbsTIP.Const polysymbol :: PolySymbol
polysymbol -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [Int -> PolySymbol -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 PolySymbol
polysymbol])
    TIP.AbsTIP.At -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [ShowS -> Doc
doc (String -> ShowS
showString "@")])
    TIP.AbsTIP.IfThenElse -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [ShowS -> Doc
doc (String -> ShowS
showString "ite")])
    TIP.AbsTIP.And -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [ShowS -> Doc
doc (String -> ShowS
showString "and")])
    TIP.AbsTIP.Or -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [ShowS -> Doc
doc (String -> ShowS
showString "or")])
    TIP.AbsTIP.Not -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [ShowS -> Doc
doc (String -> ShowS
showString "not")])
    TIP.AbsTIP.Implies -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [ShowS -> Doc
doc (String -> ShowS
showString "=>")])
    TIP.AbsTIP.Equal -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [ShowS -> Doc
doc (String -> ShowS
showString "=")])
    TIP.AbsTIP.Distinct -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [ShowS -> Doc
doc (String -> ShowS
showString "distinct")])
    TIP.AbsTIP.NumAdd -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [ShowS -> Doc
doc (String -> ShowS
showString "+")])
    TIP.AbsTIP.NumSub -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [ShowS -> Doc
doc (String -> ShowS
showString "-")])
    TIP.AbsTIP.NumMul -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [ShowS -> Doc
doc (String -> ShowS
showString "*")])
    TIP.AbsTIP.NumDiv -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [ShowS -> Doc
doc (String -> ShowS
showString "/")])
    TIP.AbsTIP.IntDiv -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [ShowS -> Doc
doc (String -> ShowS
showString "div")])
    TIP.AbsTIP.IntMod -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [ShowS -> Doc
doc (String -> ShowS
showString "mod")])
    TIP.AbsTIP.NumGt -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [ShowS -> Doc
doc (String -> ShowS
showString ">")])
    TIP.AbsTIP.NumGe -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [ShowS -> Doc
doc (String -> ShowS
showString ">=")])
    TIP.AbsTIP.NumLt -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [ShowS -> Doc
doc (String -> ShowS
showString "<")])
    TIP.AbsTIP.NumLe -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [ShowS -> Doc
doc (String -> ShowS
showString "<=")])
    TIP.AbsTIP.NumWiden -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [ShowS -> Doc
doc (String -> ShowS
showString "to_real")])

instance Print TIP.AbsTIP.PolySymbol where
  prt :: Int -> PolySymbol -> Doc
prt i :: Int
i = \case
    TIP.AbsTIP.NoAs symbol :: Symbol
symbol -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [Int -> Symbol -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 Symbol
symbol])
    TIP.AbsTIP.As symbol :: Symbol
symbol types :: [Type]
types -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [ShowS -> Doc
doc (String -> ShowS
showString "("), ShowS -> Doc
doc (String -> ShowS
showString "_"), Int -> Symbol -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 Symbol
symbol, Int -> [Type] -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 [Type]
types, ShowS -> Doc
doc (String -> ShowS
showString ")")])

instance Print TIP.AbsTIP.AttrSymbol where
  prt :: Int -> AttrSymbol -> Doc
prt i :: Int
i = \case
    TIP.AbsTIP.AttrSymbol symbol :: Symbol
symbol attrs :: [Attr]
attrs -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [Int -> Symbol -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 Symbol
symbol, Int -> [Attr] -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 [Attr]
attrs])

instance Print TIP.AbsTIP.Attr where
  prt :: Int -> Attr -> Doc
prt i :: Int
i = \case
    TIP.AbsTIP.NoValue keyword :: Keyword
keyword -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [Int -> Keyword -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 Keyword
keyword])
    TIP.AbsTIP.Value keyword :: Keyword
keyword symbol :: Symbol
symbol -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [Int -> Keyword -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 Keyword
keyword, Int -> Symbol -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 Symbol
symbol])

instance Print [TIP.AbsTIP.LetDecl] where
  prt :: Int -> [LetDecl] -> Doc
prt _ [] = [Doc] -> Doc
concatD []
  prt _ (x :: LetDecl
x:xs :: [LetDecl]
xs) = [Doc] -> Doc
concatD [Int -> LetDecl -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 LetDecl
x, Int -> [LetDecl] -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 [LetDecl]
xs]

instance Print [TIP.AbsTIP.Case] where
  prt :: Int -> [Case] -> Doc
prt _ [] = [Doc] -> Doc
concatD []
  prt _ (x :: Case
x:xs :: [Case]
xs) = [Doc] -> Doc
concatD [Int -> Case -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 Case
x, Int -> [Case] -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 [Case]
xs]

instance Print [TIP.AbsTIP.Expr] where
  prt :: Int -> [Expr] -> Doc
prt _ [] = [Doc] -> Doc
concatD []
  prt _ (x :: Expr
x:xs :: [Expr]
xs) = [Doc] -> Doc
concatD [Int -> Expr -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 Expr
x, Int -> [Expr] -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 [Expr]
xs]

instance Print [TIP.AbsTIP.Datatype] where
  prt :: Int -> [Datatype] -> Doc
prt _ [] = [Doc] -> Doc
concatD []
  prt _ (x :: Datatype
x:xs :: [Datatype]
xs) = [Doc] -> Doc
concatD [Int -> Datatype -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 Datatype
x, Int -> [Datatype] -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 [Datatype]
xs]

instance Print [TIP.AbsTIP.Constructor] where
  prt :: Int -> [Constructor] -> Doc
prt _ [] = [Doc] -> Doc
concatD []
  prt _ (x :: Constructor
x:xs :: [Constructor]
xs) = [Doc] -> Doc
concatD [Int -> Constructor -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 Constructor
x, Int -> [Constructor] -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 [Constructor]
xs]

instance Print [TIP.AbsTIP.Binding] where
  prt :: Int -> [Binding] -> Doc
prt _ [] = [Doc] -> Doc
concatD []
  prt _ (x :: Binding
x:xs :: [Binding]
xs) = [Doc] -> Doc
concatD [Int -> Binding -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 Binding
x, Int -> [Binding] -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 [Binding]
xs]

instance Print [TIP.AbsTIP.Symbol] where
  prt :: Int -> [Symbol] -> Doc
prt _ [] = [Doc] -> Doc
concatD []
  prt _ (x :: Symbol
x:xs :: [Symbol]
xs) = [Doc] -> Doc
concatD [Int -> Symbol -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 Symbol
x, Int -> [Symbol] -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 [Symbol]
xs]

instance Print [TIP.AbsTIP.Type] where
  prt :: Int -> [Type] -> Doc
prt _ [] = [Doc] -> Doc
concatD []
  prt _ (x :: Type
x:xs :: [Type]
xs) = [Doc] -> Doc
concatD [Int -> Type -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 Type
x, Int -> [Type] -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 [Type]
xs]

instance Print [TIP.AbsTIP.FunDec] where
  prt :: Int -> [FunDec] -> Doc
prt _ [] = [Doc] -> Doc
concatD []
  prt _ (x :: FunDec
x:xs :: [FunDec]
xs) = [Doc] -> Doc
concatD [Int -> FunDec -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 FunDec
x, Int -> [FunDec] -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 [FunDec]
xs]

instance Print [TIP.AbsTIP.BracketedFunDec] where
  prt :: Int -> [BracketedFunDec] -> Doc
prt _ [] = [Doc] -> Doc
concatD []
  prt _ (x :: BracketedFunDec
x:xs :: [BracketedFunDec]
xs) = [Doc] -> Doc
concatD [Int -> BracketedFunDec -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 BracketedFunDec
x, Int -> [BracketedFunDec] -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 [BracketedFunDec]
xs]

instance Print [TIP.AbsTIP.Attr] where
  prt :: Int -> [Attr] -> Doc
prt _ [] = [Doc] -> Doc
concatD []
  prt _ (x :: Attr
x:xs :: [Attr]
xs) = [Doc] -> Doc
concatD [Int -> Attr -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 Attr
x, Int -> [Attr] -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 [Attr]
xs]

instance Print [TIP.AbsTIP.DatatypeName] where
  prt :: Int -> [DatatypeName] -> Doc
prt _ [] = [Doc] -> Doc
concatD []
  prt _ (x :: DatatypeName
x:xs :: [DatatypeName]
xs) = [Doc] -> Doc
concatD [Int -> DatatypeName -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 DatatypeName
x, Int -> [DatatypeName] -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 [DatatypeName]
xs]

instance Print TIP.AbsTIP.Symbol where
  prt :: Int -> Symbol -> Doc
prt i :: Int
i = \case
    TIP.AbsTIP.Unquoted unquotedsymbol :: UnquotedSymbol
unquotedsymbol -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [Int -> UnquotedSymbol -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 UnquotedSymbol
unquotedsymbol])
    TIP.AbsTIP.Quoted quotedsymbol :: QuotedSymbol
quotedsymbol -> Int -> Int -> Doc -> Doc
prPrec Int
i 0 ([Doc] -> Doc
concatD [Int -> QuotedSymbol -> Doc
forall a. Print a => Int -> a -> Doc
prt 0 QuotedSymbol
quotedsymbol])