Re: [Haskell-cafe] Spot the difference!

2007-09-20 Thread Bas van Dijk
On 9/20/07, PR Stanley <[EMAIL PROTECTED]> wrote: > Hi > \_ n -> 1 + n > \_ -> (\n -> 1 + n) > The outcome seems to be identical. is there a substantive difference > between the two definitions? You can check this out your self by compiling this program and looking at the generated core program li

Re: [Haskell-cafe] Spot the difference!

2007-09-20 Thread Nils Anders Danielsson
On Thu, 20 Sep 2007, PR Stanley <[EMAIL PROTECTED]> wrote: > \_ n -> 1 + n > \_ -> (\n -> 1 + n) > The outcome seems to be identical. is there a substantive difference > between the two definitions? No, since you do not pattern match on the first argument. Otherwise, due to the way these definiti

Re: [Haskell-cafe] Spot the difference!

2007-09-19 Thread ajb
G'day all. Quoting PR Stanley <[EMAIL PROTECTED]>: Fully lazy? Can you elaborate please? Sure. that code again: test1 = \n _ -> 1+n test2 = \n -> let x = n+1 in \_ -> x Suppose we have: f g x = g x + g x And we try two options: f (test1 4) 3 f (test2 4) 3 In the fir

Re: [Haskell-cafe] Spot the difference!

2007-09-19 Thread PR Stanley
test1 n _ = 1 + n test2 n = \_ -> 1 + n I don't know if it's still the case, but GHC used to compile different code for these at high optimisation levels. The first was essentially compiled to: test1 = \n _ -> 1+n And the second to: test2 = \n -> let x = n+1 in \_ -> x The

Re: [Haskell-cafe] Spot the difference!

2007-09-19 Thread ajb
G'day all. Quoting PR Stanley <[EMAIL PROTECTED]>: \_ n -> 1 + n \_ -> (\n -> 1 + n) The outcome seems to be identical. is there a substantive difference between the two definitions? Certainly, GHC compiles these to the same code. But be careful! Consider the following two defintions:

Re: [Haskell-cafe] Spot the difference!

2007-09-19 Thread Tony Morris
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 PR Stanley wrote: > I must confess that the use of "\_" had me a little confused at first > but thinking about it I can see that it makes perfect sense to have an > argument or a wildcard character for any value. > Cheers, Paul FYI If \_ -> foo confus

Re: [Haskell-cafe] Spot the difference!

2007-09-19 Thread Brandon S. Allbery KF8NH
On Sep 20, 2007, at 0:16 , PR Stanley wrote: I must confess that the use of "\_" had me a little confused at first but thinking about it I can see that it makes perfect sense to have an argument or a wildcard character for any value. Sure. Remember, arguments are pattern matches in Haskel

Re: [Haskell-cafe] Spot the difference!

2007-09-19 Thread PR Stanley
I must confess that the use of "\_" had me a little confused at first but thinking about it I can see that it makes perfect sense to have an argument or a wildcard character for any value. Cheers, Paul On Sep 20, 2007, at 0:03 , PR Stanley wrote: \_ n -> 1 + n \_ -> (\n -> 1 + n) The outcom

Re: [Haskell-cafe] Spot the difference!

2007-09-19 Thread Brandon S. Allbery KF8NH
On Sep 20, 2007, at 0:03 , PR Stanley wrote: \_ n -> 1 + n \_ -> (\n -> 1 + n) The outcome seems to be identical. is there a substantive difference between the two definitions? The second one seems to be more expressive of the currying principle. Any thoughts? I *think* the former is inter

[Haskell-cafe] Spot the difference!

2007-09-19 Thread PR Stanley
Hi \_ n -> 1 + n \_ -> (\n -> 1 + n) The outcome seems to be identical. is there a substantive difference between the two definitions? The second one seems to be more expressive of the currying principle. Any thoughts? Thanks, Paul ___ Haskell-Cafe m