diff --git a/lib/LiBro/Util.hs b/lib/LiBro/Util.hs index e374501..1c2c9af 100644 --- a/lib/LiBro/Util.hs +++ b/lib/LiBro/Util.hs @@ -2,9 +2,10 @@ -- in more than one place. module LiBro.Util ( - -- * Tree building + -- * Tree utilities ParentList , readForest + , findSubtree -- * Counting monad transformer , CountingT , next @@ -59,6 +60,11 @@ readForest pairs = Nothing -> []; Just [] -> [] Just xs -> fill cs <$> sort xs +-- | Find the first matching subtree of a forest +findSubtree :: (a -> Bool) -> Forest a -> Maybe (Tree a) +findSubtree pred forest = do + undefined + -- | Simple monad transformer that allows to read an increasing 'Int'. type CountingT m = StateT Int m diff --git a/test/LiBro/UtilSpec.hs b/test/LiBro/UtilSpec.hs index ade6ee0..e4b451e 100644 --- a/test/LiBro/UtilSpec.hs +++ b/test/LiBro/UtilSpec.hs @@ -18,6 +18,7 @@ import System.IO.Temp spec :: Spec spec = describe "Helper stuff" $ do forestFromParentList + findInForest countingT xlsx guarding @@ -35,6 +36,10 @@ forestFromParentList = describe "Read Forest from parent list" $ do , Node 42 [ Node 84 [ Node (168 :: Int) [] ]] ] +findInForest :: Spec +findInForest = describe "Find matching subtrees in a forest" $ do + undefined + countingT :: Spec countingT = describe "The CountingT 'monad transformer'" $ do let nextTimes n = replicateM n next