Skip to content

Commit

Permalink
Add Reducer for LazyK
Browse files Browse the repository at this point in the history
  • Loading branch information
kamil-adam committed May 14, 2024
1 parent 6197b6d commit 64cca7b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import scala.util.Right
object Reducer {
def reduce(f: ADTBT): ADTBTSafe = f match {
case Node(x, y) => applyM(reduce(x), reduce(y))
case x => Right(x)
case x => Right(x)
}

def applyM(fM: ADTBTSafe, xM: ADTBTSafe): ADTBTSafe =
Expand All @@ -32,8 +32,6 @@ object Reducer {
case _ => Right(Node(f, x))
}



private def succ(x: ADTBT) = x match {
case Leaf(ADT.Num(x)) => Right(Leaf(ADT.Num(x + Natural.one)))
case _ => Left(s"attempted to apply inc to a non-number $x")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,7 @@ class HaskellSpec extends TableDrivenPropertySpec {
(HelloWorld5, "`apply `\\a \\b (a) \\const `apply `(const const) \\main main"),
)

val programs: TableFor3[String, String, String] = Table(
("function", "input", "output"),
(Empty, "", ""),
(HelloWorld, "", ""),
(Factorial, "", ""),
)
val programs: TableFor3[String, String, String] = Table(("function", "input", "output"), (Empty, "", ""), (HelloWorld, "", ""), (Factorial, "", ""))

it should "parse sinpleFunctions and save lambda" in {
forAll(simpleFunctions) { (function, lambda) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,8 @@ class LambdaSpec extends TableDrivenPropertySpec {
("`a a", App(Var("a"), Var("a")), "`a a"),
("\\a `a a", Abs("a", App(Var("a"), Var("a"))), "``S I I"),
("\\a \\a a", Abs("a", Abs("a", Var("a"))), "`K I"),
(
"\\a \\b `a b",
Abs("a", Abs("b", App(Var("a"), Var("b")))),
"``S ``S `K S ``S `K K I `K I"
),
(
"\\a \\b `b a",
Abs("a", Abs("b", App(Var("b"), Var("a")))),
"``S `K `S I ``S `K K I"
),
("\\a \\b `a b", Abs("a", Abs("b", App(Var("a"), Var("b")))), "``S ``S `K S ``S `K K I `K I"),
("\\a \\b `b a", Abs("a", Abs("b", App(Var("b"), Var("a")))), "``S `K `S I ``S `K K I"),
)

val advancedLambda: TableFor3[String, String, String] = Table(
Expand Down

0 comments on commit 64cca7b

Please sign in to comment.