[Haskell-cafe] Would you mind explain such a code ?

Sean Leather leather at cs.uu.nl
Thu Sep 10 09:22:45 EDT 2009


On Thu, Sep 10, 2009 at 14:43, Peter Verswyvelen wrote:

> On Thu, Sep 10, 2009 at 11:47 AM, Roman Cheplyaka 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)
>
>
> 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?
>

In some functional programming languages, these are not equivalent. For
example, Clean does not have currying, so

  f :: Int Int -> Int
  f x y = x + y

is not the same as

  f :: Int -> Int -> Int
  f x = (+) x

Notice the difference in types. The first is more like 'f :: (Int, Int) ->
Int' in Haskell.

Sean
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090910/b9f37c3f/attachment.html


More information about the Haskell-Cafe mailing list