Hello can someone explain to me why this custom implementaiton of foldl is not in scope?
afold::(a->b->a)->a->[b]->a
afold tsf accu (x:xs)=afold tsf (tsf accu x) xs
afold _ accu []=accu
I've tried running it like this :
afold (\x y-> show y:x) [] [1,2,3,4]
and i get the error:
Variable not in scope:
afold :: ([String] -> () -> [String]) -> [a0] -> [Integer] -> t
When i try to use it even simpler like this :
afold (\x y-> x+y) 0 [1,2,3,4]
i get the error:
:: (Integer -> Integer -> Integer) -> Integer -> [Integer] -> t
Why isn't the output inferred?Why is it still t
in the second example?
afold
and where are you trying to run it? The "Not in scope" error is because it cannot findafold
at all. As Carl said, the type section of that error is not very significant (in this particular context).:: (Integer -> Integer -> Integer) -> (...)
isn't an error, that's a type signature. Could you actually write the full, unedited error?