hexresearch / hschain-utxo

UTXO-based contracts for hschain
0 stars 0 forks source link

Type checker cryptic erro on foldl #207

Open anton-k opened 3 years ago

anton-k commented 3 years ago
 > foldl (\a as -> [a] ++ as) [] [1,2,3]
<repl>:1:17: Occurs error [a]
anton-k commented 3 years ago

ghci says that it can not construct infinite type here

Shimuuar commented 3 years ago

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 commented 3 years ago

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

anton-k commented 3 years ago

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