{- |
    Module      :  $Header$
    Description :  Custom Show implementation for IL
    Copyright   :  (c) 2015        Björn Peemöller
                       2016 - 2017 Finn Teegen
    License     :  BSD-3-clause

    Maintainer  :  bjp@informatik.uni-kiel.de
    Stability   :  experimental
    Portability :  portable

   This module implements a generic show function comparable to the one
   obtained by @deriving Show@. However, the internal representation of
   identifiers is hidden to avoid syntactic clutter.
-}

module IL.ShowModule (showModule) where

import Curry.Base.Ident
import Curry.Base.Position

import IL.Type

-- |Show a IL module like by an devired 'Show' instance
showModule :: Module -> String
showModule :: Module -> String
showModule m :: Module
m = Module -> ShowS
showsModule Module
m "\n"

showsModule :: Module -> ShowS
showsModule :: Module -> ShowS
showsModule (Module mident :: ModuleIdent
mident imps :: [ModuleIdent]
imps decls :: [Decl]
decls)
  = String -> ShowS
showsString "Module "
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ModuleIdent -> ShowS
showsModuleIdent ModuleIdent
mident ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShowS
newline
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ModuleIdent -> ShowS) -> [ModuleIdent] -> ShowS
forall a. (a -> ShowS) -> [a] -> ShowS
showsList (\i :: ModuleIdent
i -> ModuleIdent -> ShowS
showsModuleIdent ModuleIdent
i ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShowS
newline) [ModuleIdent]
imps
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Decl -> ShowS) -> [Decl] -> ShowS
forall a. (a -> ShowS) -> [a] -> ShowS
showsList (\d :: Decl
d -> Decl -> ShowS
showsDecl Decl
d ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShowS
newline) [Decl]
decls

showsDecl :: Decl -> ShowS
showsDecl :: Decl -> ShowS
showsDecl (DataDecl qident :: QualIdent
qident arity :: Int
arity constrdecls :: [ConstrDecl]
constrdecls)
  = String -> ShowS
showsString "(DataDecl "
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. QualIdent -> ShowS
showsQualIdent QualIdent
qident ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShowS
space
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> ShowS
forall a. Show a => a -> ShowS
shows Int
arity ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShowS
space
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ConstrDecl -> ShowS) -> [ConstrDecl] -> ShowS
forall a. (a -> ShowS) -> [a] -> ShowS
showsList ConstrDecl -> ShowS
showsConstrDecl [ConstrDecl]
constrdecls
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showsString ")"
showsDecl (ExternalDataDecl qident :: QualIdent
qident arity :: Int
arity)
  = String -> ShowS
showsString "(ExternalDataDecl "
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. QualIdent -> ShowS
showsQualIdent QualIdent
qident ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShowS
space
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> ShowS
forall a. Show a => a -> ShowS
shows Int
arity
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showsString ")"
showsDecl (FunctionDecl qident :: QualIdent
qident idents :: [(Type, Ident)]
idents typ :: Type
typ expr :: Expression
expr)
  = String -> ShowS
showsString "(FunctionDecl "
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. QualIdent -> ShowS
showsQualIdent QualIdent
qident ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShowS
space
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((Type, Ident) -> ShowS) -> [(Type, Ident)] -> ShowS
forall a. (a -> ShowS) -> [a] -> ShowS
showsList (Ident -> ShowS
showsIdent (Ident -> ShowS)
-> ((Type, Ident) -> Ident) -> (Type, Ident) -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Type, Ident) -> Ident
forall a b. (a, b) -> b
snd) [(Type, Ident)]
idents ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShowS
space
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Type -> ShowS
showsType Type
typ ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShowS
space
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Expression -> ShowS
showsExpression Expression
expr
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showsString ")"
showsDecl (ExternalDecl qident :: QualIdent
qident typ :: Type
typ)
  = String -> ShowS
showsString "(ExternalDecl "
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. QualIdent -> ShowS
showsQualIdent QualIdent
qident ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShowS
space
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Type -> ShowS
showsType Type
typ
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showsString ")"

showsConstrDecl :: ConstrDecl -> ShowS
showsConstrDecl :: ConstrDecl -> ShowS
showsConstrDecl (ConstrDecl qident :: QualIdent
qident tys :: [Type]
tys)
  = String -> ShowS
