[commit: ghc] master: utils: detabify/dewhitespace Digraph (3c5fc8e)

git at git.haskell.org git at git.haskell.org
Sun Jul 20 21:57:54 UTC 2014


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/3c5fc8eac2c0b0e34abde8eb53fddc6555546f28/ghc

>---------------------------------------------------------------

commit 3c5fc8eac2c0b0e34abde8eb53fddc6555546f28
Author: Austin Seipp <austin at well-typed.com>
Date:   Fri Jul 18 22:31:13 2014 -0500

    utils: detabify/dewhitespace Digraph
    
    Signed-off-by: Austin Seipp <austin at well-typed.com>


>---------------------------------------------------------------

3c5fc8eac2c0b0e34abde8eb53fddc6555546f28
 compiler/utils/Digraph.lhs | 37 +++++++++++++++----------------------
 1 file changed, 15 insertions(+), 22 deletions(-)

diff --git a/compiler/utils/Digraph.lhs b/compiler/utils/Digraph.lhs
index d22380f..35782ba 100644
--- a/compiler/utils/Digraph.lhs
+++ b/compiler/utils/Digraph.lhs
@@ -4,13 +4,6 @@
 
 \begin{code}
 {-# LANGUAGE CPP, ScopedTypeVariables #-}
-{-# OPTIONS_GHC -fno-warn-tabs #-}
--- The above warning supression flag is a temporary kludge.
--- While working on this module you are encouraged to remove it and
--- detab the module (please do the detabbing in a separate patch). See
---     http://ghc.haskell.org/trac/ghc/wiki/Commentary/CodingStyle#TabsvsSpaces
--- for details
-
 module Digraph(
         Graph, graphFromVerticesAndAdjacency, graphFromEdgedVertices,
 
@@ -78,10 +71,10 @@ Note [Nodes, keys, vertices]
  * A 'node' is a big blob of client-stuff
 
  * Each 'node' has a unique (client) 'key', but the latter
-	is in Ord and has fast comparison
+        is in Ord and has fast comparison
 
  * Digraph then maps each 'key' to a Vertex (Int) which is
-  	arranged densely in 0.n
+        arranged densely in 0.n
 
 \begin{code}
 data Graph node = Graph {
@@ -97,7 +90,7 @@ type Node key payload = (payload, key, [key])
      -- The keys are ordered
      -- The [key] are the dependencies of the node;
      --    it's ok to have extra keys in the dependencies that
-     --	   are not the key of any Node in the graph
+     --    are not the key of any Node in the graph
 
 emptyGraph :: Graph a
 emptyGraph = Graph (array (1, 0) []) (error "emptyGraph") (const Nothing)
@@ -168,18 +161,18 @@ reduceNodesIntoVertices nodes key_extractor = (bounds, (!) vertex_map, key_verte
 
 \begin{code}
 type WorkItem key payload
-  = (Node key payload,	-- Tip of the path
-     [payload])	  	-- Rest of the path; 
-     			--  [a,b,c] means c depends on b, b depends on a
+  = (Node key payload,  -- Tip of the path
+     [payload])         -- Rest of the path;
+                        --  [a,b,c] means c depends on b, b depends on a
 
 -- | Find a reasonably short cycle a->b->c->a, in a strongly
 -- connected component.  The input nodes are presumed to be
 -- a SCC, so you can start anywhere.
 findCycle :: forall payload key. Ord key
           => [Node key payload]     -- The nodes.  The dependencies can
-	     	     	  	    -- contain extra keys, which are ignored
-	  -> Maybe [payload]        -- A cycle, starting with node
-	     			    -- so each depends on the next
+                                    -- contain extra keys, which are ignored
+          -> Maybe [payload]        -- A cycle, starting with node
+                                    -- so each depends on the next
 findCycle graph
   = go Set.empty (new_work root_deps []) []
   where
@@ -195,14 +188,14 @@ findCycle graph
 
 
     -- 'go' implements Dijkstra's algorithm, more or less
-    go :: Set.Set key	-- Visited
-       -> [WorkItem key payload]	-- Work list, items length n
-       -> [WorkItem key payload]	-- Work list, items length n+1
-       -> Maybe [payload]		-- Returned cycle
+    go :: Set.Set key   -- Visited
+       -> [WorkItem key payload]        -- Work list, items length n
+       -> [WorkItem key payload]        -- Work list, items length n+1
+       -> Maybe [payload]               -- Returned cycle
        -- Invariant: in a call (go visited ps qs),
        --            visited = union (map tail (ps ++ qs))
 
-    go _       [] [] = Nothing	-- No cycles
+    go _       [] [] = Nothing  -- No cycles
     go visited [] qs = go visited qs []
     go visited (((payload,key,deps), path) : ps) qs
        | key == root_key           = Just (root_payload : reverse path)
@@ -211,7 +204,7 @@ findCycle graph
        | otherwise                 = go (Set.insert key visited)
                                         ps (new_qs ++ qs)
        where
-	 new_qs = new_work deps (payload : path)
+         new_qs = new_work deps (payload : path)
 
     new_work :: [key] -> [payload] -> [WorkItem key payload]
     new_work deps path = [ (n, path) | Just n <- map (`Map.lookup` env) deps ]



More information about the ghc-commits mailing list