Send Beginners mailing list submissions to
        beginners@haskell.org

To subscribe or unsubscribe via the World Wide Web, visit
        http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
        beginners-requ...@haskell.org

You can reach the person managing the list at
        beginners-ow...@haskell.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1. Re:  A post about Currying and Partial    application
      (Petar Radosevic)
   2. Re:  A post about Currying and Partial    application
      (Chadda? Fouch?)
   3. Re:  A post about Currying and Partial    application (Rustom Mody)
   4. Re:  A post about Currying and Partial    application
      (Felipe Almeida Lessa)
   5. Re:  A post about Currying and Partial    application
      (Petar Radosevic)


----------------------------------------------------------------------

Message: 1
Date: Sat, 1 Oct 2011 14:40:15 +0200
From: Petar Radosevic <pe...@wunki.org>
Subject: Re: [Haskell-beginners] A post about Currying and Partial
        application
To: Peter Hall <peter.h...@memorphic.com>
Cc: beginners@haskell.org
Message-ID: <20111001124015.GA1240@wunki.local>
Content-Type: text/plain; charset=utf-8

Peter Hall wrote the following on Sat, Oct 01, 2011 at 10:49:31AM +0100:
> I think this sentence isn't right:
> 
> "Curried functions are functions that only take one parameter."
> 
> The way I understand it, a non-curried function takes only one
> parameter. Currying is syntactic sugar so you don't have to use
> higher-order functions every time you want multiple parameters.
> 
> Without currying, if you wanted a function like:
> 
>     f a b c = 2 * a + b - c
> 
> , you'd have to write it something like:
> 
>   f a = f1
>       where f1 b = f2
>           where f2 c = 2 * a + b - c
> 
> or
> 
>    f a = (\b -> (\c ->  2*a + b -c))

You are right, I changed the sentence to better reflect wat currying
really is. Thank you for your input.

-- 
Petar Rado?evi?, Programmer
wunki.org | @wunki



------------------------------

Message: 2
Date: Sun, 2 Oct 2011 00:48:31 +0200
From: Chadda? Fouch? <chaddai.fou...@gmail.com>
Subject: Re: [Haskell-beginners] A post about Currying and Partial
        application
To: Peter Hall <peter.h...@memorphic.com>, beginners@haskell.org
Message-ID:
        <CANfjZRbAg52X+Joeq5=bm6xekg6wg0odfrgvzhbxcqkqd8r...@mail.gmail.com>
Content-Type: text/plain; charset=UTF-8

On Sat, Oct 1, 2011 at 2:40 PM, Petar Radosevic <pe...@wunki.org> wrote:
> Peter Hall wrote the following on Sat, Oct 01, 2011 at 10:49:31AM +0100:
>> I think this sentence isn't right:
>>
>> "Curried functions are functions that only take one parameter."
>>
>> The way I understand it, a non-curried function takes only one
>> parameter. Currying is syntactic sugar so you don't have to use
>> higher-order functions every time you want multiple parameters.
>>
>> Without currying, if you wanted a function like:
>>
>> ? ? f a b c = 2 * a + b - c
>>
>> , you'd have to write it something like:
>>
>> ? f a = f1
>> ? ? ? where f1 b = f2
>> ? ? ? ? ? where f2 c = 2 * a + b - c
>>
>> or
>>
>> ? ?f a = (\b -> (\c -> ?2*a + b -c))
>
> You are right, I changed the sentence to better reflect wat currying
> really is. Thank you for your input.

Sorry but you are mistaken on the sense of currying. Basically to
curry the function f is to transform it from the type "(a,b) -> c" to
the type "a -> (b -> c)", in other words instead of function from a
cartesian product to a set, you get a function from the first element
of the product to the set of function from the second element of the
product to the original final set. This is a mathematical
transformation that Curry noted was always possible whatever the
function.
In a CS context, this transformation is only possible in languages
that handle functions as first-class data types, Haskell (or the ML
family) is only special in that it encourage you to write every
functions in an already curried style instead of the uncurried fashion
that is used in most other languages. Every single example you give in
your blog is curried, uncurried would be :

