[Haskell-beginners] understanding curried function calls

Dimitri DeFigueiredo defigueiredo at ucdavis.edu
Wed Aug 20 16:31:46 UTC 2014


This is exactly what I did, but it doesn't give me a systematic way to 
evaluate the expressions.
In other words, I don't really know why it works or what else to try in 
different circumstances.
The problem arises when I have curried multi-argument functions.

People complain about pointer notation in type declarations in C. Well, 
this is pointer notation++.
And it is worse if I can't find resources to learn it.

Eventually, I would like to be able to grok famous beasts like this one.

foldl  ::  (a->  b->  a)  ->  a->  [b]  ->  a
foldl  f a bs=
    foldr  (\b g x->  g(f x b))  id  bs a

But I need a consistent approach.


Cheers,


Dimitri


Em 20/08/14 04:10, John Wiegley escreveu:
>>>>>> Dimitri DeFigueiredo <defigueiredo at ucdavis.edu> writes:
>> Here's a simple exercise from Stephanie Weirich's class [1] that I am having
>> a hard time with.
>> consider
>> doTwice :: (a -> a) -> a -> a
>> doTwice f x = f (f x)
>> what does this do?
>> ex1 :: (a -> a) -> a -> a
>> ex1 = doTwice doTwice
> Another way to write doTwice is:
>
>      doTwice :: (a -> a) -> (a -> a)
>      doTwice f = \x -> f (f x)
>
> This is equivalent.  If you stare it for a while, it should answer the rest of
> your questions.
>
> John
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20140820/10e7ff8c/attachment.html>


More information about the Beginners mailing list