Re: [Haskell-cafe] What is the role of $!?

2007-12-10 Thread Dean Herington
Thanks, Tom, for a nice description of lazy evaluation. Besides the minor things Derek pointed out, there's one more subtle but important thing to correct: At 7:29 AM + 11/29/07, Thomas Davie wrote: $! is the special case, which means strictly apply. It evaluates its argument first, *t

Re: role of seq, $!, and bangpatterns illuminated with lazy versus strict folds Re: [Haskell-cafe] What is the role of $!?

2007-12-10 Thread Albert Y. C. Lai
Thomas Hartman wrote: -- (myfoldl f q ) is a curried function that takes a list -- If I understand currectly, in this "lazy" fold, this curried function isn't applied immediately, because -- by default the value of q is still a thunk myfoldl f z [] = z myfoldl f z (x:xs) = ( myfoldl f q ) xs

role of seq, $!, and bangpatterns illuminated with lazy versus strict folds Re: [Haskell-cafe] What is the role of $!?

2007-12-10 Thread Thomas Hartman
#x27; f z (x:xs) = (myfoldl''' f $! q) xs where q = z `f` x PR Stanley <[EMAIL PROTECTED]> Sent by: [EMAIL PROTECTED] 11/14/2007 06:46 PM To haskell-cafe@haskell.org cc Subject [Haskell-cafe] What is the role of $!? Hi What is the role of $! ? As far as I can g

Re: [Haskell-cafe] What is the role of $!?

2007-12-10 Thread Jules Bean
David Fox wrote: Here is a practical example I ran into a few days ago. With this expression: writeFile path (compute text) the file at path would be overwritten with an empty file if an error occurs while evaluating (compute text). With this one: writeFile path $! (compute text) th

Re: [Haskell-cafe] What is the role of $!?

2007-12-09 Thread David Fox
Argh, that last sentence should read "the file is left alone".. On Dec 9, 2007 10:15 PM, David Fox <[EMAIL PROTECTED]> wrote: > Here is a practical example I ran into a few days ago. With this > expression: > >writeFile path (compute text) > > the file at path would be overwritten with an em

Re: [Haskell-cafe] What is the role of $!?

2007-12-09 Thread David Fox
Here is a practical example I ran into a few days ago. With this expression: writeFile path (compute text) the file at path would be overwritten with an empty file if an error occurs while evaluating (compute text). With this one: writeFile path $! (compute text) the file alone when an e

Re: [Haskell-cafe] What is the role of $!?

2007-11-30 Thread Derek Elkins
On Thu, 2007-11-29 at 07:29 +, Thomas Davie wrote: > On 29 Nov 2007, at 06:32, PR Stanley wrote: > > > Hi > > Thanks for the response. > > > > JCC: In most languages, if you have some expression E, and when the > > computer attempts to evaluate E it goes in to an infinite loop, then >

Re: [Haskell-cafe] What is the role of $!?

2007-11-28 Thread Thomas Davie
On 29 Nov 2007, at 06:32, PR Stanley wrote: Hi Thanks for the response. JCC: In most languages, if you have some expression E, and when the computer attempts to evaluate E it goes in to an infinite loop, then when the computer attempts to evaluate the expression f(E), it also goes into an

Re: [Haskell-cafe] What is the role of $!?

2007-11-28 Thread PR Stanley
Hi Thanks for the response. JCC: In most languages, if you have some expression E, and when the computer attempts to evaluate E it goes in to an infinite loop, then when the computer attempts to evaluate the expression f(E), it also goes into an infinite loop, regardless of what f is. That's

Re: [Haskell-cafe] What is the role of $!?

