Implement `idBetaReducible` to support the `reduce` example.
Chris Pressey
3 years ago
76 | 76 |
--
|
77 | 77 |
|
78 | 78 |
beta t = destruct t
|
79 | |
(\n -> var n)
|
80 | |
(\u v -> destruct u
|
81 | |
(\_ -> app u v)
|
82 | |
(\_ _ -> app u v)
|
83 | |
(\u -> resolve u v)
|
84 | |
)
|
85 | |
(\u -> u)
|
|
79 |
(\n -> var n)
|
|
80 |
(\u v -> destruct u
|
|
81 |
(\_ -> app u v)
|
|
82 |
(\_ _ -> app u v)
|
|
83 |
(\u -> resolve u v)
|
|
84 |
)
|
|
85 |
(\u -> u)
|
86 | 86 |
|
87 | 87 |
testBeta1 = (show $ beta testApp) == "FreeVar \"n\""
|
88 | 88 |
testBeta2 = (show $ beta testAbs) == "Abs (BoundVar 0)"
|
|
89 |
testBeta3 = (show $ beta (var "j")) == "FreeVar \"j\""
|
|
90 |
|
|
91 |
isBetaReducible t = destruct t
|
|
92 |
(\n -> False)
|
|
93 |
(\u v -> destruct u
|
|
94 |
(\_ -> False)
|
|
95 |
(\_ _ -> False)
|
|
96 |
(\u -> True)
|
|
97 |
)
|
|
98 |
(\u -> False)
|
|
99 |
|
|
100 |
testIsBeta1 = (isBetaReducible testApp) == True
|
|
101 |
testIsBeta2 = (isBetaReducible testAbs) == False
|
|
102 |
testIsBeta3 = (isBetaReducible (var "j")) == False
|