Small optimisations
This commit is contained in:
+3
-2
@@ -49,13 +49,14 @@ instance Foldable FTree where
|
||||
{- Tree with values at and only at the leaves. -}
|
||||
data LTree a
|
||||
= LBranches [LTree a]
|
||||
| LLeaf a
|
||||
| LLeaf !a
|
||||
instance Foldable LTree where
|
||||
foldMap g (LBranches ts) = mconcat $ map (foldMap g) ts
|
||||
foldMap g (LLeaf a) = g a
|
||||
{-# INLINE foldMap #-}
|
||||
foldr _ x (LBranches []) = x
|
||||
foldr g x (LBranches (t:ts)) = foldr g (foldr g x (LBranches ts)) t
|
||||
foldr g x (LBranches (t:ts)) = foldr g (foldr g x t) (LBranches ts)
|
||||
--foldr g x (LBranches (t:ts)) = foldr g (foldr g x (LBranches ts)) t
|
||||
foldr g x (LLeaf y) = g y x
|
||||
{-# INLINE foldr #-}
|
||||
foldl' _ x (LBranches []) = x
|
||||
|
||||
Reference in New Issue
Block a user