[Haskell-cafe] Strictness in do block

Bulat Ziganshin bulat.ziganshin at gmail.com
Wed Jul 5 08:18:05 EDT 2006

Hello John,

Wednesday, July 5, 2006, 3:04:22 PM, you wrote:

> What I want to know is the generic way to force an entire String (or
> other list, perhaps from hGetContents) to be evaluated (read into RAM, I
> guess) so the underlying file can be closed.... and do it right now.

eval [] = []
eval (x:xs) = eval xs

  do str <- getContents
     return $! eval str

is my usual hack. there is also `deepSeq` if you need to fully
evaluate more complex structure. btw, this 'eval' don't evaluate list
elements - it should be not a problem for evaluation result of

Best regards,
 Bulat                            mailto:Bulat.Ziganshin at gmail.com

More information about the Haskell-Cafe mailing list