<div dir="ltr">Dear Haskellers,<br><br>In another thread [1], I talked about computing what I've been lately calling the "total descendents" of a subset S of a graph: that is, the set of nodes t for which every maximal sequence of predecessors intersects S. I got it done, functionally [2]. But in the process I wrote something that hangs, and I can't figure out why.<br><br>The problem arose in the following passage. (Glab stands for Graph Label, a synonym for Int.)<br><br>    totalDescendents :: S.Set Glab -> Graph -> S.Set Glab<br>    totalDescendents roots graph = b<br>      where (a,b,c,graph) = totalDescendentsCtrlr  -- tricky<br>                            (roots, S.empty, M.empty, graph)<br><br>    totalDescendentsCtrlr :: TotalDescendentsData -> TotalDescendentsData<br>    totalDescendentsCtrlr (a,b,c,gr) =<br>      if S.null a' -- fails, as does a == a'<br>        -- a == a' is one iteration slower but should have same effect<br>        then                       (a',b',c',gr')<br>        else totalDescendentsCtrlr (a',b',c',gr')<br>      where (a',b',c',gr') = visitUndetPrds $ visitTdSnvSucs (a,b,c,gr)<br><br>Notice that in the equation marked "tricky", the object "graph" appears on both sides. I thought that was the problem, so I rewrote that line as the following:<br>      where (_,b,_,_) = totalDescendentsCtrlr<br>and sure enough, the problem vanished.<br><br>So I tried to distill that problem to something tiny, and came up with this:<br><br>  f (a) = a'<br>    where (a',b) = fBackend (a,b) -- tricky<br><br>  fBackend (a,b) =<br>    if a' < 1<br>      then          (a',b)<br>      else fBackend (a',b)<br>    where a' = a - 1<br><br>I see no substantive difference between the problem with the first body of code and the problem I expected f and fBackend to have -- but f and fBackend work fine!<br><br>Any idea what might be happening?<br><br>Thanks,<br>Jeff<br><br><br>[1] <a href="http://permalink.gmane.org/gmane.comp.lang.haskell.cafe/115353">http://permalink.gmane.org/gmane.comp.lang.haskell.cafe/115353</a><br>[2] <a href="https://github.com/JeffreyBenjaminBrown/digraphs-on-text/blob/master/TotalDescendents.hs">https://github.com/JeffreyBenjaminBrown/digraphs-on-text/blob/master/TotalDescendents.hs</a><br></div>