X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Futils%2FDigraph.lhs;h=66174592a7c5147f5930f60b41c938546e3e726b;hb=5109078b26bdbf226acdf1b0fe7c2861a7114571;hp=958769c12ac2144524634c271434e439bc1d79b7;hpb=6378e8dbc2b3401e951ad1d0d6b9f450c31f9a05;p=ghc-hetmet.git diff --git a/compiler/utils/Digraph.lhs b/compiler/utils/Digraph.lhs index 958769c..6617459 100644 --- a/compiler/utils/Digraph.lhs +++ b/compiler/utils/Digraph.lhs @@ -3,6 +3,13 @@ % \begin{code} +{-# OPTIONS -w #-} +-- The above warning supression flag is a temporary kludge. +-- While working on this module you are encouraged to remove it and fix +-- any warnings in the module. See +-- http://hackage.haskell.org/trac/ghc/wiki/Commentary/CodingStyle#Warnings +-- for details + module Digraph( -- At present the only one with a "nice" external interface @@ -104,8 +111,8 @@ stronglyConnCompR [] = [] -- added to avoid creating empty array in graphFromEd stronglyConnCompR edges = map decode forest where - (graph, vertex_fn) = _scc_ "graphFromEdges" graphFromEdges edges - forest = _scc_ "Digraph.scc" scc graph + (graph, vertex_fn) = {-# SCC "graphFromEdges" #-} graphFromEdges edges + forest = {-# SCC "Digraph.scc" #-} scc graph decode (Node v []) | mentions_itself v = CyclicSCC [vertex_fn v] | otherwise = AcyclicSCC (vertex_fn v) decode other = CyclicSCC (dec other []) @@ -323,17 +330,17 @@ preArr bnds = tabulate bnds . preorderF ------------------------------------------------------------ \begin{code} ---postorder :: Tree a -> [a] -postorder (Node a ts) = postorderF ts ++ [a] +postorder :: Tree a -> [a] -> [a] +postorder (Node a ts) = postorderF ts . (a :) -postorderF :: Forest a -> [a] -postorderF ts = concat (map postorder ts) +postorderF :: Forest a -> [a] -> [a] +postorderF ts = foldr (.) id $ map postorder ts -postOrd :: Graph -> [Vertex] -postOrd = postorderF . dff +postOrd :: Graph -> [Vertex] +postOrd g = postorderF (dff g) [] -topSort :: Graph -> [Vertex] -topSort = reverse . postOrd +topSort :: Graph -> [Vertex] +topSort = reverse . postOrd \end{code}