Skip to content

Commit 8189214

Browse files
committed
almost there
1 parent 190151f commit 8189214

File tree

2 files changed

+132
-54
lines changed

2 files changed

+132
-54
lines changed

app/Main.hs

+10-7
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ fibonacci = [r|
6969
|]
7070

7171

72+
printCS :: CL -> IO ()
73+
printCS cl = putStrLn ("code size: " ++ show (codeSize cl))
74+
7275
-- data CL = Com Combinator | INT Integer | CL :@ CL
7376
codeSize :: CL -> Int
7477
codeSize (Com _) = 1
@@ -87,43 +90,43 @@ showCompilations source = do
8790
let expr = compileBracket env
8891
putStrLn "The main expression compiled to SICKBY combinator expressions by recursice bracket abstraction:"
8992
print expr
90-
print $ codeSize expr
93+
printCS expr
9194
putStrLn ""
9295

9396
putStrLn "applying plain Kiselyov compilation:"
9497
print $ compilePlain env
95-
print $ codeSize $ compilePlain env
98+
printCS $ compilePlain env
9699
putStrLn ""
97100

98101
let exprK = compileK env
99102
putStrLn "The main expression compiled to SICKBY combinator expressions with K-optimization:"
100103
print exprK
101-
print $ codeSize exprK
104+
printCS exprK
102105
putStrLn ""
103106

104107

105108
let expr' = compileEta env
106109
putStrLn "The main expression compiled to SICKBY combinator expressions with Eta-optimization:"
107110
print expr'
108-
print $ codeSize expr'
111+
printCS expr'
109112
putStrLn ""
110113

111114
let expr'' = compileBulk env
112115
putStrLn "The main expression compiled to SICKBY combinator expressions with bulk combinators:"
113116
print expr''
114-
print $ codeSize expr''
117+
printCS expr''
115118
putStrLn ""
116119

117120
let expr''' = compileBulkLinear env
118121
putStrLn "The main expression compiled to SICKBY combinator expressions with bulk combinators and linear elimination:"
119122
print expr'''
120-
print $ codeSize expr'''
123+
printCS expr'''
121124
putStrLn ""
122125

123126
let expr'''' = compileBulkLog env
124127
putStrLn "The main expression compiled to SICKBY combinator expressions with bulk combinators and logarithmic elimination:"
125128
print expr''''
126-
print $ codeSize expr''''
129+
printCS expr''''
127130
putStrLn ""
128131

129132

0 commit comments

Comments
 (0)