{- trace successful path back from (m,n) point to origin -}
successpath table =
  let (_, (m,n)) = bounds table
      aux' (0,0)  = []
      -- arbitrary preference? no, let's show all successful paths.
      aux' (i,j) =
         let diag = any (\x -> case x of (Eq _) -> True ; (Neq _) -> True ; _ -> False) (reasons (table ! (i,j)))
             horz = any (\x -> case x of (X _) -> True ; _ -> False) (reasons (table ! (i,j)))
             vert = any (\x -> case x of (Y _) -> True ; _ -> False) (reasons (table ! (i,j)))
         in
           [(i-1,j-1) | diag] ++ [(i-1,j) | horz] ++ [(i,j-1) | vert]
      aux front accum =
          case S.minView front of
            Nothing         -> accum
            Just ((i,j), s) ->
                let contributions = aux' (i,j)
                in
                  aux (S.union s     (S.fromList contributions))
                      (S.union accum (S.fromList (map (\x -> (x, (i,j))) contributions)))
  in
    aux (S.fromList [(m,n)]) (S.empty)
successpath table =
  let (_, (m,n)) = bounds table
      aux' (0,0)  = []
      -- arbitrary preference? no, let's show all successful paths.
      aux' (i,j) =
         let diag = any (\x -> case x of (Eq _) -> True ; (Neq _) -> True ; _ -> False) (reasons (table ! (i,j)))
             horz = any (\x -> case x of (X _) -> True ; _ -> False) (reasons (table ! (i,j)))
             vert = any (\x -> case x of (Y _) -> True ; _ -> False) (reasons (table ! (i,j)))
         in
           [(i-1,j-1) | diag] ++ [(i-1,j) | horz] ++ [(i,j-1) | vert]
      aux front accum =
          case S.minView front of
            Nothing         -> accum
            Just ((i,j), s) ->
                let contributions = aux' (i,j)
                in
                  aux (S.union s     (S.fromList contributions))
                      (S.union accum (S.fromList (map (\x -> (x, (i,j))) contributions)))
  in
    aux (S.fromList [(m,n)]) (S.empty)
successpath table =
  let (_, (m,n)) = bounds table
      aux' (0,0)  = []
      -- arbitrary preference? no, let's show all successful paths.
      aux' (i,j) =
         let diag = any (\x -> case x of (Eq _) -> True ; (Neq _) -> True ; _ -> False) (reasons (table ! (i,j)))
             horz = any (\x -> case x of (X _) -> True ; _ -> False) (reasons (table ! (i,j)))
             vert = any (\x -> case x of (Y _) -> True ; _ -> False) (reasons (table ! (i,j)))
         in
           [(i-1,j-1) | diag] ++ [(i-1,j) | horz] ++ [(i,j-1) | vert]
      aux front accum =
          case S.minView front of
            Nothing         -> accum
            Just ((i,j), s) ->
                let contributions = aux' (i,j)
                in
                  aux (S.union s     (S.fromList contributions))
                      (S.union accum (S.fromList (map (\x -> (x, (i,j))) contributions)))
  in
    aux (S.fromList [(m,n)]) (S.empty)