diff options
author | Roman Smrž <roman.smrz@seznam.cz> | 2024-08-10 19:46:01 +0200 |
---|---|---|
committer | Roman Smrž <roman.smrz@seznam.cz> | 2024-08-10 20:40:12 +0200 |
commit | 5c67b5800a29b10b4a27fdf467cd5a2ecd4fe40a (patch) | |
tree | 635dfb859ccde7377bbb9582953b75163c72ff71 /src/Erebos | |
parent | 8743ed1b3713a764ccb191e83cb006a7c4ac60d4 (diff) |
Include passed objects in generations and ancestors functions
Diffstat (limited to 'src/Erebos')
-rw-r--r-- | src/Erebos/Storage/Merge.hs | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/Erebos/Storage/Merge.hs b/src/Erebos/Storage/Merge.hs index 9d9db13..a3b0fd7 100644 --- a/src/Erebos/Storage/Merge.hs +++ b/src/Erebos/Storage/Merge.hs @@ -97,13 +97,16 @@ storedGeneration x = doLookup x +-- |Returns list of sets starting with the set of given objects and +-- intcrementally adding parents. generations :: Storable a => [Stored a] -> [Set (Stored a)] generations = unfoldr gen . (,S.empty) - where gen (hs, cur) = case filter (`S.notMember` cur) $ previous =<< hs of + where gen (hs, cur) = case filter (`S.notMember` cur) hs of [] -> Nothing added -> let next = foldr S.insert cur added - in Just (next, (added, next)) + in Just (next, (previous =<< added, next)) +-- |Returns set containing all given objects and their ancestors ancestors :: Storable a => [Stored a] -> Set (Stored a) ancestors = last . (S.empty:) . generations |