1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
module FlatCurry.Print
where
import FlatCurry.Goodies
import FlatCurry.Pretty as FCP
import FlatCurry.Types
import Text.Pretty ( Doc, (<+>), align, pPrint, text )
showFlatProg :: Prog -> String
showFlatProg = pPrint . ppProg defaultOptions { qualMode = QualNone}
showTypeExp :: TypeExpr -> String
showTypeExp = pPrint . ppTypeExp
ppTypeExp :: TypeExpr -> Doc
ppTypeExp = FCP.ppTypeExp defaultOptions { qualMode = QualNone}
showBindExp :: Int -> Expr -> String
showBindExp bv e = pPrint $ text ('v' : show bv ++ " |-> ") <+> align (ppExp e)
showExp :: Expr -> String
showExp = pPrint . ppExp
ppExp :: Expr -> Doc
ppExp = FCP.ppExp defaultOptions { qualMode = QualNone}
showFuncDecl :: FuncDecl -> String
showFuncDecl =
pPrint . ppFuncDecl defaultOptions { qualMode = QualNone}
showFuncDeclAsLambda :: FuncDecl -> String
showFuncDeclAsLambda fdecl =
let rule = funcRule fdecl
in '\\' : unwords (map (\i -> 'v' : show i) (ruleArgs rule)) ++
" -> " ++ showExp (ruleBody rule)
|