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

Type checker cryptic erro on foldl #207

Open
anton-k opened this issue Nov 27, 2020 · 4 comments
Open

Type checker cryptic erro on foldl #207

anton-k opened this issue Nov 27, 2020 · 4 comments

Comments

@anton-k
Copy link
Contributor

anton-k commented Nov 27, 2020

 > foldl (\a as -> [a] ++ as) [] [1,2,3]
<repl>:1:17: Occurs error [a]
@anton-k
Copy link
Contributor Author

anton-k commented Nov 27, 2020

ghci says that it can not construct infinite type here

@Shimuuar
Copy link
Contributor

Nothing cryptic. Occurs check prevents construction of inifinite types

foldl ::  (b -> a -> b) -> b -> [a] -> b
(\a as -> [a] ++ as) :: c -> [c] -> [c]

thus unification foldl (\a as -> [a] ++ as) produces set of equations:

c ~ b 
a ~ [c]
b ~ [c]

From what we generate equation b ~ [b] which means b is infinite type. Occurs check prevents construction of such types

@anton-k
Copy link
Contributor Author

anton-k commented Nov 27, 2020

Ok, but it's better write it out in this way.

@anton-k
Copy link
Contributor Author

anton-k commented Nov 27, 2020

It's issue for better report of error of this type

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants