Skip to content

Commit e0fa8c0

Browse files
committed
FIX: toposort will always be buggy ;-)
1 parent 23b08b1 commit e0fa8c0

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

HB/common/database.elpi

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,12 +179,18 @@ toposort-proj Proj ES In Out :- !, toposort-proj.acc Proj ES [] In Out.
179179
pred topo-find i:B, o:A.
180180
pred toposort-proj.acc i:(A -> B -> prop), i:list (pair B B), i:list B, i:list A, o:list A.
181181
toposort-proj.acc _ ES Acc [] Out :- !,
182-
std.map {std.toposort ES Acc} topo-find Out.
182+
std.map {std.toposort ES Acc} topo-find-all Out.
183183
toposort-proj.acc Proj ES Acc [A|In] Out :- std.do![
184184
Proj A B,
185185
topo-find B A => toposort-proj.acc Proj ES [B|Acc] In Out
186186
].
187187

188+
pred topo-find-all i:B, o:A.
189+
topo-find-all B A :- std.do! [
190+
std.findall (topo-find B C_) L,
191+
std.assert! (std.forall L (x\ x = topo-find B A)) "topofind bad",
192+
].
193+
188194
% Classes can be topologically sorted according to the subclass relation
189195
pred toposort-classes.mk-class-edge i:prop, o:pair classname classname.
190196
toposort-classes.mk-class-edge (sub-class C1 C2 _ _) (pr C2 C1).

0 commit comments

Comments
 (0)