Foldr does not unify types correctly
Opened this issue · 0 comments
billpmurphy commented
Somethis is not quite right with the way the list type is being unified, as seen here when using foldr
with cons:
>>> from hask import *
>>> import hask.Data.List as DL
>>> cons = (lambda x, y: x ^ y) ** (H/ "a" >> ["a"] >> ["a"])
>>> _t(cons)
'(a -> ([a] -> [a]))'
>>> DL.foldr(cons, L[[]], L[[1, 2, 3]])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "hask/lang/type_system.py", line 362, in __call__
result_type = analyze(ap, env)
File "hask/lang/hindley_milner.py", line 216, in analyze
unify(Function(arg_type, result_type), fun_type)
File "hask/lang/hindley_milner.py", line 349, in unify
unify(p, q)
File "hask/lang/hindley_milner.py", line 349, in unify
unify(p, q)
File "hask/lang/hindley_milner.py", line 347, in unify
raise TypeError("Type mismatch: {0} != {1}".format(str(a), str(b)))
TypeError: Type mismatch: int != ([] e)