showsString "(ConstrDecl "
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. QualIdent -> ShowS
showsQualIdent QualIdent
qident ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShowS
space
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Type -> ShowS) -> [Type] -> ShowS
forall a. (a -> ShowS) -> [a] -> ShowS
showsList Type -> ShowS
showsType [Type]
tys
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showsString ")"

showsType :: Type -> ShowS
showsType :: Type -> ShowS
showsType (TypeConstructor qident :: QualIdent
qident types :: [Type]
types)
  = String -> ShowS
showsString "(TypeConstructor "
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. QualIdent -> ShowS
showsQualIdent QualIdent
qident ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShowS
space
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Type -> ShowS) -> [Type] -> ShowS
forall a. (a -> ShowS) -> [a] -> ShowS
showsList Type -> ShowS
showsType [Type]
types
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showsString ")"
showsType (TypeVariable int :: Int
int)
  = String -> ShowS
showsString "(TypeVariable "
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> ShowS
forall a. Show a => a -> ShowS
shows Int
int
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showsString ")"
showsType (TypeArrow type1 :: Type
type1 type2 :: Type
type2)
  = String -> ShowS
showsString "(TypeArrow "
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Type -> ShowS
showsType Type
type1 ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShowS
space
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Type -> ShowS
showsType Type
type2
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showsString ")"
showsType (TypeForall ints :: [Int]
ints typ :: Type
typ)
  = String -> ShowS
showsString "(TypeForall "
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int -> ShowS) -> [Int] -> ShowS
forall a. (a -> ShowS) -> [a] -> ShowS
showsList Int -> ShowS
forall a. Show a => a -> ShowS
shows [Int]
ints ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShowS
space
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Type -> ShowS
showsType Type
typ
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showsString ")"

showsLiteral :: Literal -> ShowS
showsLiteral :: Literal -> ShowS
showsLiteral (Char c :: Char
c)
  = String -> ShowS
showsString "(Char "
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> ShowS
forall a. Show a => a -> ShowS
shows Char
c
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showsString ")"
showsLiteral (Int n :: Integer
n)
  = String -> ShowS
showsString "(Int "
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> ShowS
forall a. Show a => a -> ShowS
shows Integer
n
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showsString ")"
showsLiteral (Float x :: Double
x)
  = String -> ShowS
showsString "(Float "
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Double -> ShowS
forall a. Show a => a -> ShowS
shows Double
x
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showsString ")"

showsConstrTerm :: ConstrTerm -> ShowS
showsConstrTerm :: ConstrTerm -> ShowS
showsConstrTerm (LiteralPattern ty :: Type
ty lit :: Literal
lit)
  = String -> ShowS
showsString "(LiteralPattern "
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Type -> ShowS
showsType Type
ty
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Literal -> ShowS
showsLiteral Literal
lit
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showsString ")"
showsConstrTerm (ConstructorPattern ty :: Type
ty qident :: QualIdent
qident idents :: [(Type, Ident)]
idents)
  = String -> ShowS
showsString "(ConstructorPattern "
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Type -> ShowS
showsType Type
ty
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. QualIdent -> ShowS
showsQualIdent QualIdent
qident ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShowS
space
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((Type, Ident) -> ShowS) -> [(Type, Ident)] -> ShowS
forall a. (a -> ShowS) -> [a] -> ShowS
showsList (Ident -> ShowS
showsIdent (Ident -> ShowS)
-> ((Type, Ident) -> Ident) -> (Type, Ident) -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Type, Ident) -> Ident
forall a b. (a, b) -> b
snd) [(Type, Ident)]
idents
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showsString ")"
showsConstrTerm (VariablePattern ty :: Type
ty ident :: Ident
ident)
  = String -> ShowS
showsString "(VariablePattern "
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Type -> ShowS
showsType Type
ty
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ident -> ShowS
showsIdent Ident
ident
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showsString ")"

showsExpression :: Expression -> ShowS
showsExpression :: Expression -> ShowS
showsExpression (Literal ty :: Type
ty lit :: Literal
lit)
  = String -> ShowS
showsString "(Literal "
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Type -> ShowS
showsType Type
ty
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Literal -> ShowS
showsLiteral Literal
lit
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showsString ")"
showsExpression (Variable ty :: Type
ty ident :: Ident
ident)
  = String -> ShowS
showsString "(Variable "
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Type -> ShowS
showsType Type
ty
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ident -> ShowS
showsIdent Ident
ident
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showsString ")"
showsExpression (Function ty :: Type
ty qident :: QualIdent
qident int :: Int
int)
  = String -> ShowS
