summaryrefslogtreecommitdiff
path: root/src/Erebos/Storage
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2024-04-13 08:29:25 +0200
committerRoman Smrž <roman.smrz@seznam.cz>2024-04-17 20:59:41 +0200
commit2c297cb6747080cd47cdcd9bbd23c5f24a092e8f (patch)
tree17dc2a42dc3d33ac92e5dfcd95c442626c11597a /src/Erebos/Storage
parent943cd6e754453f70deae6ad89c6045b42c59e9c9 (diff)
Chatroom metadata updates
Diffstat (limited to 'src/Erebos/Storage')
-rw-r--r--src/Erebos/Storage/Merge.hs4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/Erebos/Storage/Merge.hs b/src/Erebos/Storage/Merge.hs
index 7234b87..9d9db13 100644
--- a/src/Erebos/Storage/Merge.hs
+++ b/src/Erebos/Storage/Merge.hs
@@ -10,6 +10,7 @@ module Erebos.Storage.Merge (
generations,
ancestors,
precedes,
+ precedesOrEquals,
filterAncestors,
storedRoots,
walkAncestors,
@@ -109,6 +110,9 @@ ancestors = last . (S.empty:) . generations
precedes :: Storable a => Stored a -> Stored a -> Bool
precedes x y = not $ x `elem` filterAncestors [x, y]
+precedesOrEquals :: Storable a => Stored a -> Stored a -> Bool
+precedesOrEquals x y = filterAncestors [ x, y ] == [ y ]
+
filterAncestors :: Storable a => [Stored a] -> [Stored a]
filterAncestors [x] = [x]
filterAncestors xs = let xs' = uniq $ sort xs