> sumTwo :: (Int,Int) -> Int
> sumTwo (x,y) = x + y

and

> f :: (Int,Int,Int) -> Int
> f (a,b,c) = 2 * a + b - c

See the function "curry" and "uncurry" to see that passing from one
style to another can be automated (though only elegantly for two
parameters).

Still it is true that currying functions ease the partial application
of function (at least if your parameters are ordered sensibly).

-- 
Jeda?



------------------------------

Message: 3
Date: Sun, 2 Oct 2011 08:34:22 +0530
From: Rustom Mody <rustompm...@gmail.com>
Subject: Re: [Haskell-beginners] A post about Currying and Partial
        application
To: beginners@haskell.org
Message-ID:
        <caj+teodlpweco4pzszyomfrdqhygh-z2jnu3jg27fmbuwvd...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

On Sun, Oct 2, 2011 at 4:18 AM, Chadda? Fouch? <chaddai.fou...@gmail.com>wrote:

> On Sat, Oct 1, 2011 at 2:40 PM, Petar Radosevic <pe...@wunki.org> wrote:
> > Peter Hall wrote the following on Sat, Oct 01, 2011 at 10:49:31AM +0100:
> >> I think this sentence isn't right:
> >>
> >> "Curried functions are functions that only take one parameter."
> >>
> >> The way I understand it, a non-curried function takes only one
> >> parameter. Currying is syntactic sugar so you don't have to use
> >> higher-order functions every time you want multiple parameters.
> >>
> >> Without currying, if you wanted a function like:
> >>
> >>     f a b c = 2 * a + b - c
> >>
> >> , you'd have to write it something like:
> >>
> >>   f a = f1
> >>       where f1 b = f2
> >>           where f2 c = 2 * a + b - c
> >>
> >> or
> >>
> >>    f a = (\b -> (\c ->  2*a + b -c))
> >
> > You are right, I changed the sentence to better reflect wat currying
> > really is. Thank you for your input.
>
> Sorry but you are mistaken on the sense of currying. Basically to
> curry the function f is to transform it from the type "(a,b) -> c" to
> the type "a -> (b -> c)", in other words instead of function from a
> cartesian product to a set, you get a function from the first element
> of the product to the set of function from the second element of the
> product to the original final set. This is a mathematical
> transformation that Curry noted was always possible whatever the
> function.
> In a CS context, this transformation is only possible in languages
> that handle functions as first-class data types, Haskell (or the ML
> family) is only special in that it encourage you to write every
> functions in an already curried style instead of the uncurried fashion
> that is used in most other languages. Every single example you give in
> your blog is curried, uncurried would be :
>
> > sumTwo :: (Int,Int) -> Int
> > sumTwo (x,y) = x + y
>
> and
>
> > f :: (Int,Int,Int) -> Int
> > f (a,b,c) = 2 * a + b - c
>
>
How would you classify a function of type (Int, Int) -> Int -> Int ?
Likewise if we have a polymorphic foo: Int -> a and we instantiate a to Int
-> Int  does foo suddenly get curried?

Which is why it may be better to say this?
Curried and uncurried function are vague ideas, whereas the action of
currying and uncurrying -- as embodied in the standard prelude curry and
uncurry -- are precise and well-defined

See the function "curry" and "uncurry" to see that passing from one
> style to another can be automated (though only elegantly for two
> parameters).
>
> Still it is true that currying functions ease the partial application
> of function (at least if your parameters are ordered sensibly).
>
> --
> Jeda?
>
> _______________________________________________
> Beginners mailing list
> Beginners@haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20111002/61f81bb7/attachment-0001.htm>

------------------------------

Message: 4
Date: Sun, 2 Oct 2011 00:30:02 -0300
From: Felipe Almeida Lessa <felipe.le...@gmail.com>
Subject: Re: [Haskell-beginners] A post about Currying and Partial
        application
To: Rustom Mody <rustompm...@gmail.com>
Cc: beginners@haskell.org
Message-ID:
        <CANd=oggkpumcaocxpknvimlxn2vuvhweboy1g1wggyn2zkc...@mail.gmail.com>
