mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-23 19:42:50 -06:00
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.
This commit is contained in:
@@ -266,8 +266,10 @@ topoTest = topologicalSort . mkRel'
|
|||||||
|
|
||||||
-- | topological sorting with test of cyclicity, new version /TH 2012-06-26
|
-- | topological sorting with test of cyclicity, new version /TH 2012-06-26
|
||||||
topoTest2 :: Ord a => [(a,[a])] -> Either [[a]] [[a]]
|
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
|
where
|
||||||
|
g = g0++[(n,[])|n<-nub (concatMap snd g0)\\map fst g0]
|
||||||
|
|
||||||
cycles = findCycles (mkRel' g)
|
cycles = findCycles (mkRel' g)
|
||||||
|
|
||||||
tsort nes =
|
tsort nes =
|
||||||
|
|||||||
Reference in New Issue
Block a user