[Haskell-cafe] Would you mind explain such a code ?
Roman Cheplyaka
roma at ro-che.info
Thu Sep 10 09:22:02 EDT 2009
* Peter Verswyvelen <bugfact at gmail.com> [2009-09-10 14:43:10+0200]
> On Thu, Sep 10, 2009 at 11:47 AM, Roman Cheplyaka <roma at ro-che.info> wrote:
> > step x g a = g (f a x)
> >
> > is, thanks to currying, another way to write
> >
> > step x g = \a -> g (f a x)
>
> I thought currying just meant
>
> curry f x y = f (x,y)
Here you use 'currying' meaning the process of applying the 'curry'
operation, i.e. transforming 'uncurried' function to a 'curried' one.
(BTW, Wikipedia agrees with you.)
> Isn't the reason that
>
> f x y z = body
>
> is the same as
>
> f = \x -> \y -> \z -> body
>
> just cause the former is syntactic sugar of the latter?
Technically, yes.
Generally speaking, currying is the idea of interchangeability of
the function which takes several arguments and the function which
returns another function (i.e. what is used here).
--
Roman I. Cheplyaka :: http://ro-che.info/
"Don't let school get in the way of your education." - Mark Twain
More information about the Haskell-Cafe
mailing list