11from returns .result import Result , Success , Failure
22from funcy import lmap
33from 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
77def _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
6157def 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