Skip to content

Commit f5546b8

Browse files
thmathma
authored andcommitted
identify bug in babs
1 parent 0ebc26a commit f5546b8

File tree

5 files changed

+6
-7
lines changed

5 files changed

+6
-7
lines changed

app/Main.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ loadTestCase name = do
6060
putStrLn "The source: "
6161
putStrLn src
6262
let pEnv = parseEnvironment src
63-
expr = compile pEnv abstractSimple
63+
expr = compile pEnv abstractToSKI
6464
return expr
6565

6666
graphReductionDemo :: IO Expr -> IO ()

benchmark/ReductionBenchmarks.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module ReductionBenchmarks where
22

33
import Criterion.Main ( defaultMain, bench, nf )
44
import Parser ( parseEnvironment, Expr(Int) )
5-
import LambdaToSKI ( abstractSimple, compile )
5+
import LambdaToSKI ( abstractToSKI, compile )
66
import GraphReduction ( allocate, normalForm, toString, Graph )
77
import Data.Maybe (fromJust)
88
import Data.STRef ( STRef )
@@ -16,7 +16,7 @@ loadTestCase :: String -> IO Expr
1616
loadTestCase name = do
1717
src <- readFile $ "test/" ++ name ++ ".ths"
1818
let pEnv = parseEnvironment src
19-
expr = compile pEnv abstractSimple
19+
expr = compile pEnv abstractToSKI
2020
return expr
2121

2222
getInt :: Expr -> Integer

src/LambdaToSKI.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import Parser (Environment, Expr (..))
1717

1818
type Error = String
1919

20-
-- @TODO There must be a subtle bug in here. (tak 12 6 3) won't work with this abstraction
2120
babs :: Environment -> Expr -> Expr
2221
babs env (Lam x e)
2322
| Var "i" :@ _x <- t = t
@@ -27,7 +26,7 @@ babs env (Lam x e)
2726
| m :@ Var y <- t, x == y, x `notElem` fv [] m = m
2827
| Var y :@ m :@ Var z <- t, x == y, x == z = babs env $ Lam x $ Var "s" :@ Var "s" :@ Var "k" :@ Var x :@ m
2928
| m :@ (n :@ l) <- t, isComb m, isComb n = babs env $ Lam x $ Var "s" :@ Lam x m :@ n :@ l
30-
| (m :@ n) :@ l <- t, isComb m, isComb l = babs env $ Lam x $ Var "s" :@ m :@ Lam x l :@ n
29+
-- | (m :@ n) :@ l <- t, isComb m, isComb l = babs env $ Lam x $ Var "s" :@ m :@ Lam x l :@ n -- this line is buggy (endless loop for tak)
3130
| (m :@ l) :@ (n :@ l') <- t,
3231
l `noLamEq` l',
3332
isComb m,

test/GraphReductionSpec.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ getInt _ = error "not an int"
4646
runTest :: SourceCode -> (String, String)
4747
runTest src =
4848
let pEnv = parseEnvironment src
49-
expr = compile pEnv abstractSimple
49+
expr = compile pEnv abstractToSKI
5050
graph = allocate expr
5151
expected = show $ getInt $ fromJust (lookup "expected" pEnv)
5252
result = reduceGraph graph

test/ReducerSpec.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ loadTestCase name = readFile $ "test/" ++ name ++ ".ths"
4040
runTest :: SourceCode -> Bool
4141
runTest src =
4242
let pEnv = parseEnvironment src
43-
aExp = compile pEnv abstractSimple
43+
aExp = compile pEnv abstractToSKI
4444
tExp = translate aExp
4545
expected = translate $ fromJust (lookup "expected" pEnv)
4646
actual = link primitives tExp

0 commit comments

Comments
 (0)