Skip to content

Commit fb99ad6

Browse files
committed
ghc prover remove standalone type class
1 parent 7032a3e commit fb99ad6

2 files changed

Lines changed: 16 additions & 15 deletions

File tree

src/tfbench/ghc.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@ def ghc_prove_equiv(code: str) -> Result[None, str]:
5454
5555
$new_types
5656
57-
$new_type_classes
58-
5957
type TRUTH $truth_vars = $truth_signature
6058
type ANSWER $answer_vars = $answer_signature
6159
@@ -102,7 +100,6 @@ def get_prover(
102100
answer = reorder_constraints(answer)
103101
return PROVER.substitute(
104102
new_types="\n".join(types_defs),
105-
new_type_classes="", # todo: support new type classes
106103
truth_vars=_get_var_str(ground_truth),
107104
truth_signature=_get_body_str(ground_truth),
108105
answer_vars=_get_var_str(answer),

tests/test_ghc_pure.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from returns.result import Result, Success, Failure
22
from funcy import lmap
33
from tfbench.ghc import ghc_prove_equiv, get_prover, reorder_constraints
4-
from tfbench.type_def import def_new_type, def_new_type_class
4+
from tfbench.type_def import def_new_type, def_new_type_constructor
55

66

77
def _equiv(
@@ -10,11 +10,7 @@ def _equiv(
1010
new_types: list[str] | None = None,
1111
should_pass: bool = True,
1212
):
13-
equiv = (
14-
get_prover(truth, answer, lmap(def_new_type, new_types))
15-
.alt(str)
16-
.bind(ghc_prove_equiv)
17-
)
13+
equiv = get_prover(truth, answer, new_types or []).alt(str).bind(ghc_prove_equiv)
1814
match equiv:
1915
case Success(_):
2016
assert should_pass
@@ -34,30 +30,38 @@ def test_mono():
3430
"""test GHC type equivalence prover for monomorphic types after rewriting"""
3531
# check with type after rewriting,
3632
# i.e. T1, ... T_n
37-
_equiv("f:: T1-> T1", "g ::T1 -> T1", new_types=["T1"])
33+
_equiv("f:: T1-> T1", "g ::T1 -> T1", new_types=[def_new_type("T1")])
3834
_not_equiv(
3935
"f:: T1-> T1",
4036
"g ::T2 -> T2",
41-
new_types=["T1", "T2"],
37+
new_types=lmap(def_new_type, ["T1", "T2"]),
4238
)
4339

4440
_equiv(
4541
"f:: (T1, T2) -> T1",
4642
"g ::(T1, T2) -> T1",
47-
new_types=["T1", "T2"],
43+
new_types=lmap(def_new_type, ["T1", "T2"]),
4844
)
4945
_equiv(
5046
"f:: (Int, T2) -> Int",
5147
"g ::(Int, T2) -> Int",
52-
new_types=["T2"],
48+
new_types=lmap(def_new_type, ["T2"]),
5349
)
5450
_not_equiv(
5551
"f:: (Int, T2) -> Int",
5652
"g ::(Int, T2) -> T2",
57-
new_types=["T2"],
53+
new_types=lmap(def_new_type, ["T2"]),
5854
)
5955

6056

6157
def test_typeclass_in_body():
6258
f = "f :: T1 -> T2 T3"
63-
_equiv(f, f)
59+
_equiv(
60+
f,
61+
f,
62+
new_types=[
63+
def_new_type("T1"),
64+
def_new_type("T3"),
65+
def_new_type_constructor("T2", ["a"]),
66+
],
67+
)

0 commit comments

Comments
 (0)