summaryrefslogtreecommitdiff
path: root/src/Storage
diff options
context:
space:
mode:
Diffstat (limited to 'src/Storage')
-rw-r--r--src/Storage/Merge.hs10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/Storage/Merge.hs b/src/Storage/Merge.hs
index 17b02aa..f0eaf98 100644
--- a/src/Storage/Merge.hs
+++ b/src/Storage/Merge.hs
@@ -6,6 +6,8 @@ module Storage.Merge (
ancestors,
precedes,
filterAncestors,
+
+ findProperty,
) where
import qualified Data.ByteString.Char8 as BC
@@ -58,4 +60,12 @@ precedes :: Storable a => Stored a -> Stored a -> Bool
precedes x y = x `S.member` ancestors [y]
filterAncestors :: Storable a => [Stored a] -> [Stored a]
+filterAncestors [x] = [x]
filterAncestors xs = uniq $ sort $ filter (`S.notMember` ancestors xs) xs
+
+
+findProperty :: forall a b. Storable a => (a -> Maybe b) -> [Stored a] -> [b]
+findProperty sel = map (fromJust . sel . fromStored) . filterAncestors . (findPropHeads =<<)
+ where findPropHeads :: Stored a -> [Stored a]
+ findPropHeads sobj | Just _ <- sel $ fromStored sobj = [sobj]
+ | otherwise = findPropHeads =<< previous sobj