Skip to content

Commit 362fcfc

Browse files
author
Thomas Mahler
committed
simple stuff is working
1 parent 76c2a07 commit 362fcfc

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

src/CLTerm.hs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ module CLTerm
1717
import Parser (Expr(..))
1818
import Data.Data(Data)
1919

20-
data CL = Com Combinator | INT Integer | CL :@ CL deriving (Eq)
20+
data CL = Com Combinator | INT Integer | CL :@ CL deriving (Eq, Data)
2121

2222
instance Show CL where
2323
showsPrec :: Int -> CL -> ShowS
@@ -30,8 +30,6 @@ instance Show CL where
3030
toString (BulkCom c n) = c ++ show n
3131
toString c = show c
3232

33-
instance Data CL
34-
3533
type LeftAncestors = [CL]
3634

3735
leftAncestors :: CL -> LeftAncestors
@@ -45,7 +43,7 @@ leftAncestors clTerm = leftAncestors' clTerm []
4543
data Combinator = I | K | S | B | C | Y | P | R | ADD | SUB | MUL | DIV | REM | SUB1 | EQL | GEQ | ZEROP |
4644
A | B' | C' | S' | T |
4745
BulkCom String Int
48-
deriving (Eq, Show)
46+
deriving (Eq, Show, Data)
4947

5048
fromString :: String -> Combinator
5149
fromString "i" = I

src/TermReducer.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ reduce (Com B' :@ t :@ u :@ v) = t :@ (u :@ v)
3838
reduce (Com C' :@ t :@ u :@ v) = t :@ v :@ u
3939
reduce (Com S' :@ t :@ u :@ v) = (t :@ v) :@ (u :@ v)
4040
reduce (Com T :@ t) = t
41-
reduce x = error $ "not a known combinator: " ++ show x
41+
reduce x = x
42+
--reduce x = error $ "not a known combinator: " ++ show x
4243

4344

4445
red :: CL -> CL

test/TermReducerSpec.hs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ spec = do
2626
verify Simple.basicArithmetic
2727
it "computes basic comparison" $
2828
verify Simple.basicComparison
29-
-- it "computes basic boolean" $
30-
-- verify Simple.basicBoolean
29+
it "computes basic boolean" $
30+
verify Simple.basicBoolean
3131
it "computes basic subtraction" $
3232
verify Simple.basicSubtraction
3333
it "computes basic multiplication" $
@@ -43,7 +43,7 @@ spec = do
4343
it "computes simple composition" $
4444
verify simpleComposition
4545
-- it "computes Y combinator test" $
46-
-- verify simpleYCombinator
46+
-- verify simpleYCombinator
4747
-- it "computes simple fac (recursive)" $
4848
-- verify smallFactorial
4949

@@ -123,7 +123,10 @@ runTest src = do
123123
-- Capture result with timeout handling
124124
result <- catch
125125
(let actual = red aExp
126-
in return $ show expected == show actual)
126+
in do
127+
putStrLn $ "Expected: " ++ show expected
128+
putStrLn $ "Actual: " ++ show actual
129+
return $ show expected == show actual)
127130
(\e -> do
128131
putStrLn $ "Error during reduction: " ++ show (e :: SomeException)
129132
return False)

0 commit comments

Comments
 (0)