showsString "(Function "
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Type -> ShowS
showsType Type
ty
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. QualIdent -> ShowS
showsQualIdent QualIdent
qident ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShowS
space
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> ShowS
forall a. Show a => a -> ShowS
shows Int
int
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showsString ")"
showsExpression (Constructor ty :: Type
ty qident :: QualIdent
qident int :: Int
int)
  = String -> ShowS
showsString "(Constructor "
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Type -> ShowS
showsType Type
ty
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. QualIdent -> ShowS
showsQualIdent QualIdent
qident ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShowS
space
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> ShowS
forall a. Show a => a -> ShowS
shows Int
int
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showsString ")"
showsExpression (Apply exp1 :: Expression
exp1 exp2 :: Expression
exp2)
  = String -> ShowS
showsString "(Apply "
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Expression -> ShowS
showsExpression Expression
exp1 ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShowS
space
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Expression -> ShowS
showsExpression Expression
exp2
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showsString ")"
showsExpression (Case eval :: Eval
eval expr :: Expression
expr alts :: [Alt]
alts)
  = String -> ShowS
showsString "(Case "
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Eval -> ShowS
showsEval Eval
eval ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShowS
space
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Expression -> ShowS
showsExpression Expression
expr ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShowS
space
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Alt -> ShowS) -> [Alt] -> ShowS
forall a. (a -> ShowS) -> [a] -> ShowS
showsList Alt -> ShowS
showsAlt [Alt]
alts
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showsString ")"
showsExpression (Or exp1 :: Expression
exp1 exp2 :: Expression
exp2)
  = String -> ShowS
showsString "(Or "
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Expression -> ShowS
showsExpression Expression
exp1 ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShowS
space
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Expression -> ShowS
showsExpression Expression
exp2
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showsString ")"
showsExpression (Exist ident :: Ident
ident ty :: Type
ty expr :: Expression
expr)
  = String -> ShowS
showsString "(Exist "
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ident -> ShowS
showsIdent Ident
ident ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShowS
space
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Type -> ShowS
showsType Type
ty ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShowS
space
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Expression -> ShowS
showsExpression Expression
expr
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showsString ")"
showsExpression (Let bind :: Binding
bind expr :: Expression
expr)
  = String -> ShowS
showsString "(Let "
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Binding -> ShowS
showsBinding Binding
bind ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShowS
space
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Expression -> ShowS
showsExpression Expression
expr
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showsString ")"
showsExpression (Letrec binds :: [Binding]
binds expr :: Expression
expr)
  = String -> ShowS
showsString "(Letrec "
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Binding -> ShowS) -> [Binding] -> ShowS
forall a. (a -> ShowS) -> [a] -> ShowS
showsList Binding -> ShowS
showsBinding [Binding]
binds ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShowS
space
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Expression -> ShowS
showsExpression Expression
expr
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showsString ")"
showsExpression (Typed expr :: Expression
expr typ :: Type
typ)
  = String -> ShowS
showsString "(Typed "
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Expression -> ShowS
showsExpression Expression
expr ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShowS
space
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Type -> ShowS
showsType Type
typ
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showsString ")"

showsEval :: Eval -> ShowS
showsEval :: Eval -> ShowS
showsEval Rigid = String -> ShowS
showsString "Rigid"
showsEval Flex  = String -> ShowS
showsString "Flex"

showsAlt :: Alt -> ShowS
showsAlt :: Alt -> ShowS
showsAlt (Alt constr :: ConstrTerm
constr expr :: Expression
expr)
  = String -> ShowS
showsString "(Alt "
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ConstrTerm -> ShowS
showsConstrTerm ConstrTerm
constr ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShowS
space
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Expression -> ShowS
showsExpression Expression
expr
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showsString ")"

showsBinding :: Binding -> ShowS
showsBinding :: Binding -> ShowS
showsBinding (Binding ident :: Ident
ident expr :: Expression
expr)
  = String -> ShowS
showsString "(Binding "
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ident -> ShowS
showsIdent Ident
ident ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShowS
space
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Expression -> ShowS
showsExpression Expression
expr
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showsString ")"

showsPosition :: Position -> ShowS
showsPosition :: Position -> ShowS
showsPosition Position { line :: Position -> Int
line = Int
l, column :: Position -> Int
column = Int
c } = (Int -> ShowS) -> (Int -> ShowS) -> (Int, Int) -> ShowS
forall a b. (a -> ShowS) -> (b -> ShowS) -> (a, b) -> ShowS
showsPair Int -> ShowS
forall a. Show a => a -> ShowS
shows Int -> ShowS
forall a. Show a => a -> ShowS
shows (Int
l, Int
c)
showsPosition _ = String -> ShowS
showsString "(0,0)"

