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
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
#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
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
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
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
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
>
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
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
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
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
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
> >
>
>
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
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;
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
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
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
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
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
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
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
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
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
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.
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
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
26 matches
Mail list logo