Commit before picture change

This commit is contained in:
2021-02-28 21:26:20 +01:00
parent 4a85177522
commit bb05bcaaf1
5 changed files with 143 additions and 44 deletions
+12
View File
@@ -25,6 +25,18 @@ instance Foldable FTree where
foldMap g (FLeaf x) = g x
{-# INLINE foldMap #-}
data LTree a
= LBranches [LTree a]
| LLeaf a
instance Foldable LTree where
foldMap g (LBranches ts) = mconcat $ map (foldMap g) ts
foldMap g (LLeaf a) = g a
{-# INLINE foldMap #-}
instance Functor LTree where
fmap f (LBranches ts) = LBranches $ (fmap (fmap f)) ts
fmap f (LLeaf x) = LLeaf (f x)
flat2 (x,y) = [x,y]
flat3 (x,y,z) = [x,y,z]
flat4 (x,y,z,w) = [x,y,z,w]