flatten, levels,
-- * Building trees
unfoldTree, unfoldForest,
-#ifndef __NHC__
unfoldTreeM, unfoldForestM,
-#endif
unfoldTreeM_BF, unfoldForestM_BF,
) where
unfoldForest :: (b -> (a, [b])) -> [b] -> Forest a
unfoldForest f = map (unfoldTree f)
-#ifndef __NHC__
-- | Monadic tree builder, in depth-first order
unfoldTreeM :: Monad m => (b -> m (a, [b])) -> b -> m (Tree a)
unfoldTreeM f b = do
return (Node a ts)
-- | Monadic forest builder, in depth-first order
+#ifndef __NHC__
unfoldForestM :: Monad m => (b -> m (a, [b])) -> [b] -> m (Forest a)
-unfoldForestM f = mapM (unfoldTreeM f)
#endif
+unfoldForestM f = mapM (unfoldTreeM f)
-- | Monadic tree builder, in breadth-first order,
-- using an algorithm adapted from