Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
memowe committed Feb 26, 2024
1 parent 5c198d9 commit 930a409
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/LiBro/Util.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
-- in more than one place.
module LiBro.Util
(
-- * Tree building
-- * Tree utilities
ParentList
, readForest
, findSubtree
-- * Counting monad transformer
, CountingT
, next
Expand Down Expand Up @@ -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

Check warning on line 65 in lib/LiBro/Util.hs

View workflow job for this annotation

GitHub Actions / GHC 9.4 on ubuntu-latest

Defined but not used: ‘pred’

Check warning on line 65 in lib/LiBro/Util.hs

View workflow job for this annotation

GitHub Actions / GHC 9.4 on ubuntu-latest

This binding for ‘pred’ shadows the existing binding

Check warning on line 65 in lib/LiBro/Util.hs

View workflow job for this annotation

GitHub Actions / GHC 9.4 on ubuntu-latest

Defined but not used: ‘forest’

Check warning on line 65 in lib/LiBro/Util.hs

View workflow job for this annotation

GitHub Actions / GHC 9.6 on ubuntu-latest

Defined but not used: ‘pred’

Check warning on line 65 in lib/LiBro/Util.hs

View workflow job for this annotation

GitHub Actions / GHC 9.6 on ubuntu-latest

This binding for ‘pred’ shadows the existing binding

Check warning on line 65 in lib/LiBro/Util.hs

View workflow job for this annotation

GitHub Actions / GHC 9.6 on ubuntu-latest

Defined but not used: ‘forest’
undefined

-- | Simple monad transformer that allows to read an increasing 'Int'.
type CountingT m = StateT Int m

Expand Down
5 changes: 5 additions & 0 deletions test/LiBro/UtilSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import System.IO.Temp
spec :: Spec
spec = describe "Helper stuff" $ do
forestFromParentList
findInForest
countingT
xlsx
guarding
Expand All @@ -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
Expand Down

0 comments on commit 930a409

Please sign in to comment.