[Haskell] simple function: stack overflow in hugs vs none in ghc
john lask
jvlask at hotmail.com
Thu Sep 20 18:30:11 EDT 2007
Hi
hoping someone can shed some light on this:
The following code causes a "C stack overflow" in hugs (version 20051031)
but not in ghc (version 6.6)
The point of the exercise is to process a very large file lazily, returning
the consumed and unconsumed
parts (i.e. basic parser combinators).
The simplified (stylised example of the problem) is displayed bellow.
test1 (on a large file) will succeed in ghc but fail in hugs
test2 on same file will succeed in both ghc and hugs
the problem appears to be retaining a hold on the unconsummed portion and
returning it.
maybe something to do with updating CAFS, all too subtle for me.
The question: is there any changes that can be made to the code to make
test1 work in
hugs without changing the essence of the function.
>test1 = readFile "big.dat" >>= (\x->print $ parse x)
>test2 = readFile "big.dat" >>= (\x->print $ fst $ parse x)
big.dat is just some large data file say 1MB. (not particularly large by
todays standards!)
>parse x = sqnc item x
> where
>
> item =( \ ts -> case ts of
> [] -> ( Nothing, [])
> ts -> ( Just (head ts), tail ts) )
>
> sqnc p ts = let ( r, ts' ) = p ts in case r of
> Nothing -> ([],ts')
> Just x -> let (r',ts'') = (sqnc p ts') in (
>x:r', ts'' )
_________________________________________________________________
Advertisement: Search for local singles online at Lavalife
http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Flavalife9%2Eninemsn%2Ecom%2Eau%2Fclickthru%2Fclickthru%2Eact%3Fid%3Dninemsn%26context%3Dan99%26locale%3Den%5FAU%26a%3D30290&_t=764581033&_r=email_taglines_Search&_m=EXT
More information about the Haskell
mailing list