Re: [Haskell-cafe] Currying: The Rationale

2007-05-23 Thread Chad Scherrer
Is (^2) really considered currying? As I understand it, this is syntactic sugar for a section, and might confuse the issue a bit, since it's distinct from ((^) 2). In this case we would have something like Prelude let pow2 = ((^) 2) Prelude map pow2 [1..10] [2,4,8,16,32,64,128,256,512,1024] I

Re: [Haskell-cafe] Currying: The Rationale

2007-05-23 Thread Philippa Cowderoy
On Wed, 23 May 2007, Chad Scherrer wrote: Is (^2) really considered currying? As I understand it, this is syntactic sugar for a section, and might confuse the issue a bit, since it's distinct from ((^) 2). Sure, but it's (flip (^)) 2. -- [EMAIL PROTECTED] Sometimes you gotta fight fire

Re: [Haskell-cafe] Currying: The Rationale

2007-05-23 Thread Albert Y. C. Lai
PR Stanley wrote: What is the rationale behind currying? Given map :: (a-b) - [a]-[b] take :: Int - [a] - [a] I can write map f . take 10 or take 10 map f. Given tmap :: (a-b, [a]) - [b] ttake :: (Int, [a]) - [a] I have to write \x - tmap(f, ttake(10, x)). It is not just

Re: [Haskell-cafe] Currying: The Rationale

2007-05-23 Thread Chad Scherrer
On 5/23/07, Philippa Cowderoy [EMAIL PROTECTED] wrote: On Wed, 23 May 2007, Chad Scherrer wrote: Is (^2) really considered currying? As I understand it, this is syntactic sugar for a section, and might confuse the issue a bit, since it's distinct from ((^) 2). Sure, but it's (flip (^)) 2.

Re: [Haskell-cafe] Currying: The Rationale

2007-05-23 Thread Nicolas Frisby
Disclaimer: I've not read the standard. Sections are de-sugared depending on which argument you supply: (x^) == (^) x (^x) == flip (^) x I think this is why they are considered special cases. Prelude map (^2) [1..10] [1,4,9,16,25,36,49,64,81,100] Prelude map (flip (^) 2) [1..10]

Re: [Haskell-cafe] Currying: The Rationale

2007-05-23 Thread Derek Elkins
Chad Scherrer wrote: On 5/23/07, Philippa Cowderoy [EMAIL PROTECTED] wrote: On Wed, 23 May 2007, Chad Scherrer wrote: Is (^2) really considered currying? As I understand it, this is syntactic sugar for a section, and might confuse the issue a bit, since it's distinct from ((^) 2). Sure,

[Haskell-cafe] Currying: The Rationale

2007-05-22 Thread PR Stanley
Hi What is the rationale behind currying? is it for breaking subroutines into pure one-to-one mappings? If f x y = f x - a function which takes y for argument then does that mean that the second function already has value x, as it were, built into it? The syntax in Haskell is perfectly lucid

Re: [Haskell-cafe] Currying: The Rationale

2007-05-22 Thread Philippa Cowderoy
On Wed, 23 May 2007, PR Stanley wrote: Hi What is the rationale behind currying? is it for breaking subroutines into pure one-to-one mappings? We don't have 'subroutines' as such, but otherwise yes. Also, it gives us partial application - we don't have to apply all the parameters at once,

Re: [Haskell-cafe] Currying: The Rationale

2007-05-22 Thread PR Stanley
Hi What is the rationale behind currying? is it for breaking subroutines into pure one-to-one mappings? We don't have 'subroutines' as such, but otherwise yes. Also, it gives us partial application - we don't have to apply all the parameters at once, and we can do interesting and useful

Re: [Haskell-cafe] Currying: The Rationale

2007-05-22 Thread Brandon S. Allbery KF8NH
On May 22, 2007, at 22:35 , PR Stanley wrote: Could you perhaps demonstrate how you can apply parts of curried functions in other functions in Haskell? A trivial example: Prelude map (+1) [1..10] [2,3,4,5,6,7,8,9,10,11] (Strictly speaking (+1) is a section, but that's just a syntactic

Re: [Haskell-cafe] Currying: The Rationale

2007-05-22 Thread Donald Bruce Stewart
prstanley: Hi What is the rationale behind currying? is it for breaking subroutines into pure one-to-one mappings? We don't have 'subroutines' as such, but otherwise yes. Also, it gives us partial application - we don't have to apply all the parameters at once, and we can do