summaryrefslogtreecommitdiff
path: root/src/compiler/GF/Data
diff options
context:
space:
mode:
authorhallgren <hallgren@chalmers.se>2013-02-28 17:46:13 +0000
committerhallgren <hallgren@chalmers.se>2013-02-28 17:46:13 +0000
commit8200145513b56b914c9c1896a8293ad4d5b58af9 (patch)
tree60fd3a763ee1aaee4c17ddf2468ab1dd7f2ecb73 /src/compiler/GF/Data
parent95d77e3c37fa97f770d845dd0d05890455f8119e (diff)
Fix a bug that could cause "Prelude.head: empty list"
In Data.Operations, the function topoTest2 assumed too much about the form of the input, compared to the older function topoTest.
Diffstat (limited to 'src/compiler/GF/Data')
-rw-r--r--src/compiler/GF/Data/Operations.hs4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/compiler/GF/Data/Operations.hs b/src/compiler/GF/Data/Operations.hs
index 366f5a669..b70df6a90 100644
--- a/src/compiler/GF/Data/Operations.hs
+++ b/src/compiler/GF/Data/Operations.hs
@@ -266,8 +266,10 @@ topoTest = topologicalSort . mkRel'
-- | topological sorting with test of cyclicity, new version /TH 2012-06-26
topoTest2 :: Ord a => [(a,[a])] -> Either [[a]] [[a]]
-topoTest2 g = maybe (Right cycles) Left (tsort g)
+topoTest2 g0 = maybe (Right cycles) Left (tsort g)
where
+ g = g0++[(n,[])|n<-nub (concatMap snd g0)\\map fst g0]
+
cycles = findCycles (mkRel' g)
tsort nes =