Content-Type: text/plain; charset=UTF-8

On Sun, Oct 2, 2011 at 12:04 AM, Rustom Mody <rustompm...@gmail.com> wrote:
> How would you classify a function of type (Int, Int) -> Int -> Int ?

It's curried.  Uncurried would be:

  ((Int, Int), Int) -> Int

> Likewise if we have a polymorphic foo: Int -> a and we instantiate a to Int
> -> Int? does foo suddenly get curried?

Int -> a is both curried and uncurried.  Int -> Int -> Int is just curried.

-- 
Felipe.



------------------------------

Message: 5
Date: Sun, 2 Oct 2011 10:25:22 +0200
From: Petar Radosevic <pe...@wunki.org>
Subject: Re: [Haskell-beginners] A post about Currying and Partial
        application
To: beginners@haskell.org
Message-ID: <20111002082522.GA1068@wunki-mac-pro.local>
Content-Type: text/plain; charset="utf-8"

Chadda? Fouch? wrote the following on Sun, Oct 02, 2011 at 12:48:31AM +0200:
> On Sat, Oct 1, 2011 at 2:40 PM, Petar Radosevic <pe...@wunki.org> wrote:
> > Peter Hall wrote the following on Sat, Oct 01, 2011 at 10:49:31AM +0100:
> >> I think this sentence isn't right:
> >>
> >> "Curried functions are functions that only take one parameter."
> >>
> >> The way I understand it, a non-curried function takes only one
> >> parameter. Currying is syntactic sugar so you don't have to use
> >> higher-order functions every time you want multiple parameters.
> >>
> >> Without currying, if you wanted a function like:
> >>
> >> ? ? f a b c = 2 * a + b - c
> >>
> >> , you'd have to write it something like:
> >>
> >> ? f a = f1
> >> ? ? ? where f1 b = f2
> >> ? ? ? ? ? where f2 c = 2 * a + b - c
> >>
> >> or
> >>
> >> ? ?f a = (\b -> (\c -> ?2*a + b -c))
> >
> > You are right, I changed the sentence to better reflect wat currying
> > really is. Thank you for your input.
> 
> Sorry but you are mistaken on the sense of currying. Basically to
> curry the function f is to transform it from the type "(a,b) -> c" to
> the type "a -> (b -> c)", in other words instead of function from a
> cartesian product to a set, you get a function from the first element
> of the product to the set of function from the second element of the
> product to the original final set. This is a mathematical
> transformation that Curry noted was always possible whatever the
> function.
> In a CS context, this transformation is only possible in languages
> that handle functions as first-class data types, Haskell (or the ML
> family) is only special in that it encourage you to write every
> functions in an already curried style instead of the uncurried fashion
> that is used in most other languages. Every single example you give in
> your blog is curried, uncurried would be :
> 
> > sumTwo :: (Int,Int) -> Int
> > sumTwo (x,y) = x + y
> 
> and
> 
> > f :: (Int,Int,Int) -> Int
> > f (a,b,c) = 2 * a + b - c
> 
> See the function "curry" and "uncurry" to see that passing from one
> style to another can be automated (though only elegantly for two
> parameters).
> 
> Still it is true that currying functions ease the partial application
> of function (at least if your parameters are ordered sensibly).

Thank you for your explanation. I was also corrected on reddit[1] on the
matter. Since my post is wrong on the subject I have decided chuck it
and write a new one. I'm collecting all the comments people made as we
speak and am going to make good use of them in a post which hopefully
_does_ explain currying.

[1]: 
http://www.reddit.com/r/haskell/comments/kxdh7/curry_and_its_partial_application/

-- 
Petar Rado?evi?, Programmer
wunki.org | @wunki
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 833 bytes
Desc: Signature of Petar Radosevic
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20111002/9da169e7/attachment-0001.pgp>

------------------------------

_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://www.haskell.org/mailman/listinfo/beginners


End of Beginners Digest, Vol 40, Issue 2
****************************************

Reply via email to