Gotta update() expression too.

If type vars get into the espression you have to keep them in sync with
the unification or you can lose information.


Some combinators can put symbols on the expression, you have to convert
those to type checkers or, as a hack, just look them up and run them.
This lets definitions work(-ish), ...
This commit is contained in:
Simon Forman
2018-06-27 22:26:27 -07:00
parent fc45727008
commit 6ca59847ab
3 changed files with 72 additions and 31 deletions
+19 -3
View File
@@ -90,11 +90,27 @@ class TestCombinators(TestMixin, unittest.TestCase):
def test_nullary(self):
expression = n1, n2, (mul, s2), (stack, s3), dip, infra, first
f = [
(s1, (f1, (n1, (n2, s2)))), # (-- n2 n1 f1)
(s1, (i1, (n1, (n2, s2)))), # (-- n2 n1 i1)
(s1, (f1, (f2, (f3, s1)))), # (-- f3 f2 f1)
(s1, (f1, (f2, (i1, s1)))), # (-- i1 f2 f1)
(s1, (f1, (i1, (f2, s1)))), # (-- f2 i1 f1)
(s1, (i1, (i2, (i3, s1)))), # (-- i3 i2 i1)
]
self.assertEqualTypeStructure(infr(expression), f)
expression = n1, n2, (mul, s2), nullary
self.assertEqualTypeStructure(infr(expression), f)
def test_nullary_too(self):
expression = (stack, s3), dip, infra, first
f = ((s1, (a1, s2)), (a1, (a1, s2))) # (a1 [...1] -- a1 a1)
self.assertEqualTypeStructure(infr(expression), [f])
expression = nullary,
f = ((s1, (a1, s2)), (a1, (a1, s2))) # (a1 [...1] -- a1 a1)
# Something's not quite right here...
e = infr(expression)
self.assertEqualTypeStructure(infr(expression), [f])
def test_x(self):
expression = (a1, (swap, ((dup, s2), (dip, s0)))), x
f = (s0, ((a0, (swap, ((dup, s1), (dip, s2)))), (a1, (a1, s0))))
@@ -168,4 +184,4 @@ class TestYin(TestMixin, unittest.TestCase):
if __name__ == '__main__':
unittest.main()
unittest.main() #defaultTest='TestCombinators.test_nullary_too')