Partial fix of inventory rendering
This commit is contained in:
+8
-3
@@ -37,22 +37,27 @@ data FTree a
|
||||
= FBranch (a -> a) (FTree a)
|
||||
| FBranches [FTree a]
|
||||
| FLeaf a
|
||||
|
||||
instance Foldable FTree where
|
||||
foldMap g (FBranch f t) = foldMap (g . f) t
|
||||
foldMap g (FBranches ts) = mconcat $ map (foldMap g) ts
|
||||
foldMap g (FLeaf x) = g x
|
||||
{-# INLINE foldMap #-}
|
||||
|
||||
instance Functor FTree where
|
||||
fmap g (FBranch f t) = fmap (g . f) t
|
||||
fmap f (FBranches ts) = FBranches $ fmap (fmap f) ts
|
||||
fmap f (FLeaf x) = FLeaf (f x)
|
||||
{-# INLINE fmap #-}
|
||||
|
||||
{- 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 x t `seq` foldr g (foldr g x t) (LBranches ts)
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user