2007-11-28 Thread Luke Palmer
On Nov 29, 2007 4:23 AM, PR Stanley <[EMAIL PROTECTED]> wrote: > PRS: You would also get different results - e.g. > let a = 3, b = 7, c = 2 > therefore 20 = strict ( ( (a+(b*c)) ) > therefore 17 = non-strict ( (a+(b*c)) ) > > or am I misunderstanding

Re: [Haskell-cafe] What is the role of $!?

2007-11-28 Thread PR Stanley
Hi Thanks for the explanation. I would be grateful for some examples accompanying the text. I will indicate the right places for real life (Haskell code) examples in the paragraphs below: PJ: As I understand it, the distinction is between the mathematical term "non-strict" and the implementa

Re: [Haskell-cafe] What is the role of $!?

2007-11-19 Thread Henning Thielemann
On Sun, 18 Nov 2007, Andrew Coppin wrote: > Lauri Alanko wrote: > > Please note that if you're using GHC, bang patterns are often much > > more convenient than $! or seq when you want to enforce strictness: > > > > http://www.haskell.org/ghc/docs/latest/html/users_guide/bang-patterns.html > > > >

Re[2]: [Haskell-cafe] What is the role of $!?

2007-11-18 Thread Bulat Ziganshin
Hello Andrew, Sunday, November 18, 2007, 10:04:15 PM, you wrote: > Wait, so... f x = ... g = f $! x > and f !x = ... g = f x > mean the same thing? in both cases, x is evaluated before evaluating body of x. but of course, this happens only at the moment when value of (f x) itself is required

Re: [Haskell-cafe] What is the role of $!?

2007-11-18 Thread Andrew Coppin
Lauri Alanko wrote: Please note that if you're using GHC, bang patterns are often much more convenient than $! or seq when you want to enforce strictness: http://www.haskell.org/ghc/docs/latest/html/users_guide/bang-patterns.html Wait, so... f x = x + 1; f $! (a + b) and f !x = x + 1;

Re: [Haskell-cafe] What is the role of $!?

2007-11-18 Thread Lauri Alanko
Please note that if you're using GHC, bang patterns are often much more convenient than $! or seq when you want to enforce strictness: http://www.haskell.org/ghc/docs/latest/html/users_guide/bang-patterns.html Lauri ___ Haskell-Cafe mailing list Haskel

Re: [Haskell-cafe] What is the role of $!?

2007-11-18 Thread David Menendez
On Nov 18, 2007 9:23 AM, Paul Johnson <[EMAIL PROTECTED]> wrote: > Obviously there is a strong correspondance between a thunk and a > partly-evaluated expression. Hence in most cases the terms "lazy" and > "non-strict" are synonyms. But not quite. For instance you could > imagine an evaluation e

Re: [Haskell-cafe] What is the role of $!?

2007-11-18 Thread Paul Johnson
Andrew Coppin wrote: PS. There is a technical distinction between the terms "lazy" and "non-strict", and also the opposite terms "eger" and "strict". I couldn't tell you what that is. As I understand it, the distinction is between the mathematical term "non-strict" and the implementation meth

Re: [Haskell-cafe] What is the role of $!?

2007-11-18 Thread Andrew Coppin
PR Stanley wrote: Hi okay, so $! is a bit like $ i.e. the equivalent of putting parentheses around the righthand expression. I'm still not sure of the difference between $ and $!. Maybe it's because I don't understand the meaning of "strict application". While we're on the subject, what's mean

Re: [Haskell-cafe] What is the role of $!?

2007-11-17 Thread Jonathan Cast
On 17 Nov 2007, at 8:04 PM, PR Stanley wrote: Hi okay, so $! is a bit like $ i.e. the equivalent of putting parentheses around the righthand expression. I'm still not sure of the difference between $ and $!. Maybe it's because I don't understand the meaning of "strict application". While w

Re: [Haskell-cafe] What is the role of $!?

2007-11-17 Thread PR Stanley
Hi okay, so $! is a bit like $ i.e. the equivalent of putting parentheses around the righthand expression. I'm still not sure of the difference between $ and $!. Maybe it's because I don't understand the meaning of "strict application". While we're on the subject, what's meant by Haskell being

Re: [Haskell-cafe] What is the role of $!?

2007-11-14 Thread Matthew Brecknell
Jonathan Cast: > Right. (f x) evaluates f and then applies it to x. (f $! x) > evaluates x, evaluates f, and then applies f to x. True, though I'd like to chip in a small refinement: When evaluated, (f x) evaluates f as far as its top-level lambda, then applies it to x, and then continues to

Re: [Haskell-cafe] What is the role of $!?

2007-11-14 Thread Jonathan Cast
On 14 Nov 2007, at 4:32 PM, Shachaf Ben-Kiki wrote: On Nov 14, 2007 4:27 PM, Justin Bailey <[EMAIL PROTECTED]> wrote: It's: f $! x = x `seq` f x That is, the argument to the right of $! is forced to evaluate, and then that value is passed to the function on the left. The function itself is

Re: [Haskell-cafe] What is the role of $!?

2007-11-14 Thread Shachaf Ben-Kiki
On Nov 14, 2007 4:27 PM, Justin Bailey <[EMAIL PROTECTED]> wrote: > It's: > > f $! x = x `seq` f x > > That is, the argument to the right of $! is forced to evaluate, and > then that value is passed to the function on the left. The function > itself is not strictly evaluated (i.e., f x) I don't b

Re: [Haskell-cafe] What is the role of $!?

2007-11-14 Thread Derek Elkins
On Wed, 2007-11-14 at 16:27 -0800, Justin Bailey wrote: > It's: > > f $! x = x `seq` f x > > That is, the argument to the right of $! is forced to evaluate, and > then that value is passed to the function on the left. The function > itself is not strictly evaluated (i.e., f x) I don't believe.

Re: [Haskell-cafe] What is the role of $!?

2007-11-14 Thread Justin Bailey
It's: f $! x = x `seq` f x That is, the argument to the right of $! is forced to evaluate, and then that value is passed to the function on the left. The function itself is not strictly evaluated (i.e., f x) I don't believe. Justin ___ Haskell-Cafe m

[Haskell-cafe] What is the role of $!?

2007-11-14 Thread PR Stanley
Hi What is the role of $! ? As far as I can gather it's something to do with strict application. Could someone explain what it is meant by the term strict application please? Thanks, Paul ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://w