Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Foldr does not unify types correctly #16

Open
billpmurphy opened this issue Aug 5, 2015 · 0 comments
Open

Foldr does not unify types correctly #16

billpmurphy opened this issue Aug 5, 2015 · 0 comments
Labels

Comments

@billpmurphy
Copy link
Owner

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)
@billpmurphy billpmurphy added the bug label Aug 5, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant