title: fgl library: node context not providing expected outgoing connections lists with ufold
body: <p>Take the following edges in the <code>{A,B,C,D,E}</code> graph:</p>
  
  <pre><code>A -&gt; B
  C -&gt; D
  C -&gt; E
  D -&gt; A
  </code></pre>
  
  <p>where the nodes are indexed with an <code>Int</code>:</p>
  
  <pre><code>-5959232120642455838 -&gt; "A"
  -5322791284737046018 -&gt; "B"
  6963039171755682694  -&gt; "C"
  -5226022365236209258 -&gt; "D"
  -5226022365169098782 -&gt; "E"
  </code></pre>
  
  <p>The <code>ufold</code> provided by fgl provides a context at each node A, B, C, D and E.</p>
  
  <pre class="lang-hs prettyprint-override"><code>ufold :: Graph gr =&gt; (Context a b -&gt; c -&gt; c) -&gt; c -&gt; gr a b -&gt; c
  type Context a b = (Adj b, Node, a, Adj b)
  type Adj b = [(b, Node)]
  </code></pre>
  
  <p>Here's a function that generates a <code>String</code> showing the current visited node and a list of all of its outgoing connections.</p>
  
  <pre class="lang-hs prettyprint-override"><code>getOutgoing :: Gr String String -&gt; [String]
  getOutgoing myGraph =
    ufold (\(_,_,nodeStr,connsOut) st -&gt; 
        (nodeStr ++ " -&gt; " ++ show (map snd connsOut)) : st)
          [] myGraph
  </code></pre>
  
  <p>For the connections listed above, I would expect this <code>getOutgoing</code> to return:</p>
  
  <pre><code>A -&gt; [-5322791284737046018]
  B -&gt; []
  C -&gt; [-5226022365236209258,-5226022365169098782]
  D -&gt; [-5959232120642455838]
  E -&gt; []
  </code></pre>
  
  <p>However, it returns:</p>
  
  <pre><code>A -&gt; [-5322791284737046018]
  B -&gt; []
  D -&gt; []
  E -&gt; []
  C -&gt; []
  </code></pre>
  
  <p>This is a complete version:</p>
  
  <pre class="lang-hs prettyprint-override"><code>module Main where
  
  import Data.Graph.Inductive.Graph
  import Data.Graph.Inductive.PatriciaTree (Gr)
  
  grEdges :: [LEdge String]
  grEdges = [ (-5959232120642455838, -5322791284737046018,"AtoB")
            , (6963039171755682694,  -5226022365236209258,"CtoD")
            , (6963039171755682694,  -5226022365169098782,"CtoE")
            , (-5226022365236209258, -5959232120642455838,"DtoA") ]
  
  grNodes :: [LNode String]
  grNodes = [ (-5959232120642455838,"A")
            , (-5322791284737046018,"B")
            , (6963039171755682694,"C")
            , (-5226022365236209258,"D")
            , (-5226022365169098782,"E") ]
  
  getOutgoing :: Gr String String -&gt; [String]
  getOutgoing myGraph =
      ufold (\(_,_,nodeStr,connsOut) st -&gt;
         (nodeStr ++ " -&gt; " ++ show (map snd connsOut)) : st)
            [] myGraph
  
  main :: IO ()
  main = do
    putStrLn "Expected outgoing connections to nodeIDs:"
    mapM_ putStrLn [ "A -&gt; [-5322791284737046018]"
                   , "B -&gt; []"
                   , "C -&gt; [-5226022365236209258,-5226022365169098782]"
                   , "D -&gt; [-5959232120642455838]"
                   , "E -&gt; []" ]
  
    putStrLn "Actual outgoing connections to nodeIDs:"
    let gr = mkGraph grNodes grEdges :: Gr String String
    mapM_ putStrLn (getOutgoing gr)
  </code></pre>
  
  <p>So, why for nodes C and D, is <code>ufold</code> providing a node context containing an empty list for their outgoing connections? </p>