Blnpwr
Blnpwr

Reputation: 1875

Curry in Haskell

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 !

Upvotes: 0

Views: 144

Answers (1)

leftaroundabout
leftaroundabout

Reputation: 120711

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.

Upvotes: 3

Related Questions