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)
rather than ask the role of $! I found it helpful to first grasp the role
of seq, since $! is defined in terms of seq and seq is a primitive
operation (no prelude definition, like with IO, it's a given).
What helped me grasp seq was its role in a strict fold.
Basically, try to sum all the
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
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,
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 empty file
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
when the
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
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 the
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 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
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
Wait, so...
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 meant
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 method of
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 engine on
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
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;
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
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
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
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 believe.
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.
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
22 matches
Mail list logo