[Haskell-cafe] enforcing strictness on arbitrary subexpressions

Nils Anders Danielsson nad at cs.chalmers.se
Wed Mar 1 11:57:01 EST 2006

On Thu, 16 Feb 2006, Udo Stenzel <u.stenzel at web.de> wrote:

>> hPutStr stdout $ foldr seq veryLongString veryLongString
> There is no primitive to do this for arbitrary data types, but the
> DeepSeq type class comes close.  You can find DeepSeq and some more
> hints on strict evaluation at
> <http://users.aber.ac.uk/afc/stricthaskell.html>.

You can also use Control.Parallel.Strategies:

Prelude Control.Parallel.Strategies> take 2 (repeat 'x')
Prelude Control.Parallel.Strategies> take 2 (repeat 'x' `using` rnf)

(No more output.)


More information about the Haskell-Cafe mailing list