showsString :: String -> ShowS
showsString :: String -> ShowS
showsString = String -> ShowS
forall a. [a] -> [a] -> [a]
(++)

space :: ShowS
space :: ShowS
space = String -> ShowS
showsString " "

newline :: ShowS
newline :: ShowS
newline = String -> ShowS
showsString "\n"

showsMaybe :: (a -> ShowS) -> Maybe a -> ShowS
showsMaybe :: (a -> ShowS) -> Maybe a -> ShowS
showsMaybe shs :: a -> ShowS
shs = ShowS -> (a -> ShowS) -> Maybe a -> ShowS
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (String -> ShowS
showsString "Nothing")
                       (\x :: a
x -> String -> ShowS
showsString "(Just " ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> ShowS
shs a
x ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showsString ")")

showsList :: (a -> ShowS) -> [a] -> ShowS
showsList :: (a -> ShowS) -> [a] -> ShowS
showsList _   [] = String -> ShowS
showsString "[]"
showsList shs :: a -> ShowS
shs (x :: a
x:xs :: [a]
xs)
  = String -> ShowS
showsString "["
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ShowS -> a -> ShowS) -> ShowS -> [a] -> ShowS
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl (\sys :: ShowS
sys y :: a
y -> ShowS
sys ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showsString "," ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> ShowS
shs a
y) (a -> ShowS
shs a
x) [a]
xs
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showsString "]"

showsPair :: (a -> ShowS) -> (b -> ShowS) -> (a,b) -> ShowS
showsPair :: (a -> ShowS) -> (b -> ShowS) -> (a, b) -> ShowS
showsPair sa :: a -> ShowS
sa sb :: b -> ShowS
sb (a :: a
a,b :: b
b)
  = String -> ShowS
showsString "(" ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> ShowS
sa a
a ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showsString "," ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. b -> ShowS
sb b
b ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showsString ")"

showsIdent :: Ident -> ShowS
showsIdent :: Ident -> ShowS
showsIdent (Ident spi :: SpanInfo
spi x :: String
x n :: Integer
n)
  = String -> ShowS
showsString "(Ident " ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Position -> ShowS
showsPosition (SpanInfo -> Position
forall a. HasPosition a => a -> Position
getPosition SpanInfo
spi) ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShowS
space
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
forall a. Show a => a -> ShowS
shows String
x ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShowS
space ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> ShowS
forall a. Show a => a -> ShowS
shows Integer
n ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showsString ")"

showsQualIdent :: QualIdent -> ShowS
showsQualIdent :: QualIdent -> ShowS
showsQualIdent (QualIdent _ mident :: Maybe ModuleIdent
mident ident :: Ident
ident)
  = String -> ShowS
showsString "(QualIdent "
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ModuleIdent -> ShowS) -> Maybe ModuleIdent -> ShowS
forall a. (a -> ShowS) -> Maybe a -> ShowS
showsMaybe ModuleIdent -> ShowS
showsModuleIdent Maybe ModuleIdent
mident
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShowS
space
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ident -> ShowS
showsIdent Ident
ident
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showsString ")"

showsModuleIdent :: ModuleIdent -> ShowS
showsModuleIdent :: ModuleIdent -> ShowS
showsModuleIdent (ModuleIdent spi :: SpanInfo
spi ss :: [String]
ss)
  = String -> ShowS
showsString "(ModuleIdent "
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Position -> ShowS
showsPosition (SpanInfo -> Position
forall a. HasPosition a => a -> Position
getPosition SpanInfo
spi) ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShowS
space
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (String -> ShowS) -> [String] -> ShowS
forall a. (a -> ShowS) -> [a] -> ShowS
showsList ((String -> ShowS) -> String -> ShowS
forall a. (a -> ShowS) -> a -> ShowS
showsQuotes String -> ShowS
showsString) [String]
ss
  ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showsString ")"

showsQuotes :: (a -> ShowS) -> a -> ShowS
showsQuotes :: (a -> ShowS) -> a -> ShowS
showsQuotes sa :: a -> ShowS
sa a :: a
a
  = String -> ShowS
showsString "\"" ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> ShowS
sa a
a ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showsString "\""