While we can unify namedtuples with the same structure, reify returns a tuple when passed a namedtuple:
from typing import NamedTuple
from unification import unify, reify
class Test(NamedTuple):
a: int
b: int
test1 = Test(1, 4)
test2 = Test(var(), var())
res = unify(test1, test2)
print(res)
reified = reify(test2, res)
print(reified)
# (1, 4)
Trying to access elements by name obviously fails:
We would expect reify to return a namedtuple with the same structure instead.
While we can unify namedtuples with the same structure,
reifyreturns a tuple when passed a namedtuple:Trying to access elements by name obviously fails:
We would expect
reifyto return a namedtuple with the same structure instead.