问题描述:

as you know the foldl function is defined as :

 foldl :: (a -> b -> a ) -> a -> [b] -> a

I want to rewrite the function as an uncurrified function

I tried this one:

 foldl :: ( (a-> b-> a) , a , [b] ) -> a

Is that correct? Maybe it is not important to uncurry but I am gonna write an exam and I am pretty sure this will be one of the tasks to do.

Thanks in anticipation !

网友答案:

Well, that sure is an uncurried form of foldl. However, there a more levels on which you can do this – what I'd can the "fully uncurried form" would be

foldl'' :: ( ((a,b) -> a), a, [b] ) -> a

where not just the function itself but also its function argument is uncurried. OTOH, just calling uncurry on the function would yield merely

foldl''' :: ( (a->b->a), a ) -> [b] -> a

which might thus also be called "uncurried foldl", though it would certainly not be the desired interpretation in an exam.

相关阅读:
Top