Ah, thanks for the correction. So if I understand it correctly, this is currying:
when f :: (a,b) -> c then g :: a -> (b,c) is the curried form of f? So currying has to do with tuples? And partial application is just leaving away some tail arguments? >----- Oorspronkelijk bericht ----- >Van: Jules Bean [mailto:[hidden email]] >Verzonden: dinsdag, juli 3, 2007 12:19 PM >Aan: 'peterv' >CC: [hidden email] >Onderwerp: Re: [Haskell-cafe] Haskell's "partial application" (not currying!) versus Business Objects Gem Cutter's "burning" > >peterv wrote: >> In Haskell, currying can only be done on the last (rightmost) function >> arguments. > > >You are talking about partial application, not currying. > >> foo x y >> >> can be curried as >> >> foo x >> >> but not as >> >> foo ? y >> >> where ? would be a “wilcard” for the x parameter. > >(\x -> foo x y) > >[snip] > >> This burning looks more general to me, but cannot be done using the >> textual approach? > >Well, it can be done, but basically there are two issues: > >1. You need to demarquate the 'scope' of the ?. What 'lump' of >expression is the partially evaluated part. An obvious way to do this is >with parentheses, but you have to be careful. > >2. If you have more than one ?, you need to remember which is which. >Think of nested expressions, nested ?s. What if you want to use the >'same' ? more than once? > >The solution that haskell chooses to (2) is to 'label' the ?s with >names. The solution to (1) is to mark the scope with a \, and the list >of names bound: > >\x z -> foo (foo x y) z > >Jules > > > > _______________________________________________ Haskell-Cafe mailing list [hidden email] http://www.haskell.org/mailman/listinfo/haskell-cafe |
Peter Verswyvelen wrote:
> Ah, thanks for the correction. So if I understand it correctly, this is currying: > > when > > f :: (a,b) -> c > > then > > g :: a -> (b,c) > > is the curried form of f? So currying has to do with tuples? g :: a -> b -> c (also could be written as g :: a -> (b -> c) ) is the curried form of f. Curry has to do with the isomorphism between tuples, and functions-returning-functions. > > And partial application is just leaving away some tail arguments? Depending how generally you want to construe it; you might say "partial application is leaving off tail arguments" or "partial application is leaving off some arguments". Currying makes partial application "easier". Jules _______________________________________________ Haskell-Cafe mailing list [hidden email] http://www.haskell.org/mailman/listinfo/haskell-cafe |
In reply to this post by bf3
On Tue, 3 Jul 2007, Peter Verswyvelen wrote: > Ah, thanks for the correction. So if I understand it correctly, this is currying: > > when > > f :: (a,b) -> c > > then > > g :: a -> (b,c) > > is the curried form of f? No it is g :: a -> b -> c g = curry f > So currying has to do with tuples? Yes. > And partial application is just leaving away some tail arguments? Indeed. _______________________________________________ Haskell-Cafe mailing list [hidden email] http://www.haskell.org/mailman/listinfo/haskell-cafe |
In reply to this post by bf3
On Tue, Jul 03, 2007 at 10:53:33AM +0000, Peter Verswyvelen wrote:
> Ah, thanks for the correction. So if I understand it correctly, this is currying: > > when > > f :: (a,b) -> c > > then > > g :: a -> (b,c) g :: a->b->c > > is the curried form of f? So currying has to do with tuples? > > And partial application is just leaving away some tail arguments? > _______________________________________________ Haskell-Cafe mailing list [hidden email] http://www.haskell.org/mailman/listinfo/haskell-cafe |
In reply to this post by bf3
On Tue, 3 Jul 2007, Peter Verswyvelen wrote: > Ah, thanks for the correction. So if I understand it correctly, this is currying: See also: http://haskell.org/haskellwiki/Currying http://haskell.org/haskellwiki/Partial_application and more generally: http://haskell.org/haskellwiki/Category:Glossary _______________________________________________ Haskell-Cafe mailing list [hidden email] http://www.haskell.org/mailman/listinfo/haskell-cafe |
Duh, I made a typo in my previous emails, I did mean a -> (b -> c) and not a -> (b,c). But you guys quickly corrected that
IMHO when reading http://haskell.org/haskellwiki/Currying a newbie like me cannot see the difference between currying and partial application... I quote the text: -------------------- "Currying is the process of transforming a function that takes multiple arguments into a function that takes just a single argument and returns another function if any arguments are still needed. In Haskell, all functions are considered curried: that is, all functions in Haskell take just single arguments. This is mostly hidden in notation, and so may not be apparent to a new Haskeller. Let's take the function div :: Int -> Int -> Int which performs integer division. The expression div 11 2 unsurprisingly evaluates to 5. But there's more that's going on than immediately meets the untrained eye. It's a two-part process. First, div 11 is evaluated and returns a function of type Int -> Int" -------------------- But that is partial application, not currying no... Later in the text tuples are mentioned, but the real definition of currying being -- Hope I get it right this time... curry :: ((a, b) -> c) -> a -> b -> c is not really clear from the article to me... >----- Oorspronkelijk bericht ----- >Van: Henning Thielemann [mailto:[hidden email]] >Verzonden: dinsdag, juli 3, 2007 01:48 PM >Aan: 'Peter Verswyvelen' >CC: [hidden email] >Onderwerp: Re: [Haskell-cafe] Haskell's currying and partial application > > >On Tue, 3 Jul 2007, Peter Verswyvelen wrote: > >> Ah, thanks for the correction. So if I understand it correctly, this is currying: > >See also: > http://haskell.org/haskellwiki/Currying > http://haskell.org/haskellwiki/Partial_application > >and more generally: > http://haskell.org/haskellwiki/Category:Glossary > > _______________________________________________ Haskell-Cafe mailing list [hidden email] http://www.haskell.org/mailman/listinfo/haskell-cafe |
On Tue, 3 Jul 2007, Peter Verswyvelen wrote: > IMHO when reading > > http://haskell.org/haskellwiki/Currying > > a newbie like me cannot see the difference between currying and partial application... Better now? _______________________________________________ Haskell-Cafe mailing list [hidden email] http://www.haskell.org/mailman/listinfo/haskell-cafe |
Henning Thielemann wrote:
> On Tue, 3 Jul 2007, Peter Verswyvelen wrote: > >> IMHO when reading >> >> http://haskell.org/haskellwiki/Currying >> >> a newbie like me cannot see the difference between currying and partial application... > > Better now? Much better, IMO, although I still don't like the part with four examples of sections. Sure, sections are cool but they have nothing much to do with currying. Even if our binary operators were defined uncurried, we could have identical syntactic sugar for sections... Jules _______________________________________________ Haskell-Cafe mailing list [hidden email] http://www.haskell.org/mailman/listinfo/haskell-cafe |
In reply to this post by Henning Thielemann
Much better. Although I struggle a bit with the exercises ;)
Let's see id :: a -> a curry :: ((a,b) -> c) -> a -> b -> c => curry id :: ((a,b) -> (a,b)) -> a -> b -> (a,b) So basically if f = curry id then f x y = (x,y) which means curry id = (,) something like this? Do I win a price now? ;) -----Original Message----- From: Henning Thielemann [mailto:[hidden email]] Sent: Tuesday, July 03, 2007 3:21 PM To: Peter Verswyvelen Cc: [hidden email] Subject: Re: [Haskell-cafe] Haskell's currying and partial application On Tue, 3 Jul 2007, Peter Verswyvelen wrote: > IMHO when reading > > http://haskell.org/haskellwiki/Currying > > a newbie like me cannot see the difference between currying and partial application... Better now? _______________________________________________ Haskell-Cafe mailing list [hidden email] http://www.haskell.org/mailman/listinfo/haskell-cafe |
On Tue, 3 Jul 2007, Peter Verswyvelen wrote: > Let's see > > id :: a -> a > > curry :: ((a,b) -> c) -> a -> b -> c > > => curry id :: ((a,b) -> (a,b)) -> a -> b -> (a,b) > > So basically if > > f = curry id > > then > > f x y = (x,y) > > which means > > curry id = (,) > > something like this? You got it! > Do I win a price now? ;) I hoped that nobody would care about the puzzle, thus I have not thought about a price so far. :-] _______________________________________________ Haskell-Cafe mailing list [hidden email] http://www.haskell.org/mailman/listinfo/haskell-cafe |
Free forum by Nabble | Edit this page |