[Haskell-beginners] hClose: illegal operation (handle is finalized) and/or <<loop>>

anderson leo fireman119 at gmail.com
Tue Aug 17 20:04:23 EDT 2010

It seems there is no empty node which might make a inifinite loop.


On Wed, Aug 18, 2010 at 7:39 AM, Travis Erdman <traviserdman at yahoo.com>wrote:

> > > putStrLn $ show result
> > >
> > > <<loop>>
> >
> > That is the *real* error message.
> >
> > It means that where you define result, you refer to result
> > also on the right-hand side in a way that is an endless
> > loop instead of well-behaved recursion.
> >
> > We would have to see more of your code to be able to
> > say much more.
> Thank you very much ... now I have isolated the offending "loop" code:
> I am folding with a function that takes a tree and the input data, and
> delivers a "processed"/"updated" tree.  The function that is used in the
> fold is "calcTree".  calcTree is also recursive ... it updates the root
> node, then recursively calls itself to update each of its children, which is
> all working fine.  Here are simplified versions of my structure:
> data Tree a = Node a [Tree a]
> calcTree (Node oldData oldsubtree) input = Node newData recurseChildren
>   where
>       {-calculate newData from oldData and input-}
>       recurseChildren = if {BOOLEANS} then oldsubtree else map (\old ->
> calcTree old input) oldsubtree
> And, in words:  if certain conditions become true, there will be no change
> in any decedent node from the current node (ie all newData = oldData, and
> tree structure never changes), so rather than waste exponential time
> traversing all the decedent nodes, I'd like to just re-use the ones I
> already have, as they are identical.  This is "pruning" the tree.  If I
> remove this pruning, the "<<LOOP>>" objection ceases and the code executes
> as expected ... except it takes lots longer than it should, because there
> are usually lots of oppt'ys for pruning, and I'd rather not explicitly
> traverse all of them.
> How can I make this work?
> Thanks again for all the A's to my Q's !
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/beginners/attachments/20100817/c0a09771/attachment-0001.html

More information about the Beginners mailing list