foldMapDefault,
) where
-import Prelude hiding (mapM, sequence)
-import qualified Prelude (mapM)
+import Prelude hiding (mapM, sequence, foldr)
+import qualified Prelude (mapM, foldr)
import Control.Applicative
-import Data.Foldable (Foldable)
+import Data.Foldable (Foldable())
import Data.Monoid (Monoid)
import Data.Array
traverse f (Just x) = Just <$> f x
instance Traversable [] where
- traverse f = foldr cons_f (pure [])
+ traverse f = Prelude.foldr cons_f (pure [])
where cons_f x ys = (:) <$> f x <*> ys
mapM = Prelude.mapM
-- | The elements of a tree in pre-order.
flatten :: Tree a -> [a]
flatten t = squish t []
- where squish (Node x ts) xs = x:foldr squish xs ts
+ where squish (Node x ts) xs = x:Prelude.foldr squish xs ts
-- | Lists of nodes at each level of the tree.
levels :: Tree a -> [[a]]
#ifndef __NHC__
unfoldForestM :: Monad m => (b -> m (a, [b])) -> [b] -> m (Forest a)
#endif
-unfoldForestM f = mapM (unfoldTreeM f)
+unfoldForestM f = Prelude.mapM (unfoldTreeM f)
-- | Monadic tree builder, in breadth-first order,
-- using an algorithm adapted from
EmptyL -> return empty
a :< aQ -> do
(b, as) <- f a
- tQ <- unfoldForestQ f (foldl (|>) aQ as)
+ tQ <- unfoldForestQ f (Prelude.foldl (|>) aQ as)
let (tQ', ts) = splitOnto [] as tQ
return (Node b ts <| tQ')
where splitOnto :: [a'] -> [b'] -> Seq a' -> (Seq a', [a'])