[Haskell] Re: state of HaXml?

Taral taralx at gmail.com
Sat Jan 6 13:15:59 EST 2007

On 1/4/07, Stefan Karrmann <S.Karrmann at web.de> wrote:
> My 2 cent:
> Why does seq not help? See code below.

The short answer is because it only forces the head of the value, not
the entire value. You need deepSeq for that.

> load fn = do handle <- IO.openFile fn IO.ReadMode
>              contents <- IO.hGetContents handle
>              let len = length contents
>              seq len $ IO.hClose handle
>              return $ XP.xmlParse fn contents

This works, because to get the head of len (an integer) you need the
whole of contents.

Taral <taralx at gmail.com>
"You can't prove anything."
    -- Gödel's Incompetence Theorem

More information about the Haskell mailing list