[Haskell-cafe] What is the role of $!?
lemming at henning-thielemann.de
Mon Nov 19 09:01:45 EST 2007
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...
> f x = x + 1; f $! (a + b)
> f !x = x + 1; f (a + b)
> mean the same thing?
> Well, you learn something new every day... (I guess wanting a function's
> arguments to evaluate before the rest of that function is quite a common
> thing to want. Neat!)
For my taste it makes the language more complicated that sometimes 'lazy'
is default and 'strict' must be enforced and in other cases it is the
other way round. Would it be a good idea to make 'lazy' the default and
'strict' optional, and the strictness analyzer handles the obvious cases
where there is no difference?
More information about the Haskell-Cafe